My db tables:
db_1
db_2
db_3
My internal table:
it_comb
it_comb has a structure with some fields from db_1, db_2, db_3.
All db tables have different structures.
I want to select everything from db_1, db_2, db_3 into the correct fields of it_comb with a where condition.
I would like to do something like this: (This doesn't work)
SELECT * From db_1, db_2, db_3 into CORRESPONDING FIELDS OF TABLE it_comb WHERE db_1-MATNR LIKE db_2-MATNR AND db_1-MATNR LIKE db_3-MATNR.
Obviously, this doesn't work because I can't use ',' like that. How do I write this in ABAP? So that it_comb is filled with data from db_1, db_2 and db_3.
Another problem is that every time I select something into it_comb, my previous data gets overwritten.
Code example would be appreciated for ABAP-Beginner.
You can use inner join -
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE it_comb
FROM db_1 AS a
INNER JOIN db_2 AS b
ON a~matnr = b~matnr
INNER JOIN db_3 AS c
ON a~matnr = c~matnr
WHERE (Your any other condition).
APPENDING won't overwrite the previous record from internal table it_comb.
Warning: Use APPENDING if internal table is TYPE STANDARD otherwise you'll get dump.
Also check the SELECT - JOIN documentaion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With