‎2006 Mar 21 6:28 AM
Hi all,
I have a problem. I want to write a function module (or method) which imports two similar complex structures. Inside the module, I want to compare every field of every sub-structure and fill some table. How can I do this generically(meaning I do not know the type of the complex structure imported into the module)?
e.g. the module imports bus_ei_extern1 and bus_ei_extern2 structures. These structures have sub-structures like central_data, address etc. These sub-structures have fields inside that i want to compare.
Thanks in advance for your help
‎2006 Mar 21 6:48 AM
have a look at abap RADVVTB2 which is used by the dictionary 'compare versions' utility.
‎2006 Mar 21 6:59 AM
Hi Neil,
I do not want to compare the structures themselves (because they will be same for sure), but the values of the fields in the sub-structures.
eg. consider two complex structures st1 and st2
they both have sub-structure 'central' which has fields name1, name2 and name3.
st1
central
name1 = 'abc'
name2 = 'xyz'
name3 = 'pqr'
st2
central
name1 = 'abc'
name2 = 'mno'
name3 = 'pqr'
in the above two structure, name2 field is unequal. I somehow first want to find out the sub-structures of st1 and st2 (which is central) and fields in the substructure and finally compare them.
Message was edited by: Vikram Nagendra
‎2006 Mar 21 7:49 AM
you can discover the fields belonging to a structure by using a variant of describe:
eg,
data td TYPE sydes_desc.
*.. get attributes of component field
DESCRIBE FIELD <field> INTO td.
The structure is quite complex but have a play around in debug and it may become clear.
Then you'd need to loop at the components of the structures and make comparisons.
something like:
DO.
*... work through all structure's components...
ASSIGN COMPONENT sy-index OF STRUCTURE <in_content> TO <field>.
IF sy-subrc <> 0.
*... exit when reaching the end of components
EXIT.
ENDIF.
enddo.