Google Search - Blog...........

ABAP - Sample Code On Inner Join On Three Tables.

report ztest.

tables:mara,marc,mard.

data:begin of itab occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
meins like mara-meins,
werks like marc-werks,
pstat like marc-pstat,
labst like mard-labst,
lgort like mard-lgort,
maktx like makt-maktx,
end of itab.


select-options:s_matnr for mara-matnr.

start-of-selection.
select a~matnr
a~mtart
a~meins
b~werks
b~pstat
c~lgort
c~labst
into corresponding fields of table itab
from mara as a inner join marc as b on a~matnr = b~matnr
inner join mard as c on a~matnr = c~matnr
and b~werks = c~werks
where a~matnr in s_matnr.

if sy-subrc = 0.

loop at itab.

select single maktx
from makt
into itab-maktx
where matnr = itab-matnr.
modify itab.

write:/ itab-matnr,
itab-mtart,
itab-meins,
itab-werks,
itab-pstat,
itab-lgort,
itab-labst,
itab-maktx.

endloop.

endif.

No comments:

Post a Comment