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 data file upload

Former Member
0 Likes
1,626

How can I upload XML data file to SAP? I cannot use class method import_from_file of class cl_xml_document

because I want to run the program in background and with this Method it only run in foreground

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,500

Just read the file (READ DATASET, see forums), put content into a string variable named your_string and do:

DATA lo_xml TYPE REF TO cl_xml_document_base.
CREATE OBJECT lo_xml.
lo_xml->parse_string( stream = your_string ).

11 REPLIES 11
Read only

Former Member
0 Likes
1,500

Hello,

Use the below FM's:

/SMB/SC_UL_XML_DOC

/XFT/DIO_DEMO_CP_XML_2_STR

/AIN/IF_XML_TO_C255

Hope this helps.

Thanks,

GReetson

Read only

0 Likes
1,500

Where can I look at these FM's?

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,501

Just read the file (READ DATASET, see forums), put content into a string variable named your_string and do:

DATA lo_xml TYPE REF TO cl_xml_document_base.
CREATE OBJECT lo_xml.
lo_xml->parse_string( stream = your_string ).

Read only

0 Likes
1,500

How can I use READ DATASET with the upload?

Read only

0 Likes
1,500

it's an elementary abap statement, read the doc, or read forum if you don't understand

Read only

0 Likes
1,500

The problem is not that I want to read the xml data file into a string, the problem is that I can't use any upload method to upload the data file in background, this is want I want to solve, when I run the program in the foreground everything works with my method but not in the background, for this I get a dump.

Read only

0 Likes
1,500

You want to upload a file from your desktop in background ?

IT'S NOT POSSIBLE !

See forum on this, it's very well known and discussed.

oops bad oss user used, sorry!

I am sandra rossi

Edited by: Sandra Rossi on Jan 14, 2009 1:57 PM

Read only

0 Likes
1,500

Yes I know this, but is there no method or something else where I can upload something from the server in background?

Read only

0 Likes
1,500

Could you show the dump?

Could you show your method?

Otherwise use READ DATASET to read the file, why don't you want?

Read only

0 Likes
1,500

currently I use following methods tu opload and to transfor the xml into a string.


* Method to create XML from data file

  CALL METHOD instance->import_from_file
    EXPORTING
      filename = gf_filename
    RECEIVING
      retcode  = ch_retcode.

* Convert into XML-Stream

  CALL METHOD instance->render_2_string
*  EXPORTING
*    pretty_print = 'X'
    IMPORTING
    retcode      = ch_retcode
      stream       = lf_string .
*    size         = .

When I use read dataset the output of the xml is into an internal table where I have many lines depending on the XML data file, this means if my xml has 10lines the internal table of read dataset has also 10 lines but I need a string to make the transformation of the xml.

Read only

0 Likes
1,500

Do it this way so that "all_lines" is a string that contains the whole file (if you had SEARCHED THE FORUM you would have found it yourself):

DATA line TYPE string.
DATA all_lines TYPE string.
OPEN DATASET ... IN TEXT MODE ...
DO
  READ DATASET ... INTO line.
  IF sy-subrc <> 0. EXIT. ENDIF.
  CONCATENATE all_lines line INTO all_lines.
ENDDO.

and then use :

DATA lo_xml TYPE REF TO cl_xml_document_base.
CREATE OBJECT lo_xml.
lo_xml->parse_string( stream = all_lines ).

Edited by: Sandra Rossi on Jan 14, 2009 2:54 PM