Reading XMl file from ABAP
Hi friends,
I am working in SAP 4.6c. Please help me in the following scenario.
I have to read the xml whixjh in the application server.
I have to Make sure each XML only contains 1 IDOC. If 10 idocs are pushed out , there should be 10 XML messages. 1 idoc per XML.
So if the FM receives a message that contains 10 idocs, the routine just needs to split the XML into 10 separate XML's using YYYYMMDDHHMMSS_IDOCNUMBER.XML as the new of each XML.
Convert the XML into UTF-8 compliant
above is my requirement.
Can you guide me how to read a XMl file and findout how many idocs are present in that...
Please guide me...
Thanks in advance,
Sudha
Hi Sudha,
Refer this blog and thread to get more information on how to process XML documents.
/people/thomas.jung3/blog/2004/06/24/bsp-150-a-developer146s-journal-part-v-xml-for-rfcs
redaing an XML file to an internal table
Regards,
Uma
Message was edited by: Uma Maheswari
Similar Messages
-
Create XML file from ABAP with SOAP Details
Hi,
I am new to XML and I am not familiar with JAVA or Web Service. I have searched in SDN and googled for a sample program for creating XML document from ABAP with SOAP details. Unfortunately I couldn't find anything.
I have a requirement for creating an XML file from ABAP with SOAP details. I have the data in the internal table. There is a Schema which the client provided and the file generated from SAP should be validating against that Schema. Schema contains SOAP details like Envelope, Header & Body.
My question is can I generate the XML file using CALL TRANSFORMATION in SAP with the SOAP details?
I have tried to create Transformation (Transaction XSLT_TOOL) in SAP with below code. Also in CALL transformation I am not able to change the encoding to UTF-8. It's always show UTF-16.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:template match="/">
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header>
<CUNS:HeaderInfo>
<CUNS:InterfaceTypeId>10006</InterfaceTypeId>
<CUNS:BusinessPartnerID>11223344</BusinessPartnerID>
<CUNS:SchemaVersion>1.0</SchemaVersion>
<CUNS:DateTime>sy-datum</DateTime>
</CUNS:HeaderInfo>
</SOAP:Header>
<SOAP:Body>
<xsl:copy-of select="*"/>
</SOAP:Body>
</SOAP:Envelope>
</xsl:template>
</xsl:transform>
In ABAP program, I have written below code for calling above Transformation.
call transformation ('Z_ID')
source tab = im_t_output[]
result xml xml_out.
call function 'SCMS_STRING_TO_FTEXT'
exporting
text = xml_out
tables
ftext_tab = ex_t_xml_data.
Please help me how to generate XML file with SOAP details from ABAP. If anybody have a sample program, please share with me.
Is there any easy way to create the XML file in CALL Transformation. Please help.
ThanksTry ABAP forum, as it seems not to be PI related.
-
FM to read XML files from Application server in ECC5.0
Hi All,
We need to pick up an XML file from Application server/FTP server. The requirement is to parse the XML file and process it to create material master. SAP provides standard function modules to read XML files.
Now we need to read the XML file contents of MM01 and upload into SAP Data Base through BAPI
I need to know about the Function modules to read XML files from Application Server and also about the FM's that will update the Date base tables with the data obtained form XML files.
Regards
PrathimaParsing XML data:
http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
or alternatively check out ABAP online help for "CALL TRANSFORMATION".
For creating the material master look at BAPI_STANDARDMATERIAL_CREATE.
Thomas -
I am reading XML file from unix using :
FORM read_file USING p_name.
DO.
READ DATASET p_name INTO WXML_LINE LENGTH LENG.
ENDDO.
Then I am using subroutine below where I get a short dump at
case X_NODE->get_type( ).
FORM get_data tables Y_CAPXML structure GV_CAPXML
using value(x_node) type ref to if_ixml_node.
data: INDENT type i.
data: PTEXT type ref to if_ixml_text.
data: STRING type string.
data: TEMP_STRING(100).
case X_NODE->get_type( ).
when if_ixml_node=>co_node_element.
STRING = X_NODE->get_name( ).
GV_NODETEXT = STRING.
when if_ixml_node=>co_node_text.
PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
if PTEXT->ws_only( ) is initial.
STRING = X_NODE->get_value( ).
case GV_NODETEXT.
when 'NIIN'.
move STRING to GV_CAPXML-NIIN.
when 'FED_x0020_STOCK_x0020_CLASS'.
move STRING to GV_CAPXML-fed_stock_class.
when 'DODIC'.
move STRING to GV_CAPXML-dodic.
endcase.
The text for the short dump is : STACK_STATE_NO_ROLL_MEMORY
Can someone please explain what is it mean.
Thanks.May be this blog can help:
<a href="/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 for Blog</a>
Sri -
Creating an xml file from abap code
Hello All,
Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
Thanks in advance,
Paul.This has been discussed before
XML files from ABAP programs -
Reading XML file from application server and put into internal table-4.6C
Dear All,
Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
Thanks and regards,
AtanuHi Atanu!
Simply use the XSLT transformation 'ID'.
FIELD-SYMBOLS <ls_result> TYPE ANY.
CREATE DATA lref_data TYPE (your_structure).
ASSIGN lref_data->* TO <ls_result>.
CALL TRANSFORMATION id
SOURCE XML xmlstr
RESULT result = <ls_result>.
"xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
Best regards
Torsten -
Read XML file from presentation server
Hi All,
I want read XML file from presentation server currently i am using GUI_UPLOAD fm . but it is reading some junk data.
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
is there any other alternative.
Thanks
Swarup,Hi Swarup,
Use method IMPORT_FROM_FILE of class CL_XML_DOCUMENT.
A sample code snippet :-
PARAMETERS: p_filnam TYPE localfile OBLIGATORY
DEFAULT 'C:\Documents and Settings\ssaha\Desktop\test.xml'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filnam.
DATA: l_v_fieldname TYPE dynfnam.
l_v_fieldname = p_filnam.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = l_v_fieldname
IMPORTING
file_name = p_filnam.
START-OF-SELECTION.
TYPES:
BEGIN OF ty_tab,
name TYPE string,
value TYPE string,
END OF ty_tab.
DATA:
lcl_xml_doc TYPE REF TO cl_xml_document,
v_subrc TYPE sysubrc,
v_node TYPE REF TO if_ixml_node,
v_child_node TYPE REF TO if_ixml_node,
v_root TYPE REF TO if_ixml_node,
v_iterator TYPE REF TO if_ixml_node_iterator,
v_nodemap TYPE REF TO if_ixml_named_node_map,
v_count TYPE i,
v_index TYPE i,
v_attr TYPE REF TO if_ixml_node,
v_name TYPE string,
v_prefix TYPE string,
v_value TYPE string,
v_char TYPE char2.
DATA:
itab TYPE STANDARD TABLE OF ty_tab,
wa TYPE ty_tab.
CREATE OBJECT lcl_xml_doc.
CALL METHOD lcl_xml_doc->import_from_file
EXPORTING
filename = p_filnam
RECEIVING
retcode = v_subrc.
CHECK v_subrc = 0.
v_node = lcl_xml_doc->m_document.
CHECK NOT v_node IS INITIAL.
v_iterator = v_node->create_iterator( ).
v_node = v_iterator->get_next( ).
WHILE NOT v_node IS INITIAL.
CASE v_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
v_name = v_node->get_name( ).
v_nodemap = v_node->get_attributes( ).
IF NOT v_nodemap IS INITIAL
* attributes
v_count = v_nodemap->get_length( ).
DO v_count TIMES.
v_index = sy-index - 1.
v_attr = v_nodemap->get_item( v_index ).
v_name = v_attr->get_name( ).
v_prefix = v_attr->get_namespace_prefix( ).
v_value = v_attr->get_value( ).
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
* text node
v_value = v_node->get_value( ).
MOVE v_value TO v_char.
IF v_char <> cl_abap_char_utilities=>cr_lf.
wa-name = v_name.
wa-value = v_value.
APPEND wa TO itab.
CLEAR wa.
ENDIF.
ENDCASE.
* advance to next node
v_node = v_iterator->get_next( ).
ENDWHILE.
LOOP AT itab INTO wa.
ENDLOOP.
Regards
Abhii -
Problem while reading XML file from Aplication server(Al11)
Hi Experts
I am facing a problem while reading XML file from Aplication server using open data set.
OPEN DATASET v_dsn IN BINARY MODE FOR INPUT.
IF sy-subrc <> 0.
EXIT.
ENDIF.
READ DATASET v_dsn INTO v_rec.
WHILE sy-subrc <> 0.
ENDWHILE.
CLOSE DATASET v_dsn.
The XML file contains the details from an IDOC number , the expected output is XML file giving all the segments details in a single page and send the user in lotus note as an attachment, But in the present output after opening the attachment i am getting a single XML file which contains most of the segments ,but in the bottom part it is giving the below error .
- <E1EDT13 SEGMENT="1">
<QUALF>001</QUALF>
<NTANF>20110803</NTANF>
<NTANZ>080000</NTANZ>
<NTEND>20110803<The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/SHPORD_0080005842.xml'.
/SPAN></NTEND>
<NTENZ>000000</NTENZ>
for all the xml its giving the error in bottom part , but once we open the source code and if we saved in system without changing anything the file giving the xml file without any error in that .
could any one can help to solve this issue .Hi Oliver
Thanx for your reply.
see the latest output
- <E1EDT13 SEGMENT="1">
<QUALF>003</QUALF>
<NTANF>20110803</NTANF>
<NTANZ>080000</NTANZ>
<NTEND>20110803</NTEND>
<NTENZ>000000</NTENZ>
<ISDD>00000000</ISDD>
<ISDZ>000000</ISDZ>
<IEDD>00000000</IEDD>
<IEDZ>000000</IEDZ>
</E1EDT13>
- <E1EDT13 SEGMENT="1">
<QUALF>001</QUALF>
<NTANF>20110803</NTANF>
<NTANZ>080000</NTANZ>
<NTEND>20110803<The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/~1922011.xml'.
/SPAN></NTEND>
<NTENZ>000000</NTENZ>
E1EDT13 with QUALF>003 and <E1EDT13 SEGMENT="1">
with <QUALF>001 having almost same segment data . but E1EDT13 with QUALF>003 is populating all segment data
properly ,but E1EDT13 with QUALF>001 is giving in between. -
How to read .xml file from embedded .swf(flash output) in captivate
I have been trying to read .xml file from the .swf (Flash output) that is embedded within the captivate file but no luck yet . Please if anyone got any clue on how get this thing done using Action script 3.0 then let me know. I am using Adobe Captivate 5.5 at present and Flash CS 5.5.
I am well aware about how to read .xml file through action script 3.0 in flash but when insert the same flash in captivate and publish nothing comes in captivate output. I would higly appreciate if anyone could help me out with that.
Here is is graphical demonstration of my query :
Message was edited by: captainmkvHi Captainmkv,
Does the information in this post cover what you're trying to do: http://forums.adobe.com/message/5081928#5081928
Tristan, -
i want to make a schedular probably in Coldfusion or using javascript , which read xml files from a folder ,import in Indesign template then export as a pdf....
I don't think you understand: I want to open Dreamweaver and build a brand new site, then when I am done I want to host the dreamweaver site on the Business Catalyst platform. I dont want to use anything in BC to build the site, I just want to use the hosting platform. I do not want to import a BC site into dreamweaver or anything like that. I just want to use BC the same way I would use godaddy, or uhost or any other hosting provider. Based on your response you said that "of course its possible to build a BC site in Dreamweaver" I dont want to build a BC site, I want to build a Dreamweaver site and host it on the BC platform. Like I said before it doesnt seem like this is possible. As of now we can only build a new site in MUSE and integrate it into BC without using a BC template. Can you understand what I am saying. I DONT WANT TO USE A BC TEMPLATE, I WANT NOTHING TO DO WITH BC WHILE I AM BUILDING THE SITE WITH DREAMWEAVER, JUST LIKE MUSE DOES.
-
Function module to read xml files from application server
Hi experts,
I need to read xml files from application server to sap. Is the any siutable function moldule for that?Hi Cenosure,
Donno about FM which will upload data directly to SAP, I think you have to do some mapping for it so that it will suit the SAP format. Again it depends on your requirement..
Please elaborate more about your requirement.
Please have a look on below FM
TEXT_CONVERT_XML_TO_SAP
Also search on SCN there are many threads on the same topic available.
http://abapreports.blogspot.com/2008/09/upload-xml-file-from-application-server.html
This is the link which will give you the Code
http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XML_TO_ABAP_46C.html
Use this XML file to Upload the same, this Program will work for your XML file also,
http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/input_xml.xml
See the below thread also
Upload XML to internal table and vice versa in SAP 4.6C
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya -
Reading XML file to ABAP internal table
Hi all,
Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.
below is the XML file.
===========================================================================
- <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">
- <PIX>
<TransactionType>605</TransactionType>
<TransactionCode>98</TransactionCode>
<TransactionNumber>6888965</TransactionNumber>
<SequenceNumber>40001</SequenceNumber>
- <SKUDefinition>
<Company>GZL</Company>
<Division>BMD</Division>
<Season />
<SeasonYear />
<Style>ORT002A</Style>
<StyleSuffix />
<Color>K13</Color>
<ColorSuffix />
<SecDimension />
<Quality />
<SizeRangeCode />
<SizeDesc>M</SizeDesc>
<SkuID>200140577</SkuID>
</SKUDefinition>
</PIX>
</PIXBridge>
=================================================================
and my Transformation code is as below
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<IPIX>
<xsl:apply-templates select="//PIX"/>
</IPIX>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="PIX">
<item>
<TRANSACTIONTYPE>
<xsl:value-of select="TransactionType"/>
</TRANSACTIONTYPE>
<TRANSACTIONCODE>
<xsl:value-of select="TransactionCode"/>
</TRANSACTIONCODE>
<TRANSACTIONNUMBER>
<xsl:value-of select="TransactionNumber"/>
</TRANSACTIONNUMBER>
<SEQUENCENUMBER>
<xsl:value-of select="SequenceNumber"/>
</SEQUENCENUMBER>
<SKUDEFINITION>
<COMPANY>
<xsl:value-of select="Company"/>
</COMPANY>
<DIVISION>
<xsl:value-of select="Division"/>
</DIVISION>
<SEASON/>
<SEASONYEAR/>
<STYLE>
<xsl:value-of select="Style"/>
</STYLE>
<STYLESUFFIX/>
<COLOR>
<xsl:value-of select="Color"/>
</COLOR>
<COLORSUFFIX/>
<SECDIMENSION/>
<QUANTITY/>
<SIZERANGECODE/>
<SIZEDESC>
<xsl:value-of select="SizeDesc"/>
</SIZEDESC>
<SKUID>
<xsl:value-of select="SkuID"/>
</SKUID>
</SKUDEFINITION>
</item>
</xsl:template>
When i run my program i am getting the values only till the sequence number part and im not getting any values that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>
I need help to sort this , kindly help me in this.
regs,
rajaI am not able to get a clue out of that, can Get Durairaj Athavan Raja in to loop for sorting this out.
I made changes to my transformation program , but still not getting the output of the components inside the
<SKUDefinition> , but when i debug the transformation i can able to see the output values for those components but when i get the values in the result table im not getting values of those components.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<IPIX>
<xsl:apply-templates select="//PIX"/>
</IPIX>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="PIX">
<item>
<TRANSACTIONTYPE>
<xsl:value-of select="TransactionType"/>
</TRANSACTIONTYPE>
<TRANSACTIONCODE>
<xsl:value-of select="TransactionCode"/>
</TRANSACTIONCODE>
<TRANSACTIONNUMBER>
<xsl:value-of select="TransactionNumber"/>
</TRANSACTIONNUMBER>
<SEQUENCENUMBER>
<xsl:value-of select="SequenceNumber"/>
</SEQUENCENUMBER>
<xsl:for-each select="SKUDefinition">
<SKUDEFINITION>
<COMPANY>
<xsl:value-of select="Company"/>
</COMPANY>
<DIVISION>
<xsl:value-of select="Division"/>
</DIVISION>
<SEASON/>
<SEASONYEAR/>
<STYLE>
<xsl:value-of select="Style"/>
</STYLE>
<STYLESUFFIX/>
<COLOR>
<xsl:value-of select="Color"/>
</COLOR>
<COLORSUFFIX/>
<SECDIMENSION/>
<QUANTITY/>
<SIZERANGECODE/>
<SIZEDESC>
<xsl:value-of select="SizeDesc"/>
</SIZEDESC>
<SKUID>
<xsl:value-of select="SkuID"/>
</SKUID>
</SKUDEFINITION>
</xsl:for-each>
</item>
</xsl:template>
</xsl:transform>
==================
Below is my main program
===================
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\XMLABAP1.xml'.
This is the structure for the data from the XML file
TYPES: BEGIN OF ty_text,
TransactionType(3) type n,
TransactionCode(2) type n,
TransactionNumber(7) type n,
SequenceNumber(5) type n,
Company(3) type c,
Division(3) type c,
Season(3) type c,
SeasonYear(4) type c,
Style(8) type c,
Color(3) type c,
SecDimension(3) type c,
Quality(3) type n,
SizeRangeCode(2) type c,
SizeDesc(1) type c,
SkuID(10) type c,
END OF ty_text.
Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
data: xmlstr TYPE XSTRING.
Table and work ares for the data from the XML file
DATA: gt_person TYPE STANDARD TABLE OF ty_text,
gs_person TYPE ty_text.
Result table that contains references
of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Fill the result table with a reference to the data table.
Within the XSLT stylesheet, the data table can be accessed with
"IPERSON".
GET REFERENCE OF gt_person INTO gs_result_xml-value.
gs_result_xml-name = 'IPIX'.
APPEND gs_result_xml TO gt_result_xml.
Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION ZAUM_MANH_SYNC_RPT
SOURCE XML XMLSTR
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
Now let's see what we got from the file
LOOP AT gt_person INTO gs_person.
WRITE: / 'Transaction Type:', gs_person-TransactionType.
WRITE: / 'Transaction Code :', gs_person-TransactionCode.
WRITE: / 'Transaction Number :', gs_person-TransactionNumber.
WRITE: / 'SequenceNumber :', gs_person-SequenceNumber.
WRITE: / 'Company : ', gs_person-Company.
WRITE : /.
ENDLOOP. "gt_person. -
Reading XML Data from ABAP Program?
Hi,
How do I read XML Data from an ABAP Program? For example if I have the below basic XML Code-
<xml>
<Name> Thiru </Name>
<Age> 24 </Age>
<City> chennai </Chennai>
</xml>
How do i read the data within the Name,Age, and City tags into variables in the ABAP Program?
Regards,
Thiruif you decide to do in XSLT, I have a sample list here:
XML file like this:
<?xml version="1.0" encoding="UTF-16"?>
<F>
<P1>
<t_1>value1</t_1>
<t_2>testvalue</t_2>
</P1>
<P2>
</P2>
</F>
XSLT file like this:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="F">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<<b>DOCUMENT</b>>
<xsl:apply-templates/>
</<b>DOCUMENT</b>>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="P1">
<ENTRY>
<<b>T_1</b>><xsl:value-of select="t_1"/></T_1>
<<b>T_2</b>><xsl:value-of select="t_2"/></T_2>
</ENTRY>
</xsl:template>
</xsl:transform>
ABAP program like this:
DATA: BEGIN OF wa_upload,
text(255) TYPE c,
END OF wa_upload,
itab_upload LIKE TABLE OF wa_upload,
BEGIN OF wa_document,
t_1 TYPE string,
t_2 TYPE string,
END OF wa_document,
itab_document LIKE TABLE OF wa_document.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'XXXXX'
filetype = 'ASC'
TABLES
data_tab = itab_upload.
CALL TRANSFORMATION zrappel_xml_test
SOURCE XML itab_upload
RESULT <b>document</b> = itab_document.
You should pay attention to the bold words.
hope it will be helpful
thanks -
Reading XML File from application server
Hi experts,
My aim is to read a XML file from application server and extract the relevant data from it and process further.
When I am trying to read a XML file from application server it is reading success fully but the problem is that its not reading the last root structure of XML file why is so happening can any body help me?
I am using the following code:
TYPES: BEGIN OF xml_line,
text(256) type x,
END OF xml_line.
DATA: e_file LIKE rlgrap-filename VALUE 'applcatin server path'
OPEN DATASET e_file FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
DO.
READ DATASET e_file INTO wa_item1-text.
IF sy-subrc EQ 0.
APPEND wa_item1 TO gt_item1 .
CLEAR wa_item1.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET e_file.
after this i am passing this internal table to "cl_ixml" class to extract the data
but it returning the itab with required value except the last record.
The stream reading the file it self is i thought in complete thats why it is not converting the all values.
Please help me...
Thanks a ton in advance.Hi,
1 Copy Report BCCIIXMLT1
2 (you can change the way of filling internal table xml_table if necessary)
3 you don't need the part between
*-- render the DOM back into an output stream/internal table
and
*-- print the whole DOM tree as a list...
Comment it out or simply delete it
4 Rename form print_node to your liking e.g. process_node
5 In your new form you need three extra variables:
data: attribs type ref to IF_IXML_NAMED_NODE_MAP,
attrib_node type ref to IF_IXML_NODE,
attrib_value type string.
6 After the lines:
when if_ixml_node=>co_node_element.
string = pNode->get_name( ).
Insert:
attribs = pNode->get_attributes( ).
clear attrib_value.
case string.
when ''. "put your XML tag name here
attrib_node = attribs->get_named_item(name = '' ). "put your XML attribute name here
attrib_value = attrib_node->get_value( ).
You can also refer link,
/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
thanks & regards
shreemohan -
Function module to read XML file in ABAP
Hey guys
is there any function module which can read an XML file into an ABAP code?
we are getting some file on the application server in XML format and we need to read this file in ABAP code,how can i achieve this ?
thanz
ahmadHi Ahmad,
These are few functions to work with XML in ABAP.
SDIXML_DATA_TO_DOM: Convert SAP data (elementary/structured/table types) into DOM (XML)
SDIXML_DOM_TO_XML: Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
SDIXML_DOM_TO_SCREEN: Display DOM (XML)
SDIXML_DOM_TO_DATA
Example of using these:
eport z.
data: it_table like t001 occurs 0.
data: l_dom TYPE REF TO IF_IXML_ELEMENT,
m_document TYPE REF TO IF_IXML_DOCUMENT,
g_ixml TYPE REF TO IF_IXML,
w_string TYPE XSTRING,
w_size TYPE I,
w_result TYPE I,
w_line TYPE STRING,
it_xml TYPE DCXMLLINES,
s_xml like line of it_xml,
w_rc like sy-subrc.
start-of-selection.
select * from t001 into table it_table.
end-of-selection.
initialize iXML-Framework ****
write: / 'initialiazing iXML:'.
class cl_ixml definition load.
g_ixml = cl_ixml=>create( ).
check not g_ixml is initial.
write: 'ok'.
create DOM from SAP data ****
write: / 'creating iXML doc:'.
m_document = g_ixml->create_document( ).
check not m_document is initial.
write: 'ok'.
write: / 'converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'IT_TABLE'
DATAOBJECT = it_table[]
IMPORTING
DATA_AS_DOM = l_dom
CHANGING
DOCUMENT = m_document
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
check not l_dom is initial.
write: / 'appending DOM to iXML doc:'.
w_rc = m_document->append_child( new_child = l_dom ).
if w_rc is initial. write 'ok'.
else. write: 'Err =', w_rc.
endif.
visualize iXML (DOM) ****
write: / 'displaying DOM:'.
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
DOCUMENT = m_document
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
convert DOM to XML doc (table) ****
write: / 'converting DOM TO XML:'.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = m_document
PRETTY_PRINT = ' '
IMPORTING
XML_AS_STRING = w_string
SIZE = w_size
TABLES
XML_AS_TABLE = it_xml
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
write: / 'XML as string of size:', w_size, / w_string.
describe table it_xml lines w_result.
write: / 'XML as table of', w_result, 'lines:'..
loop at it_xml into s_xml.
write s_xml.
endloop.
write: / 'end of processing'.
end of code
Let me know if you have further questions..
BR
Rakesh
Maybe you are looking for
-
i want the JDBC Driver for MS SQL Server. is it available free? thanks in advance
-
Photobook corrupt photo !?!?!?!
I'm trying to use Photobook in iPhoto for the first time and I'm about to shoot my computer. The book layout is made, and during the upload I get an error stating photo "IMG_0593.jpg" is corrupt or missing. Replace or delete to place order. Well,
-
RAW Support for Panasonic Lumix DMC-G5?
When is the RAW Support for Panasonic Lumix DMC-G5 available?
-
[In Design CS5 Mac] Déplacer les "informations sur la page" hors des repères ?
Bonjour, Savez-vous s'il possible de décaler les "informations sur la page" à l'export PDF pour éviter qu'elles se retrouvent dans les repères ? L'imprimeur aura besoin de continuer à voir ces infos après découpe. C'est étrange car, sur un format 245
-
Mac book locking up require restart
my mac book locks up with a must restart error. sometimes after mac goes into sleep or screen shutdown but I have had it happen running different apps. any body else have this problem. I thought I had random shut down problem but my mac only locks up