SAP提供了一个XML相关类cl_xml_document_base,通过这个类可以将abap程序中内表中的数据转化成XML格式的数据,然在再下载到本地。
方法create_with_data:转换内表数据到XML格式
方法export_to_file:下载xml文件
代码
REPORT ztest_xml.
DATA:git_ekko TYPE STANDARD TABLE OF ekko.
DATA: go_xml TYPE REF TO cl_xml_document_base,
l_rc TYPE sy-subrc.
DATA: go_xml TYPE REF TO cl_xml_document_base,
l_rc TYPE sy-subrc.
SELECT *
INTO TABLE git_ekko
FROM ekko
UP TO 20 ROWS.
CREATE OBJECT go_xml.
INTO TABLE git_ekko
FROM ekko
UP TO 20 ROWS.
CREATE OBJECT go_xml.
CALL METHOD go_xml->create_with_data
EXPORTING
name = ‘DATA’
dataobject = git_ekko[]
RECEIVING
retcode = l_rc.
EXPORTING
name = ‘DATA’
dataobject = git_ekko[]
RECEIVING
retcode = l_rc.
CALL METHOD go_xml->export_to_file
EXPORTING
filename = ‘c:/temp/test.xml’
RECEIVING
retcode = l_rc.
EXPORTING
filename = ‘c:/temp/test.xml’
RECEIVING
retcode = l_rc.
下载的XML格式的文件:
以上。
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/19228.html