on 06-20-2023 12:29 PM
Hi,
I tried to merge two internal tables (itab_1 & 2) into another one (itab_3). They have the same type.
Here the coding:
LOOP AT ITAB_2.
READ TABLE ITAB_1 WITH KEY: PERNR = ITAB_2-PERNR, DAT2 = ITAB_2-DAT1.
IF SY-SUBRC = 0.
ITAB_3-PERNR = ITAB_1-PERNR.
ITAB_3-DAT1 = ITAB_1-DA1.
ITAB_3-DAT2 = ITAB_2-DAT2.
* ITAB_3-DAT3 = ITAB_1-DAT3.
ITAB_3-NAME = ITAB_2-NAME.
ITAB_3-STATUS = ITAB_1-STATUS.
ENDIF.
AT LAST.
CONTINUE.
ENDAT.
APPEND ITAB_3.
ENDLOOP.
Result
The problem is that, when the conditions are verified at a line, the next one will be filled with new data of itab_2, but previous data of itab_1, as long as the PERNR is the same.
I would like to merge this like an inner join
How can I improve my coding, so that I can merge the two internal tables with matching entries?
I thank you in advance!
in the case you want to join data from both itab with same index, you could just use
READ TABLE itab_3 INDEX sy-tabix.
right after the loop, unless you have key ( or keys ) which is unique to each row
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
9 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.