2010 May 12 10:52 AM
i have this requirement to fetch data from internal table and dowload this to an xml file.
the xml file has this XML format.
Output Sample (in XML format):
<?xml version="1.0"?>
<ORDERS01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>1</DIRECT>
<IDOCTYP>ORDERS01</IDOCTYP>
<MESTYP>ORDERS</MESTYP>
<SNDPOR>SAPEX3</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>0011297603</SNDPRN>
<RCVPOR>SAPP82</RCVPOR>
<RCVPRT>LI</RCVPRT>
<RCVPFC>LF</RCVPFC>
<RCVPRN></RCVPRN>
<CREDAT>2003-09-15</CREDAT>
<CRETIM>12:39:13</CRETIM>
</EDI_DC40>
<E1EDK01>
this format is in IDOC format, is there any function modules of way to download it to this file?
please help. thanks.
i have this requirement to fetch data from internal table and dowload this to an xml file.
the xml file has this XML format.
Output Sample (in XML format):
<?xml version="1.0"?>
<ORDERS01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>1</DIRECT>
<IDOCTYP>ORDERS01</IDOCTYP>
<MESTYP>ORDERS</MESTYP>
<SNDPOR>SAPEX3</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>0011297603</SNDPRN>
<RCVPOR>SAPP82</RCVPOR>
<RCVPRT>LI</RCVPRT>
<RCVPFC>LF</RCVPFC>
<RCVPRN></RCVPRN>
<CREDAT>2003-09-15</CREDAT>
<CRETIM>12:39:13</CRETIM>
</EDI_DC40>
<E1EDK01>
this format is in IDOC format, is there any function modules of way to download it to this file?
please help. thanks.
2010 May 12 10:57 AM
Hi,
Just check if this link might help you.
Link[XML|http://sapprograms.blogspot.com/2008/11/download-to-xml.html]
Regards and Best wishes.
2010 May 12 11:05 AM
thanks.
but i need the xml to have the tags from idocs the <SEGMET> etc.
is there another way?
2010 May 12 2:48 PM
Hi blue22,
you can solve this by using class cl_xml_document.
1. Get your data in an internal table
2. Create XML Object type cl_xml_document
3. Convert data in table to XML by using method "create_with_data" of cl_xml_document
4. Save XML to local PC by using method "export_to_file" of cl_xml_document
regards
rea
2010 May 12 5:30 PM
1. You use the FM: IDX_IDOC_TO_XML to get the idoc data in XML_DATA export param.
2. Now you can use this snippet to download data as an XML file:
DATA:
v_stream TYPE string,
lcl_xml_doc TYPE REF TO cl_xml_document,
v_subrc TYPE sysubrc,
v_filename TYPE localfile.
CREATE OBJECT lcl_xml_doc.
IF sy-subrc = 0.
" V_STREAM contains the idoc data in XML format which you got
" from the func. module IDX_IDOC_TO_XML
v_subrc = lcl_xml_doc->parse_string( stream = v_stream ).
CHECK v_subrc = 0.
v_filename = `C:\Users\Suhas Saha\Desktop\xml_data.xml`.
v_subrc = lcl_xml_doc->export_to_file( filename = v_filename ).
IF v_subrc = 0.
WRITE / `File downloaded successfully. Yippee!!!`.
ELSE.
WRITE / `Why does not this work ? Sob !!!`.
ENDIF.
ENDIF.Hope this helps.
BR,
Suhas
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |