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 Processing in ABAP

Former Member
0 Likes
647

Hi,

I need to load XML file into ABAP and then process data. Can I use call transformation for that?? My SAP version is 4.7 E(Basis 620). Is there any difference for SAP version 4.6C????

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
580

Hi,

This should be possible to do via the ABAP iXML framework:

There is good documentation and example code at:

http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/content.htm.

Another simple option would be to copy the code from blog:

/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach

And replace the file-upload code with a call to istream = streamfactory->create_istream_uri( URL_TO_SITE ).

which would let you read the XML data directly from a specified URI.

The iXML library is meanwhile available in all 4.6C basis and application development systems.

Rgds,

Prakash

Message was edited by: Prakashsingh Mehra

4 REPLIES 4
Read only

Former Member
0 Likes
581

Hi,

This should be possible to do via the ABAP iXML framework:

There is good documentation and example code at:

http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/content.htm.

Another simple option would be to copy the code from blog:

/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach

And replace the file-upload code with a call to istream = streamfactory->create_istream_uri( URL_TO_SITE ).

which would let you read the XML data directly from a specified URI.

The iXML library is meanwhile available in all 4.6C basis and application development systems.

Rgds,

Prakash

Message was edited by: Prakashsingh Mehra

Read only

0 Likes
580

How to do the same in SAP 4.6C or 4.6B versions?? The iXML framework may not be available in old versions.

Thanks.

Read only

Former Member
0 Likes
580

Hi sri,

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,

amit m.

Read only

Former Member
0 Likes
580

Hai Sri

Check the following

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.

*----


Convert to TABLE

CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'

EXPORTING

i_string = xml_out

i_tabline_length = 100

TABLES

et_table = 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[].

Regards

Sreeni