Application Development 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: 

Access table node in a XML docuement using cl_xml_document objects

Former Member
0 Kudos

Hello all,

I am using CL_XML_document class to modify a deep complex structure.

I convert the structure into an XML representation using CALL TRANSFORMATION 'ID' and then access its fields using find_node () method of the CL_XML_DOCUMENT.

If i find a particular field(node) , i modify its contents with new values using Set_value() method of if_ixml_node.

This works fine if the complex structures has only simple structures inside it. But in 1 of the case, a field of a structure is an internal table.

So when I reach this node , i need to add an entry into this table using set_value( ) but I am unable to do so.

For ex.

Input structure ZABC have 3 structure fields A, B , C.  Stucture C has a field ITAB which is an internal table.

ZABC

  |- A

      |_ fld1 TYPE  CHAR2

      |_ fld2 TYPE CHAR2

|- B

      |_ fld1 TYPE CHAR2

      |_ fld2 TYPE CHAR2

|- C

      |_ fld1 TYPE CHAR2

      |_ itab TYPE STANDARD TABLE OF TY_TABTYPE    " TY_TABTYPE has 2 fields /columns

My logic


CALL TRANSFORMATION id

SOURCE struc = 'ZABC'

RESULT XML   = xml_string  

xml_doc->parse_string( stream = xml_String ). " XML_doc TYPE REF TO cl_xml_document

    

  LOOP.

   << some code >>

    lv_node  = xml_doc->find_node( "some input" )

    lv_node->set_value( "some value").

  ENDLOOP

So when the lv_node is ITAB , how do i know if its of table type ? Then if there is a row in it then i need to modify. If it is empty then i need to add a new row into the node.

I am totally stuck here as i don't understand how to proceed.

Any one with any pointers on this ?

Appreciate your quick replies.

Thanks

Nilesh

1 REPLY 1

Former Member
0 Kudos

Hello all,

Is there anyone who can help me out ?

BR

Nilesh