ABAP - traverse deep structure in ABAP using CL_XML_DOCUMENT



All, I have a deep structure and one of the field of this deep structure is an internal table.


Using CALL TRANDROMATION id , i convert this structure into an XML string and then traverse it using CL_XML_DOCUMENT.


I am setting the values of each node but when i come across this field which is an internal table, I simply don't know how to proceed. If there are any entries existing then I need to replace them . If this node is empty then i need to create an entry into this internal table.


Can any one help me out here ?


For example :- 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.


Appreciate your quick replies.


Thanks Nilesh Puranik


No comments:

Post a Comment