MOVE-CORRESPONDING for Internal Tables

MOVE-CORRESPONDINGABAP Release 7.40 SP05 provides many different powerful features. The post describes about how to use MOVE-CORRESPONDING with respect to Internal tables.

 

 

Program


DATAlt_scarr TYPE TABLE OF scarr,
              lt_spfli TYPE TABLE OF spfli.
START-OF-SELECTION.
  SELECT FROM scarr INTO TABLE lt_scarr.
  SELECT FROM spfli INTO TABLE lt_spfli.
  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
    EXPORTING
      i_callback_program syrepid
      i_structure_name   ‘SCARR’
    TABLES
      t_outtab           lt_scarr.
  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
    EXPORTING
      i_callback_program syrepid
      i_structure_name   ‘SPFLI’
    TABLES
      t_outtab           lt_spfli.

  MOVE-CORRESPONDING lt_scarr TO lt_spfli .

  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
    EXPORTING
      i_callback_program syrepid
      i_structure_name   ‘SPFLI’
    TABLES
      t_outtab           lt_spfli.


1

ALV for SCARR table.

2

ALV for SPFLI table.

3

MOVE-CORRESPONDING lt_scarr TO lt_spfli . This statement just deletes the entries from the target table and moves the matching fields from source to the target .

ALV for SPFLI table after  MOVE-CORRESPONDING lt_scarr TO lt_spfli .

4


 

DATAlt_scarr TYPE TABLE OF scarr,
              lt_spfli TYPE TABLE OF spfli.
START-OF-SELECTION.
  SELECT FROM scarr INTO TABLE lt_scarr.
  SELECT FROM spfli INTO TABLE lt_spfli.
  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
    EXPORTING
      i_callback_program syrepid
      i_structure_name   ‘SCARR’
    TABLES
      t_outtab           lt_scarr.
  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
    EXPORTING
      i_callback_program syrepid
      i_structure_name   ‘SPFLI’
    TABLES
      t_outtab           lt_spfli.

  MOVE-CORRESPONDING lt_scarr TO lt_spfli KEEPING TARGET LINES.

  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
    EXPORTING
      i_callback_program syrepid
      i_structure_name   ‘SPFLI’
    TABLES
      t_outtab           lt_spfli.

This statement  MOVE-CORRESPONDING lt_scarr TO lt_spfli KEEPING TARGET LINES. just append records from the source table to the target table with matching fields without deleting the target table entries.

5

ALV for SPFLI table after  

MOVE-CORRESPONDING lt_scarr TO lt_spfli KEEPING TARGET LINES.

6


 

Leave a Reply