2010 Feb 02 2:34 PM
Hi Guys,
I wanted to build a generic table comparison.
The general idea was to loop through one and read the other.
LOOP AT i_table1 ASSIGNING <line1>.
READ TABLE i_table2 ASSIGNING <line2> INDEX sy-tabix.
idx_field = 1.
DO.
UNASSIGN <field1>.
UNASSIGN <field2>.
ASSIGN COMPONENT idx_field OF STRUCTURE <line1> TO <field1>.
ASSIGN COMPONENT idx_field OF STRUCTURE <line2> TO <field2>.
IF <field1> IS ASSIGNED AND <field2> IS ASSIGNED.
IF <field1> = <field2>.
.....
but in order to make it generic the method parameter has to be of type ANY TABLE.
then i'm nit able to read the table by index.
Does anyone have a solution to compare to generic tables ?
Best Regards,
Rasmus
2010 Feb 02 6:34 PM
You can compare two tables like the next example:
if table1[] = table2[].
write 'ok'.
else.
write 'bad'.
endif.
Table1 and table2 can be field symbols
Hi Guys,
I wanted to build a generic table comparison.
The general idea was to loop through one and read the other.
LOOP AT i_table1 ASSIGNING <line1>.
READ TABLE i_table2 ASSIGNING <line2> INDEX sy-tabix.
idx_field = 1.
DO.
UNASSIGN <field1>.
UNASSIGN <field2>.
ASSIGN COMPONENT idx_field OF STRUCTURE <line1> TO <field1>.
ASSIGN COMPONENT idx_field OF STRUCTURE <line2> TO <field2>.
IF <field1> IS ASSIGNED AND <field2> IS ASSIGNED.
IF <field1> = <field2>.
.....
but in order to make it generic the method parameter has to be of type ANY TABLE.
then i'm nit able to read the table by index.
Does anyone have a solution to compare to generic tables ?
Best Regards,
Rasmus
2010 Feb 02 6:34 PM
You can compare two tables like the next example:
if table1[] = table2[].
write 'ok'.
else.
write 'bad'.
endif.
Table1 and table2 can be field symbols
2010 Feb 03 6:37 AM
Hi Jorge,
Unfortunately there can be some minor differences due to some naming conventions.
So I have to check each field in order to determine if the difference is caused by these naming conventions.
Best Regards
Rasmus
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |