Skip to Content

Error on XML Deserialization with DATS Datatype

Nov 02, 2016 at 02:58 PM


avatar image
Former Member


I'm using an XSLT Program to deserialize a XML-File. Inside the XSL I'm assigning the needed values to the fields of my structure. I have one field with the datatype DATS (length 8). Inside the XML File there is a tag which contains a date in the according format

YYYMMDD ( e.g. <DATE>20160522</DATE>).

Whenever I try to assign the value of Date to the structure field with the DATS type I am getting the CX_XSLT_DESERIALIZATION_ERROR.

For troubleshooting I changed the type of the field to a char32 which is working just fine.

How can I cast the value correctly to the dats field?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sandra Rossi Nov 02, 2016 at 04:20 PM

Here are the accepted formats for "asXML" :



XML Scheme Type XML Representation Domain ABAP Representation

xsd:date 2007-10-01 XSDDATE_D "20071001"

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you for your quick answer. I already saw the page for asXML types but that doesn't seem to help me much. Here is an example of how my code looks:

Input XML:

<?xml version="1.0" encoding="UTF-8"?><INVOIC02>

So besides other values, I need to get the value of the <DATUM> tag into a variable of the ABAP type DATS. Here's my XSL-Transformation for that:

<xsl:transform xmlns:xsl="" xmlns:sap="" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/"> <asx:abap xmlns:asx="" version="1.0"> <asx:values> <IDOC_GET> <xsl:apply-templates select="//IDOC"/> </IDOC_GET> </asx:values> </asx:abap> </xsl:template> <xsl:template match="IDOC"> <xsl:for-each select="E1EDK03"> <xsl:if test="IDDAT = 012"> <xsd:element name="DATUM" type="xsd:date"> <DOCDT> <xsl:value-of select="DATUM"/> </DOCDT> </xsd:element> </xsl:if> </xsl:for-each>
... </xsl:template> </xsl:transform>

As already mentioned, I am able to retrieve the date, when the corresponding ABAP-datatype for DOCDT is a character of according lenght. But since the type I need in this case is DATS the selection throws the error.


asxml requires format YYYY-MM-DD.

So, you must use something like:

<xsl:template match="IDOC">
<xsl:for-each select="E1EDK03">
<xsl:if test="string(IDDAT) = '012'">
<DOCDT><xsl:value-of select="concat(substring(DATUM,1,4), '-', substring(DATUM,5,2), '-', substring(DATUM,7,2))"/></DOCDT>
Former Member
Sandra Rossi

That does the trick. Thank you very much. That bothered me a lot longer than it should have.