2021 Mar 16 7:33 PM

The situation is similar to having 2 internal tables gt_itab1 and gt_itab2. I need to create a table gt_itab3 and gt_itab4 which hold the contents of gt_itab1 and gt_itab2.
The code below:
REPORT Z_TRY4.
TYPES : BEGIN OF itab1,
index TYPE int4,
number1 TYPE int4,
END OF itab1.
TYPES : BEGIN OF itab2,
index TYPE int4,
a_number TYPE int4,
address TYPE char40,
END OF itab2.
TYPES: BEGIN OF itab3, " store n1 = itab1-b, n2 = itab2-b, summ = n1 + n2
index TYPE int4,
new_index TYPE int4,
number1 TYPE int4,
a_number TYPE int4,
address type char40,
END OF itab3.
TYPES: BEGIN OF itab4, " store n1 = itab1-b, n2 = itab2-b, summ = n1 + n2
index TYPE int4,
new_index TYPE int4,
number1 TYPE int4,
a_number TYPE int4,
address type char40,
END OF itab4.
*DATA : itab11 type itab1 occurs 0 with header line.
*DATA : itab22_1 type itab2_1 occurs 0 with header line.
DATA: gs_itab1 TYPE itab1,
gt_itab1 TYPE STANDARD TABLE OF itab1,
gs_itab2 TYPE itab2,
gt_itab2 TYPE STANDARD TABLE OF itab2,
variable TYPE int4,
variable2 TYPE int4,
gt_itab3 TYPE STANDARD TABLE OF itab3,
gs_itab3 TYPE itab3,
gt_itab4 TYPE STANDARD TABLE OF itab4,
gs_itab4 TYPE itab4.
gs_itab1-index = 01.
gs_itab1-number1 = 10.
APPEND gs_itab1 TO gt_itab1.
gs_itab1-index = 02.
gs_itab1-number1 = 11.
APPEND gs_itab1 TO gt_itab1.
gs_itab1-index = 03.
gs_itab1-number1 = 13.
APPEND gs_itab1 TO gt_itab1.
************
gs_itab2-index = 01.
gs_itab2-a_number = 100.
gs_itab2-address = 'zyz'.
APPEND gs_itab2 TO gt_itab2.
gs_itab2-index = 02.
gs_itab2-a_number = 100.
gs_itab2-address = 'xyz'.
APPEND gs_itab2 TO gt_itab2.
gs_itab2-index = 02.
gs_itab2-a_number = 101.
gs_itab2-address = 'zyx'.
APPEND gs_itab2 TO gt_itab2.
gs_itab2-index = 02.
gs_itab2-a_number = 102.
gs_itab2-address = 'zzz'.
APPEND gs_itab2 TO gt_itab2.
gs_itab2-index = 03.
gs_itab2-a_number = 110.
gs_itab2-address = 'fnh'.
APPEND gs_itab2 TO gt_itab2.
CLEAR: gs_itab1, gs_itab2.
*
if gt_itab1[] is not INITIAL.
loop at gt_itab1 into gs_itab1.
MOVE-CORRESPONDING gs_itab1 to gs_itab3.
APPEND gs_itab3 to gt_itab3.
ENDLOOP.
ENDIF.
CLEAR: gs_itab3.
if gt_itab2[] is not INITIAL.
loop at gt_itab2 into gs_itab2.
READ TABLE gt_itab3 into gs_itab3 with key index = gs_itab2-index. " i dont think keys can be given as the key must be unique
* MOVE-CORRESPONDING gs_itab2 to gs_itab3.
gs_itab3-new_index = gs_itab2-index.
gs_itab3-a_number = gs_itab2-a_number.
gs_itab3-address = gs_itab2-address.
* MODIFY gt_itab3 from gs_itab3 INDEX sy-tabix TRANSPORTING new_index a_number address.
MODIFY gt_itab3 from gs_itab3.
ENDLOOP.
ENDIF.
Gives me the wrong output:

I'm a newbie. Any help will be really useful.