Skip to Content
1
Jul 27, 2020 at 10:58 AM

How to Comparing 2 internal table and get the different records

83 Views

I have 2 internal tables with the same structure. GT_AFPO and GT_AFPO. I wanna looping GT_AFPO that not in GT_AFPO2.

 
SELECT a~matnr a~aufnr a~psmng a~wemng a~amein a~ltrmi b~objnr c~stat
  FROM afpo AS a
  JOIN aufk AS b ON a~aufnr = b~aufnr
  JOIN jest AS c ON b~objnr = c~objnr
  INTO CORRESPONDING FIELDS OF TABLE gt_afpo
  FOR ALL ENTRIES IN gt_mard
  WHERE a~matnr = gt_mard-matnr AND a~pwerk = p_werks
  AND c~stat = 'I0002'
  AND c~inact = ''
    .
SELECT a~aufnr FROM afpo AS a
      JOIN aufk AS b ON a~aufnr = b~aufnr
      JOIN jest AS c ON b~objnr = c~objnr
     INTO CORRESPONDING FIELDS OF TABLE gt_afpo2
     WHERE a~matnr = gw_mara-matnr AND a~pwerk = p_werks
    AND c~stat = 'I0076' AND c~inact = ''.
    
    LOOP AT gt_afpo INTO gw_afpo WHERE matnr = gw_mara-matnr.
      lv_qty_pro = lv_qty_pro + gw_afpo-psmng.
    ENDLOOP.