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

compare 2 tables

Former Member
0 Likes
510

hi everybody

i have to compare the fields of 2 tables(to check whether the values have changed for the fields).

The tables are of type vbap and contain all the fields of the table vbap.

does anybody know how to compare all the fields of the 2 tables?

i was thinking of using loops but I guess there may be an easier way

Regards

Anjali

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
479

i guess u have to loop to compare

loop at itab1 into wa_itab1.
  loop at itab2 into wa_itab2.
     if wa_itab1 = wa_itab2.
        *all the fields are equal
     else.
        *fields r not same.
  endloop.
endloop.

4 REPLIES 4
Read only

Former Member
0 Likes
479

Hi Sia,

You can get all the table fields from table -DD03L and then compare...

Hope this helps.

Manish

Read only

Former Member
0 Likes
479

Hi,

You can use <itab1> <operator> <itab2>

where operator = [(EQ, =, NE, <>, ><, GE, >=, LE, <=, GT, >, LT, <)]

Example:

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA: ITAB LIKE TABLE OF LINE,

JTAB LIKE TABLE OF LINE.

DO 3 TIMES.

LINE-COL1 = SY-INDEX.

LINE-COL2 = SY-INDEX ** 2.

APPEND LINE TO ITAB.

ENDDO.

MOVE ITAB TO JTAB.

LINE-COL1 = 10. LINE-COL2 = 20.

APPEND LINE TO ITAB.

IF ITAB GT JTAB.

WRITE / 'ITAB GT JTAB'.

ENDIF.

Regards,

Ruthra

Read only

Former Member
0 Likes
480

i guess u have to loop to compare

loop at itab1 into wa_itab1.
  loop at itab2 into wa_itab2.
     if wa_itab1 = wa_itab2.
        *all the fields are equal
     else.
        *fields r not same.
  endloop.
endloop.

Read only

0 Likes
479

thanks for the reply