04-14-2009 11:17 AM
Hi all,
Can anyone let me know how to compare two structures ie., wheather all fields(sequence/datatypes) of <Structure1> are same as <Structure2>..
Cheers,
Rahul.
04-14-2009 11:20 AM
Hi there,
if you are comparing in some report program in debugging mode, then in the new sap debugger, we have a functionality to compare structures.... you can use that. ....
otherwise, compare the data types of the fields of the structures. If the data types are same , then the structures are identical . Also the number of fields shopuld also be the same.
Do get back if you need further help...
best regards,
Prem Sharma
04-14-2009 11:22 AM
04-14-2009 11:24 AM
Hi Rahul,
do below
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = wa_structure1
CHANGING
ct_fieldcat = it_fieldcat1
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = wa_structure1
CHANGING
ct_fieldcat = it_fieldcat2
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
if it_fieldcat1[] = it_fieldcat2[].
,...success message
endif.
it works
04-14-2009 11:24 AM
04-14-2009 11:31 AM
Hi,
Try the below code.
DATA: lo_obj TYPE REF TO CL_ABAP_STRUCTDESCR.
DATA: lt_comp1 TYPE cl_abap_structdescr=>component_table.
DATA: lt_comp2 TYPE cl_abap_structdescr=>component_table.
lo_obj ?= cl_abap_structdescr=>describe_by_name( 'STRUC1_NAME' ).
lt_comp1 = lo_obj->get_components( ).
lo_obj ?= cl_abap_structdescr=>describe_by_name( 'STRUC2_NAME' ).
lt_comp2 = lo_obj->get_components( ).
if lt_comp1 = lt_comp2.
endif.
Regards,
Sesh
04-15-2009 7:34 AM
Thanks for your answers, but I wanted to compare two structures of workareas(not values in it).
for ex: <WA1> = <WA2>...?