Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

XML files from ABAP programs

Former Member
0 Likes
3,278

Hi everyone!

Is there a way in ABAP to output XML files? Pls. send code/ function module if any.

From ABAP programs, we are sure that we can output TEXT files, but how about XML files?

The significance of this question is related

Currently we are using XI to interface SAP and AMS, this question for ABAP to produce XML file arose, if for example, the XI server is down and we have to still send data from one system to another. IDocs can also produce XML files, pls confirm. Earlier however, we have preferred XI rather than IDocs to do this. Anyway, any idea regarding this scenario will be greatly appreciated.

Thanks and God bless!

Celeste

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
985

Use this FM. SAP_CONVERT_TO_XML_FORMAT

Check this link too -

Regards,

Amit

3 REPLIES 3
Read only

amit_khare
Active Contributor
0 Likes
986

Use this FM. SAP_CONVERT_TO_XML_FORMAT

Check this link too -

Regards,

Amit

Read only

0 Likes
985

Thanks for your quick reply Amit.

1. I read from the link that they had issues w/ 4.6, 4.7 etc... Will this work in another component version? My current client is using <b>SAP ECC 6.0</b>.

2. I also checked out the FM you sent. Good thing it exists in ECC 6.0. Add'l questions: what should I put in the PARAMETERS of the FM SAP_CONVERT_TO_XML_FORMAT?

3. Also when I try to execute it, window pops up with this message:

"Error generating the test frame"

Checking the documentation for further information:

Message no. FL819

Diagnosis

The system could not generate a syntactically correct test frame for function module SAP_CONVERT_TO_XML_FORMAT. You therefore cannot test the function module using the test environment. You have probably used an ABAP feature in the interface definition that is not yet supported in the test environment.

The error message is:

"OF" expected after "TABLE".

System Response

Procedure

Check whether you can change the interface of the function module so that it is possible to generate the test frame. If this is not possible,you will have to write your own utility for testing the function module.

Procedure for System Administration

Thanks,

Celeste

Read only

Former Member
0 Likes
985

Hi,

Please check this sample codes from other thread.

1. itab --- > xml

xml ---> itab.

2. This program will do both.

(just copy paste in new program)

3.


REPORT abc.


*-------------- DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.

DATA: xml_out TYPE string .

DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .



******************************* FIRST PHASE
******************************* FIRST PHASE
******************************* FIRST PHASE

*------------------ Fetch Data

SELECT * FROM t001 INTO TABLE t001.

*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.



CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
* IMPORTING
* LENGTH =
TABLES
FTEXT_TAB = itab.
.


*-------------- Download

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:xx.xml'
TABLES
data_tab = itab.



******************************* SECOND PHASE
******************************* SECOND PHASE
******************************* SECOND PHASE


BREAK-POINT.
REFRESH t001.
CLEAR t001.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.

LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.

*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
.
BREAK-POINT.

Regards,

Ferry Lianto