cancel
Showing results for 
Search instead for 
Did you mean: 

Reading XML data using ABAP Mapping

Former Member
0 Kudos

Dear Friends,

I have a issue with reading the below XML DATA in my ABAP Mapping program.Please share your experience .

MY XML FILE-->

<?xml version="1.0" encoding="utf-8" ?>

- <FILE changeId="1" batchNo="35049">

- <TRANSACTION transactionNo="2">

- <SELLING_CODE docNo="2">

- <PRODUCT SKU="1000305">

- <CODE>

<CRUD>P</CRUD>

<SELLING_CODE>30000000000090</SELLING_CODE>

<CODE_TYPE>110002</CODE_TYPE>

</CODE>

</PRODUCT>

</SELLING_CODE>

</TRANSACTION>

</FILE>

I want to read the changeID, BatchNo Value from FILE NODE and similarly from Transaction, Selling_code,Product as well.I can successfully read the other value but dont know how to read the above tag values.

I am using the interface IF_IXML_NODE to read child node values but dont know which method I ll use to read header tag values.

Thanks a lot for your kind help and support in advance.

Regards

Jay

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Anyone could please give any further input on this because I am not able to fetch the appropriate header tab <FILE>  value from the XML file.

Thanks&Regards

Jay

vikas2
Active Participant
0 Kudos

Hi,

May be draw the tree graphically and check the below link, specifically "Finding an element by name".

http://help.sap.com/saphelp_nw04/helpdata/en/86/8280de12d511d5991b00508b6b8b11/content.htm

Thanks,

Vikas

PeterJonker
Active Contributor
0 Kudos

use the get_attributes method.

and do a search on abap mapping first. There are so many sample programs to be found.

e.g.:

http://wiki.sdn.sap.com/wiki/display/XI/ABAP+Mapping+Steps

Former Member
0 Kudos

Hi Peter,

Thank you very much for your response.Yes I know there is lots many sample program in SDN not none of them address my requirement.

The link that you mentioned in your answer ll work well for the below XML type of files and I am currently following the same link for my requirement.Appreciate if you could please help me out to to read the batno in FILE node which is actually the header node.

  <?xml version="1.0" encoding="UTF-8" ?>

- <ns0:MT_Emp_Det xmlns:ns0="http://yash.com/YH203/file2file_abapmapping">

- <EMPLOYEE>

- <PERSONAL>

  <EMPID>001</EMPID>

  <FIRSTNAME>Santosh</FIRSTNAME>

  <MIDDLENAME>Kumar</MIDDLENAME>

  <LASTNAME>K</LASTNAME>

  <AGE>25</AGE>

  <GENDER>M</GENDER>

  </PERSONAL>

- <JOB>

  <COMPANY>XYZ</COMPANY>

  <DEPARTMENT>SAP</DEPARTMENT>

  <DESIGNATION>Consultant</DESIGNATION>

  <BEGINDATE>20050606</BEGINDATE>

  <ENDDATE />

  <SALARY>600000</SALARY>

  </JOB>

- <PERSONAL>

  <EMPID>002</EMPID>

  <FIRSTNAME>Bala</FIRSTNAME>

  <MIDDLENAME>Krishna</MIDDLENAME>

  <LASTNAME>Reddy</LASTNAME>

  <AGE>25</AGE>

  <GENDER>M</GENDER>

  </PERSONAL>

- <JOB>

  <COMPANY>XYZ</COMPANY>

  <DEPARTMENT>SAP</DEPARTMENT>

  <DESIGNATION>Consultant</DESIGNATION>

  <BEGINDATE>20050606</BEGINDATE>

  <ENDDATE>20061206</ENDDATE>

  <SALARY>600000</SALARY>

  </JOB>

- <JOB>

  <COMPANY>XYZ</COMPANY>

  <DEPARTMENT>SAP</DEPARTMENT>

  <DESIGNATION>Consultant</DESIGNATION>

  <BEGINDATE>20070106</BEGINDATE>

  <ENDDATE />

  <SALARY>800000</SALARY>

  </JOB>

  </EMPLOYEE>

  </ns0:MT_Emp_Det>

Regards

Jay

PeterJonker
Active Contributor
0 Kudos

When you say Header node, you mean the root node ?

from  the previous wiki document link  (abstract code)

idocument->GET_ROOT_ELEMENT  the result is of type IF_IXML_ELEMENT then use the method GET_ATTRIBUTE from this result type IF_IXML_ELEMENT.

That should work