ABAP Release 7.40 SP05 provides many different powerful features. The post describes about how to use MOVE-CORRESPONDING with respect to Internal tables.
Program
DATA: lt_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 = sy–repid
i_structure_name = ‘SCARR’
TABLES
t_outtab = lt_scarr.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy–repid
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 = sy–repid
i_structure_name = ‘SPFLI’
TABLES
t_outtab = lt_spfli.
ALV for SCARR table.
ALV for SPFLI table.
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 .
DATA: lt_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 = sy–repid
i_structure_name = ‘SCARR’
TABLES
t_outtab = lt_scarr.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy–repid
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 = sy–repid
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.
ALV for SPFLI table after
MOVE-CORRESPONDING lt_scarr TO lt_spfli KEEPING TARGET LINES.