2014 Aug 29 11:41 PM
Dear all,
We are uploading a PDF file and converting to XML (into string variable).
This XML has three elements:
- Structure (OK)
- Internal Table (OK)
- Variable (Not OK)
When calling transformation to pass these data from XLM into respective elements, we have the structure and internal table filling very well, but i REALLY don't know why the variable I caught the exception CX_ST_MATCH_ELEMENT.
I tried to find something, but nothing useful.
Below my code:
CALL TRANSFORMATION ztransf
SOURCE XML lv_xml_data_string
RESULT root = s1
root1 = t1
root2 = v1.
lv_xml_data_string contains (I pasted only the final):
<NETWR_WAERS/></DATA></LISTA_ITENS></DADOS_COTACAO><V1>ggggggggggggg</V1>
The <V1>ggggggggggggg</V1> is important here, I just need to pass "ggggggggggggg" to a simple variable.
Now, my transformation code:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT" type="?"/>
<tt:root name="ROOT1" type="?"/>
<tt:root name="ROOT2" type="?"/>
<tt:template>
<DADOS_COTACAO tt:ref="ROOT">
<BUKRS>
<tt:value ref="BUKRS"/>
</BUKRS>
<LIFNR>
<tt:value ref="LIFNR"/>
</LIFNR>
<NAME1>
<tt:value ref="NAME1"/>
</NAME1>
<STRAS>
<tt:value ref="STRAS"/>
</STRAS>
<LISTA_ITENS>
<tt:loop name="data" ref=".ROOT1">
<DATA xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<EBELP>
<tt:value ref="$data.ebelp"/>
</EBELP>
<EBELN>
<tt:value ref="$data.ebeln"/>
</EBELN>
<MATNR>
<tt:value ref="$data.matnr"/>
</MATNR>
<MAKTX>
<tt:value ref="$data.maktx"/>
</MAKTX>
<LABST>
<tt:value ref="$data.labst"/>
</LABST>
<LABST_MEINS>
<tt:value ref="$data.labst_meins"/>
</LABST_MEINS>
<NETWR>
<tt:value ref="$data.netwr"/>
</NETWR>
<NETWR_WAERS>
<tt:value ref="$data.netwr_waers"/>
</NETWR_WAERS>
</DATA>
</tt:loop>
</LISTA_ITENS>
</DADOS_COTACAO>
<V1> """""Here is the part that isn't working
<tt:value ref="ROOT2"/>
</V1>
</tt:template>
</tt:transform>
Please, i really appreciate any help!
Best Regrads
Thanks In advanced
Vinicius Ostan
2014 Aug 31 6:52 PM
Have a look at below snippets. I have modified standard example so that it looks similar to your case, root structure, root internal table and root variable. Run it in debug to see that ABAP to XML and XML to ABAP transformations are happening successfully.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp" version="0.1">
<tt:root name="ROOT"/>
<tt:root name="ROOT2"/>
<tt:root name="ROOT3"/>
<tt:template name="temp">
<X>
<X1>
<tt:value ref="ROOT.COL1"/>
</X1>
<X2>
<tt:value ref="ROOT.COL2"/>
</X2>
<X3>
<tt:loop name="line" ref="ROOT2">
<ITEM>
<X1>
<tt:value ref="$line.COL1"/>
</X1>
<X2>
<tt:value ref="$line.COL2"/>
</X2>
</ITEM>
</tt:loop>
</X3>
<X4>
<tt:value ref="ROOT3"/>
</X4>
</X>
</tt:template>
</tt:transform>
/.
2014 Aug 30 5:19 AM
2014 Aug 31 6:52 PM
Have a look at below snippets. I have modified standard example so that it looks similar to your case, root structure, root internal table and root variable. Run it in debug to see that ABAP to XML and XML to ABAP transformations are happening successfully.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp" version="0.1">
<tt:root name="ROOT"/>
<tt:root name="ROOT2"/>
<tt:root name="ROOT3"/>
<tt:template name="temp">
<X>
<X1>
<tt:value ref="ROOT.COL1"/>
</X1>
<X2>
<tt:value ref="ROOT.COL2"/>
</X2>
<X3>
<tt:loop name="line" ref="ROOT2">
<ITEM>
<X1>
<tt:value ref="$line.COL1"/>
</X1>
<X2>
<tt:value ref="$line.COL2"/>
</X2>
</ITEM>
</tt:loop>
</X3>
<X4>
<tt:value ref="ROOT3"/>
</X4>
</X>
</tt:template>
</tt:transform>
/.
2014 Sep 01 2:52 PM
Thanks Kumar.
This good example is working well.
I analyze this example against my code, and it supposedly should run fine. But I dont know why I'm getting error.
I get XLM when uploading PDF file, so I can't manipulate its code.
Please, could you see if there is any synthetically difference in XML, because I dont see.
Bellow my complete XML (when uploading PDF).
<DADOS_COTACAO> " "Structure with 2 fields - OK
<BUKRS>1000</BUKRS>
<LIFNR>0098000000</LIFNR>
<LISTA_ITENS> "Table with 3 fields and 1 row - OK
<DATA xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<EBELP>00010</EBELP>
<EBELN>0100000000</EBELN>
<MATNR>R10001</MATNR>
</DADOS_COTACAO> "end structure TAG
<V1>teste</V1> "Variable that's getting error
Thank you so much.
2014 Sep 01 3:46 PM
I don't see the DATA tag getting closed here. With one line content it is not clear whether DATA tag is repeating or something else. Try posting complete xml, xslt and abap code as attachment (use advanced editor to see attachment option). I can then have a look.
2014 Sep 01 5:25 PM
2014 Sep 01 6:44 PM
I found the error, as you said, was missing the DATA tag in XML.
I've inserted it in transformation code e now it's OK.
Kumar, I really appreciate your help.
Thanks a lot.
Best Regards..
2014 Sep 01 6:58 PM
It looks like proper xml can have only one root element. Your xml has DADOS_COTACAO as well as V1 at top level of hierarchy.
I enclosed the xml content in another tag that became new root.
New xml became something this.
<XMLROOT>
<DADOS_COTACAO>....</DADOS_COTACAO>
<V1>...</V1>
</XMLROOT>
You can do something similar by concatenating <XMLROOT>, xml_string, </XMLROOT> into single string.
After having single root, following simple transformation worked.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:root name="ROOT1"/>
<tt:root name="ROOT2"/>
<tt:template>
<XMLROOT>
<DADOS_COTACAO>
<BUKRS>
<tt:value ref="ROOT.BUKRS"/>
</BUKRS>
<LIFNR>
<tt:value ref="ROOT.LIFNR"/>
</LIFNR>
<LISTA_ITENS>
<tt:loop name="data" ref="ROOT1">
<DATA xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<EBELP>
<tt:value ref="$data.EBELP"/>
</EBELP>
<EBELN>
<tt:value ref="$data.EBELN"/>
</EBELN>
<MATNR>
<tt:value ref="$data.MATNR"/>
</MATNR>
</DATA>
</tt:loop>
</LISTA_ITENS>
</DADOS_COTACAO>
<V1>
<tt:value ref="ROOT2"/>
</V1>
</XMLROOT>
</tt:template>
</tt:transform>
/.
2014 Sep 01 7:42 PM
You are completely right.
I was clearing the first TAG DATA. For this I was getting error.
Thank you so much.