Application Development 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: 

How to read XML file from server

flavio_mariola
Explorer
0 Kudos

Hi!!

I'have 4.6c version and I must to read an XML file from server, I wrote this sample code:

REPORT zflavio_xml2.

* & ------------------------------------------------ --------------------- *

* Date & Declaration

* & ------------------------------------------------ --------------------- *

DATE: LIKE rlgrap-filename file.

file = '/usr/usrsap/CRD/transfer/SEPASCT_SSBPAE/IN/R4_ESEMPIO.xml'.

DATE: gcl_xml TYPE REF TO cl_xml_document.

DATE: gv_subrc TYPE sy-subrc.

DATA: TYPE gv_xml_string xstring.

DATA: TYPE gv_size sytabix.

DATE: gt_xml_data TYPE TABLE OF smum_xmltb.

DATA: TYPE gwa_xml_data smum_xmltb OCCURS 0 WITH HEADER LINE.

* DATA: TYPE gwa_xml_data smum_xmltb.

DATE: gt_return TYPE TABLE OF bapiret2.

DATA: TYPE gv_tabix sytabix.

DATE: len TYPE i.

* & ------------------------------------------------ --------------------- *

* & Start-of-selection

* & ------------------------------------------------ --------------------- *

START-OF-SELECTION.

   OPEN DATASET file FOR INPUT IN BINARY MODE.

   IF sy-subrc = 0.

     DO.

       READ DATASET INTO gv_xml_string file. "ACTUAL LENGTH len.

* IF sy-subrc NE 0.

         EXIT.

* ENDIF.

     ENDDO.

   ENDIF.

   CLOSE DATASET file.

   CALL FUNCTION 'SMUM_XML_PARSE'

     EXPORTING

       xml_input = gv_xml_string

     TABLES

       xml_table = gwa_xml_data

       return = gt_return.

   WRITE: / 'heirarchy', 11 'Type', 17 'Name', 37 'Value'.

   LOOP AT gwa_xml_data.

     WRITE: / gwa_xml_data-hier,

            11 gwa_xml_data-type,

            17 gwa_xml_data-cname,

            37 gwa_xml_data-cValue.

     CLEAR gwa_xml_data.

   ENDLOOP.

the problem is that in the internal table, the program writes correctly the first twenty records, but it cuts all the others.

Does anyone know help me?

Thanks a lot,

Flavio Mariola

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Flavio,

I tried you sample code, and works fine in 7.3.

How do you mean cuts all the records? Do you mean truncating the lines or only shows the first 20 records?

Regards,

Alex

2 REPLIES 2

Former Member
0 Kudos

Hi Flavio,

I tried you sample code, and works fine in 7.3.

How do you mean cuts all the records? Do you mean truncating the lines or only shows the first 20 records?

Regards,

Alex

0 Kudos

yes, I'm sorry. the example works. I did not notice that the file was put on the server was truncated and different from what I expected.

Thank you,

Flavio