‎2009 Jan 13 3:30 PM
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
‎2009 Jan 13 7:35 PM
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 ).
‎2009 Jan 13 5:00 PM
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
‎2009 Jan 13 5:09 PM
‎2009 Jan 13 7:35 PM
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 ).
‎2009 Jan 14 8:41 AM
‎2009 Jan 14 9:18 AM
it's an elementary abap statement, read the doc, or read forum if you don't understand
‎2009 Jan 14 9:20 AM
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.
‎2009 Jan 14 12:57 PM
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
‎2009 Jan 14 12:58 PM
Yes I know this, but is there no method or something else where I can upload something from the server in background?
‎2009 Jan 14 1:04 PM
Could you show the dump?
Could you show your method?
Otherwise use READ DATASET to read the file, why don't you want?
‎2009 Jan 14 1:11 PM
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.
‎2009 Jan 14 1:53 PM
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