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.
ABAP code
- TYPES:
- BEGINOF ty_input,
- col1 TYPE d ,
- col2 TYPE t ,
- ENDOF ty_input.
- ***
- DATA: input TYPE ty_input,
- ls_input2 TYPE ty_input,
- input2 TYPETABLEOF ty_input,
- input3 TYPE string VALUE'asdf',
- xml_string TYPE string,
- result LIKEinput,
- result2 LIKE input2,
- result3 LIKE input3.
- ***
- input-col1 = 'ABCDEFGHIJ'.
- input-col2 = 111.
- ***
- ls_input2-col1 = '20040126'.
- ls_input2-col2 = '084000'.
- APPEND ls_input2 TO input2.
- ls_input2-col1 = '20050126'.
- ls_input2-col2 = '085000'.
- APPEND ls_input2 TO input2.
- ls_input2-col1 = '20060126'.
- ls_input2-col2 = '086000'.
- APPEND ls_input2 TO input2.
- TRY.
- CALL TRANSFORMATION zm1
- SOURCE root = input
- root2 = input2
- root3 = input3
- RESULT XML xml_string.
- ***
- CALL TRANSFORMATION zm1
- SOURCE XML xml_string
- RESULT root = result
- root2 = result2
- root3 = result3.
- WRITE'pass'.
- CATCH cx_st_error.
- WRITE'fail'.
- ENDTRY.
Simple transformation code
<?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>
/.