ABAP顾问
分类:
2008-03-13 17:39:23
*&---------------------------------------------------------------------*
*& 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类型
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
chinaunix网友2009-03-24 17:30:01
ztest2是什么东东?为什么代码报错Die Transformation "ZTEST2" hat keine aktive Version.