Skip to Content
0
Former Member
Jul 27, 2010 at 01:57 PM

Generate delta records by comparing multiple fields from two tables?

164 Views

I have two tables with similar fields. Let's say Table 1 (T1) has fields Customer, A, B and C. Table 2 (T2) has fields Customer0002, A0002, B0002 and C0002. For each customer (each record) I want to check whether there is any difference in field A and A0002 or B and B0002 or C and C0002. If there is a difference between any of these pairs of fields then I will update that customer's record. Currently I have a piece of code

   DATA: ls_source TYPE y_source_fields,
        ls_target TYPE y_target_fields.

  LOOP AT it_source INTO ls_source.
    if not ( ls_source-A = ls_source-A0002 ).
      MOVE-CORRESPONDING ls_source TO ls_target.
      APPEND ls_target TO et_target.
    endif.
  ENDLOOP.

This checks for the difference between one pair - A and A0002. How can I make it check 3 pairs and update when any of them have differences?