Skip to Content
avatar image
Former Member

DataSet text file to internal table

Hi,

I have an XML file which is stored in AL11 as a one line string like below:

<?xml version="1.0" encoding= "UTF-8"?><GrpHdr><Matnr>1234567</matnr><MTART>type</MTART><MATKL>group</MATKL><BISMT>00000123</BISMT><VOLUM>17</VOLUM></GrpHdr>

I used:

DATA: lv_data TYPE string.

OPEN DATASET file1 FOR INPUT IN TEXT MODE ENCODING UTF-8. and READ DATASET

DO.

READ DATASET file1 INTO lv_data.

**lv_data will contain the same string line as the file appears in AL11.

ENDDO.

My questions is, how can I assign/map the fields in the file to my internal table of type customized table and store the new record in DB table?

Thank you,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 14, 2015 at 12:21 PM

    Thanks everybody for your help. I have used below guide with exactly the same and it works just as I wanted.

    Guide towards a simple conversion of an XML file to ABAP Internal table, using XML parsing

    Thank you.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 14, 2015 at 09:05 AM

    Hi Eman,

    If your process is very much frequent use, and there sould not be any changes in future, then i Suggest to go from creation a Transformation for the related XML type.

    Creating a Transformation Program -  ABAP Workbench Tools - SAP Library

    Or your can use the below function module to read the store the XML informaiton in internal Table.

    SWF_XML_TO_ABAP


    or follow the below Link, which is related to your requirement.

    Guide towards a simple conversion of an XML file to ABAP Internal table, using XML parsing.

    Regards.

    Praveer.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 14, 2015 at 08:36 AM

    you can use transformation. Have a look on call transformation id in SDN

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 14, 2015 at 09:55 AM

    Hello Eman,

    You can use transformation to map XML data into an internal table and vice-versa. Below are some links for your reference:

    http://scn.sap.com/message/1283866#1283866

    http://sapblog.rmtiwari.com/2009/04/generate-simple-transformation-for-xml.html

    I found few other useful links, if you do not want to use transformation:

    http://scn.sap.com/docs/DOC-24791

    http://wiki.scn.sap.com/wiki/display/ABAP/Upload+XML+file+to+internal+table

    http://scn.sap.com/thread/96971

    With Regards,

    Dipika.

    Add comment
    10|10000 characters needed characters exceeded