码迷,mamicode.com
首页 > 其他好文 > 详细

CALL TRANSFORMATION 的方法生成XML文件

时间:2014-07-05 18:41:39      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   文件   

*&---------------------------------------------------------------------*
*& Report  Z_BARRY_XML_CALL
*&
*&---------------------------------------------------------------------*
*& CALL TRANSFORMATION的方法生成XML例程
*& 适用ECC5以上系统
*& 普通方法生成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,"部门
        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类型

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

CALL TRANSFORMATION 的方法生成XML文件,布布扣,bubuko.com

CALL TRANSFORMATION 的方法生成XML文件

标签:des   style   blog   http   color   文件   

原文地址:http://www.cnblogs.com/rainysblog/p/3822779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!