Hi Guys,
Please correct my code. I am using for all entries to extract data from three tables mara, mbew, marc. Please find the attachment.Please correct me
In the final loop statement
No data is coming to final internal table in the bottom loop statement. I request u to spare ur time. Thanks in advance . I am not getting any records in gi_matmaster while debugging. U will be rewarded.
code:
*Structure for material master
TYPES: BEGIN OF gs_matmaster,
matnr type mara-matnr, " Material Number
bismt type mara-bismt, " Old Material Number
normt type mara-normt, " Material Description
stprs type mbew-stprs, " Standard Cost
expme type marc-expme, " HTS Code
prefe type marc-prefe, " NAFTA Code
herkl type mara-herkl, " Country Of Origin
meins type mara-meins, " Unit Of Measure
ntgew type mara-ntgew, " Net Weight
mtart type mara-mtart, " Material Type
bwvor type mara-bwvor, " Procurement Type
END OF gs_matmaster.
TYPES: BEGIN OF gs_matmaster_mara,
matnr type mara-matnr,
bismt type mara-bismt,
normt type mara-normt,
herkl type mara-herkl,
meins type mara-meins,
ntgew type mara-ntgew,
mtart type mara-mtart,
bwvor type mara-bwvor,
END OF gs_matmaster_mara.
TYPES: BEGIN OF gs_matmaster_marc,
matnr type marc-matnr,
expme type marc-expme,
prefe type marc-prefe,
END OF gs_matmaster_marc.
TYPES: BEGIN OF gs_matmaster_mbew,
matnr type mbew-matnr,
stprs type mbew-stprs,
END OF gs_matmaster_mbew.
*INTERNAL TABLES/WORK AREA FOR MATERIAL MASTER
DATA: gi_matmaster type standard table of gs_matmaster,
gw_matmaster type gs_matmaster,
gi_matmaster_mara type standard table of gs_matmaster_mara,
gw_matmaster_mara type gs_matmaster_mara,
gi_matmaster_marc type standard table of gs_matmaster_marc,
gw_matmaster_marc type gs_matmaster_marc,
gi_matmaster_mbew type standard table of gs_matmaster_mbew,
gw_matmaster_mbew type gs_matmaster_mbew.
select matnr
bismt
normt
herkl
meins
ntgew
mtart
bwvor
from mara
into table gi_matmaster_mara
where ersda in s_ersda
or laeda in s_laeda.
IF NOT gi_matmaster_mara is initial.
select matnr
stprs
from mbew
into table gi_matmaster_mbew
for all entries in gi_matmaster_mara
where matnr = gi_matmaster_mara-matnr.
IF NOT gi_matmaster_mara is initial.
select matnr
expme
prefe
from marc
into table gi_matmaster_marc
for all entries in gi_matmaster_mara
where matnr = gi_matmaster_mara-matnr.
ENDIF.
ENDIF.
LOOP AT gi_matmaster into gw_matmaster.
clear gw_matmaster.
gw_matmaster-matnr = gw_matmaster_mara-matnr.
gw_matmaster-bismt = gw_matmaster_mara-bismt.
gw_matmaster-normt = gw_matmaster_mara-normt.
READ TABLE gi_matmaster_mbew into gw_matmaster_mbew with key matnr = gw_matmaster_mara-matnr.
if sy-subrc eq 0.
gw_matmaster-stprs = gw_matmaster_mbew-stprs.
endif.
READ TABLE gi_matmaster_marc into gw_matmaster_marc with key matnr = gw_matmaster_mara-matnr.
if sy-subrc eq 0.
gw_matmaster-expme = gw_matmaster_marc-expme.
gw_matmaster-prefe = gw_matmaster_marc-prefe.
endif.
gw_matmaster-herkl = gw_matmaster_mara-herkl.
gw_matmaster-meins = gw_matmaster_mara-meins.
gw_matmaster-ntgew = gw_matmaster_mara-ntgew.
gw_matmaster-mtart = gw_matmaster_mara-mtart.
gw_matmaster-bwvor = gw_matmaster_mara-bwvor.
append gw_matmaster to gi_matmaster .
ENDLOOP.
Regards,
nagaraju