on 2023 Jun 20 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!
Request clarification before answering.
Hello Fabrice,
I think, that it would be easier if you use an INNER JOIN.
Good luck!
SELECT itab_1~PERNR
itab_1~DAT1
itab_1~DAT2
itab_1~DAT3
itab_1~NAME
itab_1~STATUS
FROM itab_1 INNER JOIN itab_2
ON itab_1~PERNR EQ itab_1~PERNR
INTO TABLE itab_3
SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}.L0S52 {
color: #0000FF;
}.L0S70 {
color: #808080;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
18 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.