Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP to XML

Nawanandana
Active Contributor
1,465

Hi

I have to create XML file using ABAP (internal table to xml ). I crate structure and map with transformation tool using tcode XSLT_TOOL . I can download XML file without any issue. but I need to pass value for the root element. I was try to pass different way but its not working. I have to pass " linkey, Action and Type" .those are variable . <Vendor linkey=" " Action=" " type=" ">.

If any one can help me about this it will be grate.

<?xml version="1.0" encoding="UTF-16"?>
-<APVend Companycode="">
-<Vendor linkey=" " Action=" " type=" ">
<idfAPVendorKey>9230000011</idfAPVendorKey>
<idfComment/>
<idfCurrLineUpSeq/>
<idfDatePromisedOffset/>

Hi

I have to create XML file using ABAP (internal table to xml ). I crate structure and map with transformation tool using tcode XSLT_TOOL . I can download XML file without any issue. but I need to pass value for the root element. I was try to pass different way but its not working. I have to pass " linkey, Action and Type" .those are variable . <Vendor linkey=" " Action=" " type=" ">.

If any one can help me about this it will be grate.

<?xml version="1.0" encoding="UTF-16"?>
-<APVend Companycode="">
-<Vendor linkey=" " Action=" " type=" ">
<idfAPVendorKey>9230000011</idfAPVendorKey>
<idfComment/>
<idfCurrLineUpSeq/>
<idfDatePromisedOffset/>

2 REPLIES 2
Read only

DoanManhQuynh
Active Contributor
1,094

You can create template in transformation,when call transformation you pass the itab to that template something like this (You can read more about transformation by push F1 on TRANSFORM statement):

In ABAP:

CALL TRANSFORMATION ZXXX
   SOURCE source = itab 
   RESULT xml result.

In Transformation:

<?sap.transform simple?><tt:transform xmlns:tt="http://www.sap.com/transformation-templates">  
  <tt:root name="SOURCE"/>  
  <tt:template>  
    <tt:loop name="b" ref=".SOURCE"> 
     <Vendor>  
      <tt:attribute name="linkey" value-ref="$b.linkey"/> 
     </Vendor>  
    </tt:loop>  
  </tt:template>
Read only

Nawanandana
Active Contributor
0 Likes
1,094

Hi

I found the solution how to create root attribute, you have to create structure and using XSLT_TOOL you can change the Element to attribute .

XSLT_TOOL-change-element-type

Regards,

Nawa