*&---------------------------------------------------------------------*
* & Report z_barry_xml_call
*&
*&---------------------------------------------------------------------*
* & Call transformation method to generate xml routines
* & Applicable to ecc5 and later Systems
* & Common method to generate xml: http://blog.chinaunix.net/u1/40527/showart_468389.html
*&---------------------------------------------------------------------*
Report z_barry_xml_call.
Data: Begin of it_xml occurs 0,
Line (100) type C,
End of it_xml.
Data: w_xml type string,
W_len type I,
W_fname type string.
Data: Begin of line,
Matnr like Mara-matnr,
Maktx like Makt-maktx,
End of line.
Data: Begin of line2,
Class like m_wwgha-class, "Department
Kschl like m_wwgha-kschl, "DESC
End of line2.
Data: itab_matnr like table of line,
Itab_class like table of line2.
Start-of-selection.
Perform getdata.
Perform create_xml.
*---------------------------------------------------------------------*
* Form getdata *
*---------------------------------------------------------------------*
Form getdata.
Select matnr maktx from Makt
Into Table itab_matnr
Up to 4 rows
Where spras = '1 '.
Select class kschl from m_wwgha
Into Table itab_class
Up to 4 rows
Where spras in ('1', 'E ').
Endform. "getdata
*&---------------------------------------------------------------------*
* & Form create_xml
*&---------------------------------------------------------------------*
Form create_xml.
Call transformation ztest2
Source PRD = itab_matnr
Class = itab_class
Result XML w_xml.
Call function 'scms _ string_to_ftext'
Exporting
TEXT = w_xml
Importing
Length = w_len
Tables
Ftext_tab = it_xml.
Call function 'gui _ download'
Exporting
Filename = 'C: \ xmlcall. xml'
Filetype = 'bin'
Importing
Filelength = w_len
Tables
Data_tab = it_xml.
Endform. "create_xml
* Tcode: strans, simple type
* <? Sap. Transform simple?>
* <TT: Transform xmlns: TT = "http://www.sap.com/transformation-templates">
* <TT: Root name = "PRD"/>
* <TT: Root name = "class"/>
* <TT: Template>
* <Root>
* <Products>
* <TT: loop name = "line" ref = "PRD">
* <Product>
* <Matnr>
* <TT: Value ref = "$ line. matnr"/>
* </Matnr>
* <Maktx>
* <TT: Value ref = "$ line. maktx"/>
* </Maktx>
* </Product>
* </TT: loop>
* </Products>
* <Categories>
* <TT: loop name = "line2" ref = "class">
* <Categorie>
* <Class>
* <TT: Value ref = "$ line2.class"/>
* </Class>
* <Kschl>
* <TT: Value ref = "$ line2.kschl"/>
* </Kschl>
* </Categorie>
* </TT: loop>
* </Categories>
* </Root>
* </TT: Template>
* </TT: Transform>