Call transformation method to generate an XML file

Source: Internet
Author: User

*&---------------------------------------------------------------------*
* & 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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.