今天在做银行返回报文调用CALL TRANSFORMATION的XML转到SAP结构时,银行返回的日期为YYYYMMDD格式,我定义的SAP结构为SY-DATUM,在STRANS中定义的格式如下
原来想关应该是能直接转换,可结果报错,
An exception has occurred which is explained in more detail below. The
exception is assigned to class ‘CX_SY_CONVERSION_NO_DATE_TIME’ and was not
caught in procedure
“CONVERT_XML_TO_SAP” “(METHOD)”, nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated this
exception, the current program was terminated.
The reason for the exception is:
Date 20220325 has an invalid format. The system could not interpret it in
the representation “yyyy-mm-dd”.
If the termination occurred when using MOVE EXACT, the rules apply for
MOVE EXACT. Otherwise, the rules for the deserialization of type
XSDDATE_D apply.
所以就想着应该可以在转换中调用一下XLST的函数(格式转换),或者是SAP的函数(比如FORMAT_DATE_4_OUTPUT),可把传入的按YYYY-MM-DD转换,可折腾了一整天都有没调用成功。
最后只能用字符截取办法解决,这也算一办法了。办法如下。
1 2 3 4 5 6 7 |
<TRXDATE> <xsl:value-of select="concat(substring(transactionDate,1,4),'-', substring(transactionDate,5,2),'-', substring(transactionDate,7,2))"/> </TRXDATE> <TRXTIME> <xsl:merge-key select="concat(substring(transactionTime,1,2),':', substring(transactionTime,3,2),':', substring(transactionTime,5,2))"/> <!--交易时间--> </TRXTIME> |