‎2009 Aug 06 7:57 AM
HI Experts ,
I want to parse this XML file to abap internal table ,i read as usual the Help and i think
that something is missing on my code.
There is someone can help.
The fields is type string and the value is :
<Containers> <Container workitemid = "00000017" IsParent = "X"><Element name = "_WF" value = "USI029"/><Element name = "_WF_PRIOR" value = "5"/><Element name = "_WF_VERSION" value = "0000"/><Element name = "_WF_NESTING_LEVEL" value = ""/><Element name = "XUBNAME" value = ""/><Element name = "XUACCNT" value = ""/><Element name = "SHORTTEXT" value = ""/><Element name =
.....i use the call transformation code and there i put this code:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="XML_TAB"/>
<tt:template>
<Containers>
<tt:loop name="a" ref=".XML_TAB">
<Container>
<tt:attribute name="Element name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Container>
</tt:loop>
</Containers>
</tt:template>
</tt:transform>I think that i miss something with the line :<Container workitemid = "0000007" IsParent = "X">
the dump is:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_MATCH_ATTRIBUTE', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
XML matching error
Expected was attribute: "Elementname" [ ] Read was element-start: "Container" [
].
Please help
Regards
Chris
Edited by: Chris Teb on Aug 6, 2009 9:57 AM
‎2009 Aug 06 9:14 AM
Your transformation is wrong:
<Element> tag is occured multiple times. But Your transformation says <Container> tag wil occur multiple times.
Try with this transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="XML_TAB"/>
<tt:template>
<Containers>
<Container>
<tt:loop name="a" ref=".XML_TAB">
<Element >
<tt:attribute name="name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Element>
</tt:loop>
</Container>
</Containers>
</tt:template>
</tt:transform>
‎2009 Aug 06 9:03 AM
‎2009 Aug 06 9:14 AM
Your transformation is wrong:
<Element> tag is occured multiple times. But Your transformation says <Container> tag wil occur multiple times.
Try with this transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="XML_TAB"/>
<tt:template>
<Containers>
<Container>
<tt:loop name="a" ref=".XML_TAB">
<Element >
<tt:attribute name="name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Element>
</tt:loop>
</Container>
</Containers>
</tt:template>
</tt:transform>
‎2009 Aug 06 11:27 AM
H Siva,
Thanks ,
I try exactly like u tell and i get this dump:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT', was not caught
and
therefore caused a runtime error.
The reason for the exception is:
XML matching error
Expected was element-end: "Containers" [ ] Read was element-start: "Container"
[ ].
<Containers>
<Container>
<tt:loop name="a" ref=".XML_TAB">
<Element >
<tt:attribute name="name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Element>
</tt:loop>
</Container>
</Containers> ->**the dump in the debugger is here .**
</tt:template>
</tt:transform>Any Idea?
Regards
Chris
‎2009 Aug 06 11:31 AM
Check XML input which is getting passed to transformation. This should end with
</Container>
</Containers>.
I think it is not like that.
‎2009 Aug 06 11:36 AM
HI Siva,
Thank you ,
since i upload the file from text file the string maybe is cutting somewhere ,
i check it and let u know.
Regards
Chris
‎2009 Aug 06 11:39 AM
Check if you have more than one <Container> tag in the XML input. If that is the case, then this transformation will not work as this transformation is considered only for one <Container> tag in <Containers> tag. Check this also
‎2009 Aug 06 9:50 AM
CHeck this link. There is a example for the same type of XML structure.
[http://help.sap.com/saphelp_nwpi71/helpdata/EN/3a/eefd3f0521c842e10000000a1550b0/content.htm]
‎2009 Aug 06 10:24 AM
Hello Chris,
Try Identical transformation. It is easy and not required transformation template.
CALL TRANSFORMATION ID
SOURCE ...
RESULT...
So source and result are not going to change any ways only you have to remove transformation template and replace it with ID.
Also make sure the input XML is following the XSLT format.
Thanks,
Augustin.