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 to SAP

Former Member
0 Likes
1,335

hI,

I need to convert the data from XML file which is on application server into an internal table

Since the file is on application server I can't use GUI_UPLOAD.

I have read the XML file into an internal table having char type field using the READ DATASET statement. But I'm not able to parse the file.

Can anybody please suggest me an alternative way so that I can directly get the values in an internal table.

I have tried using function modules SMUM_XML_PARSE and TEXT_CONVERT_XML_TO_SAP, but I'm not able to pass proper parameters to them.

I also tried using " read the XML using open data set into a variable of type string. and then use FM SCMS_STRING_TO_XSTRING to convert the string to xstring. pass the xstring to SMUM_XML_PARSE

I tried the same. But it not populating the table and giving an error message in the return table "line 1 col 1-unexpected symbol; expected '<'</', entity reference, charac".

I can't find any ' ; ' in the XML file. What could be the possible reason of error?

Thanks in advance

hI,

I need to convert the data from XML file which is on application server into an internal table

Since the file is on application server I can't use GUI_UPLOAD.

I have read the XML file into an internal table having char type field using the READ DATASET statement. But I'm not able to parse the file.

Can anybody please suggest me an alternative way so that I can directly get the values in an internal table.

I have tried using function modules SMUM_XML_PARSE and TEXT_CONVERT_XML_TO_SAP, but I'm not able to pass proper parameters to them.

I also tried using " read the XML using open data set into a variable of type string. and then use FM SCMS_STRING_TO_XSTRING to convert the string to xstring. pass the xstring to SMUM_XML_PARSE

I tried the same. But it not populating the table and giving an error message in the return table "line 1 col 1-unexpected symbol; expected '<'</', entity reference, charac".

I can't find any ' ; ' in the XML file. What could be the possible reason of error?

Thanks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
1,014

Hi,

Refer to the following link:

http://sap-img.com/abap/xml-file-to-word-document-through-sap.htm

Hope this helps.

Reward if helpful.

Regards,

Sipra

Read only

Former Member
0 Likes
1,014

hai,

Try this.

data :response TYPE string.

Response is where u pass the xml file to it.

*FM converting the XML format to abap

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = response

IMPORTING

buffer = xml.

*FM converting XMl to readable format to a internal table.

CALL FUNCTION 'SMUM_XML_PARSE'

EXPORTING

xml_input = xml

TABLES

xml_table = t_xml

return = return.

Regards,

vikram

Read only

0 Likes
1,014

yaa, I did the same way but i am getting error like "line 1 col 1-unexpected symbol; expected '<'</', entity reference, charac".

Read only

SureshRa
Active Participant
0 Likes
1,014

Hi abap_inter,

You need to create an XML transformation program in t-code XSLT (mind you are 4.7 and above). In your main program you need to read the app server xml file into a string and use CALL TRANSFORMATION statement to pass the XML string to the XSLT program.

In the XSLT program you will define the transformation and all create the relevent structures and table types in ABAP dictionary.

I have done this hands-on in a huge XML based interface in my earlier project. Remember one important thing, if your XML has got date fields also, there could be a lot of problem if you declare them in your ABAP structures as date type. ALL fields should be declared of type STRING. Once you got all the data in internal table, then you can validate them and move them into appropriate type variables.

If you are new to XSLT, please refer to the the help document and demo programs (XSLDEMOFLIGHT*). As a pre-requisite please have a crash course on XSL (will not take more than a day if you study yourself !!!).

Enjoy

Suresh Radhakrishnan

Read only

Former Member
0 Likes
1,014

hai,

in debug mode see the xml code starts with

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>####<Order>## <Customer>###<Name>Bill Buckram</Name>###<Cardnum>

Regards,

vikram