Skip to Content
0
Former Member
May 06, 2009 at 09:09 AM

Reading complex file in ABAP internal table.

61 Views

I have a following XML file. and I want to read it in internal Table with deep structure.

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

- http://www.sap.com/abapxml" version="1.0">

- <asx:values>

- <TAB>

- <item>

<CATALOGUEREQUESTIDID>5</CATALOGUEREQUESTIDID>

<MBRSH>Chemical Industry</MBRSH>

<MTART>Spare Parts</MTART>

<WERKS>Spare Parts Warehouse</WERKS>

<MAKTX>Lubricant,Oil Graphite></MAKTX>

<MEINS>Bottle</MEINS>

<MATKL>Spare parts - General</MATKL>

<BRGEW>10</BRGEW>

<GEWEI>G</GEWEI>

<NTGEW>9</NTGEW>

<VOLUM>1</VOLUM>

<VOLEH>L</VOLEH>

<EKGRP>Buyer 1</EKGRP>

<XCHPF>NO</XCHPF>

<EKWSL>-15, -10, -05</EKWSL>

<WEBAZ>2</WEBAZ>

<INSMK>NO</INSMK>

<KZKRI>NO</KZKRI>

<MFRPN>SHELL</MFRPN>

<MFRNR>WD-40</MFRNR>

- <DRGNUM>

<ZEINR>C-39166</ZEINR>

<ZEIAR>KKK</ZEIAR>

<ZEIVR>3</ZEIVR>

<BLATT>4</BLATT>

<AESZN>12</AESZN>

<ZEIFO>A3</ZEIFO>

<BLANZ>12</BLANZ>

</DRGNUM>

- <DRGNUM>

<ZEINR>C-39167</ZEINR>

<ZEIAR>KKK</ZEIAR>

<ZEIVR>3</ZEIVR>

<BLATT>4</BLATT>

<AESZN>12</AESZN>

<ZEIFO>A3</ZEIFO>

<BLANZ>12</BLANZ>

</DRGNUM>

- <DRGNUM>

<ZEINR>C-39168</ZEINR>

<ZEIAR>KKK</ZEIAR>

<ZEIVR>3</ZEIVR>

<BLATT>4</BLATT>

<AESZN>12</AESZN>

<ZEIFO>A3</ZEIFO>

<BLANZ>12</BLANZ>

</DRGNUM>

</item>

</TAB>

</asx:values>

</asx:abap>

+I for this I have created a internal table as; +

types : begin of DRGNUM,
        ZEINR(10),
        ZEIAR(5),
        ZEIVR(5),
        BLATT(5),
        AESZN(5),
        ZEIFO(5),
        BLANZ(5),
       end of DRGNUM.

data : begin of item occurs 0,
       CATALOGUEREQUESTIDID,
       MBRSH(20),
       MTART(15),
       WERKS(30),
       MAKTX(40),
       MEINS(10),
       MATKL(30),
       BRGEW(5),
       GEWEI(2),
       NTGEW(5),
       VOLUM(5),
       VOLEH(2),
       EKGRP(10),
       XCHPF(3),
       EKWSL(15),
       WEBAZ(2),
       INSMK(2),
       KZKRI(2),
       MFRPN(5),
       MFRNR(5).
data : DRGNUM type  ZDRGNUM.
data:  end of item.

...............
..............
..............
*XML
call transformation ('ID')
source xml xmlupl
result tab = item[]

.

The problem is that for DRGNUM nodes in XML I can only manage to get last DRGNUM node data in the internal table.

How can I get all the 3 items for DRGNUM in the Internal table ?

Your help is appreciated.

Edited by: Hasan Bin Tariq on May 6, 2009 11:12 AM