Application Development and Automation 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: 
Read only

Looking for two structure types comparison method

Former Member
0 Likes
2,357

Hi All

Could somebody provide a method for two structure types comparison ?

I need to define if both structures have same:

  • fields quantity
  • field names
  • fields order

but one of field has different length.

Does it exist short method for the difference check?

Of course I can create two tables by CL_ABAP_TYPE_DESCR  with types of these structures and to compare these internal tables them line by line.

May be exists more short Method without LOOP ?

Regards..

1 ACCEPTED SOLUTION
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,144

Please check the following link

http://scn.sap.com/thread/3351517

4 REPLIES 4
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,145

Please check the following link

http://scn.sap.com/thread/3351517

Read only

Former Member
0 Likes
1,144

Hi Anuser,

The structure can be compared either by using the FM DDIF_NAMETAB_GET or using CL_ABAP_TYPE_DESCR like mentioned below. But as far as I know, if you want to compare internal table records, you must loop through the records.

Structure comparison using CL_ABAP_TYPE_DESCR:

TYPES: begin of my_type,

        age TYPE i,
        name type text30,

       end of my_type.

DATA: my_data   TYPE my_type,
      descr_ref TYPE ref to cl_abap_typedescr.

START-OF-SELECTION.
  descr_ref = cl_abap_typedescr=>describe_by_data( my_data ).

  WRITE: / 'Typename:', descr_ref->absolute_name.
  WRITE: / 'Kind    :', descr_ref->type_kind.
  WRITE: / 'Length  :', descr_ref->length.
  WRITE: / 'Decimals:', descr_ref->decimals.

Thanks,

Ajay Bose

Read only

Former Member
0 Likes
1,144

Sorry, I forgot a small detail. These structures are Local in ABAP program and they don't have relation to SAP Dictionary.

But it seems to me advised CL_TPDA_TOOL_DIFF->DIFF_VARS my be appropriate. I check it  

Read only

0 Likes
1,144

Yes becoz this is what New ABAP debugger use in its new tool structure comparison