Skip to Content

How to parse XML for internal table

hi guys, I would like to know how to parse xml for an internal table. I explain myself.

Let's say you have a purchase order form where you have header data & items data. In my interactive form, the user can change the purchase order quantity at the item level. When I received back the pdf completed by mail, I need to parse the xml and get the po qty that has been entered.

This is how I do to get header data from my form

lr_ixml_node = lr_ixml_document->find_from_name( name = ''EBELN ).

lv_ebeln = lr_ixml_node->get_value( ).

How do we do to get the table body??

Should I used the same method (find_from_name) and passing the depth parameter inside a do/enddo?


Alexandre Giguere

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 17, 2009 at 09:31 AM


    Here is an example. Suppose your internal table is called 'ITEMS'.

    lr_node = lr_document->find_from_name('ITEMS').
    lv_num_of_children = lr_node->num_children( ).
    lr_nodechild = lr_node->get_first_child( ).
    do lv_num_of_children times.
        lv_num_of_attributes = lr_nodechild->num_children( ).
        lr_childchild = lr_nodechild->get_first_child( ).
       do lv_num_of_attributes times.
          lv_value = lr_childchild->get_value( ).
          case sy-index.
             when 1.
               wa_item-field1 = lv_value
             when 2.
               wa_item-field2 = lv_value.
          lr_childchild = lr_childchild->get_next( ).
       append wa_item to lt_item.
       lr_nodechild = lr_nodechild->get_next( ).

    Add comment
    10|10000 characters needed characters exceeded