TRANSFER DATA FROM ONE INTERNAL TABLE TO ANOTHER TABLE

Transferring data from one internal table to another table

Transferring the data from internal table to another table which are similar structure
If the second internal table is empty.

Syntax: -
<internal table 2> = <internal table 1>.

Ex: -
IT = IT_t001.

If the second internal table has data

Syntax: -
Append lines of <internal table 1> to <internal table 2>.

Ex: -
Append lines of IT_t001 to IT.

Syntax: -
Insert lines of <internal table 1> into table <internal table 2>.

Ex: -
Insert lines of IT_t001 into table IT.

PROGRAM:

*&---------------------------------------------------------------------*
*& Report  ZR_TRASFER_DATA_BW_TWO_IT
*&
*&---------------------------------------------------------------------*
REPORT ZR_TRASFER_DATA_BW_TWO_IT.
TYPES:
  
BEGIN OF ty_vbak,
    vbeln 
TYPE vbak-vbeln,
    auart 
TYPE vbak-auart,
    vkorg 
TYPE vbak-vkorg,
  
END   OF ty_vbak.
DATAt_vbak  TYPE STANDARD TABLE OF ty_vbak.
DATAls_vbak LIKE LINE OF t_vbak.
DATAt_vbeln TYPE STANDARD TABLE OF vbak-vbeln.
DATAlv_lines TYPE i.
* Some test data
SELECT vbeln auart vkorg
  
FROM vbak
  
INTO TABLE t_vbak
  
UP TO 500 ROWS.
CLEAR t_vbeln.
LOOP AT t_vbak INTO ls_vbak.
  
APPEND ls_vbak-vbeln TO t_vbeln.
ENDLOOP.
* Display number of entries in target table
lv_lines 
LINES( t_vbeln ).
WRITE lv_lines.
*CLEAR t_vbeln.
*MOVE t_vbak TO t_vbeln.
*
** Display number of entries in target table
*lv_lines = LINES( t_vbeln ).
*WRITE lv_lines.
*CLEAR t_vbeln.
*APPEND LINES OF t_vbak TO t_vbeln.
*
** Display number of entries in target table
*lv_lines = LINES( t_vbeln ).
*WRITE lv_lines.
* CLEAR t_vbeln.
*t_vbeln = t_vbak.
*
** Display number of entries in target table
*lv_lines = LINES( t_vbeln ).
*WRITE lv_lines.