‎2009 Jan 05 10:30 AM
hello friends.........
i am writing the following code but i am not getting the o/p except two fields vbeln and erdat.
tables: vbap,
vbak,
mara.
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
ernam like vbak-ernam,
end of itab.
data: begin of ktab occurs 0,
posnr like vbap-posnr,
matnr like vbap-matnr,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
vbeln like vbap-vbeln, " common key with itab.
end of ktab.
data: begin of jtab occurs 0,
ernam like mara-ernam,
laeda like mara-laeda,
end of jtab.
data: begin of atab occurs 0,
posnr like vbap-posnr,
matnr like vbap-matnr,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
laeda like mara-laeda,
ernam like mara-ernam,
end of atab.
-
query starts here
-
select vbeln erdat from vbak into table itab
where vbeln in vb.
select posnr matnr kwmeng netpr from vbap into table ktab for all entries in
itab where vbeln = itab-vbeln.
select ernam laeda from mara into table jtab for all entries in ktab
where matnr = ktab-matnr.
loop at itab.
move itab-vbeln to atab-vbeln.
move itab-erdat to atab-erdat.
read table ktab with key vbeln = itab-vbeln.
if sy-subrc = 0.
atab-posnr = ktab-posnr.
atab-matnr = ktab-matnr.
atab-kwmeng = ktab-kwmeng.
atab-netpr = ktab-netpr.
endif.
read table jtab with key ernam = itab-ernam.
if sy-subrc = 0.
atab-ernam = jtab-ernam.
ATAB-LAEDA = JTAB-LAEDA.
endif.
append atab.
endloop.
-
and if i am selecting vbeln in ktab and ernam in itab then i am getting different values that of mara-ernam's.value.
thnks n regards
mukesh
‎2009 Jan 05 10:40 AM
1.For all entries..
Before fetching records from a table with for all entries,
try giving,
If vbak is not initial.
Select st with for all entries shud be here..
endif.
2.And Clearing the tables before Endloop will also count.
Hope this helps.
‎2009 Jan 05 10:40 AM
1.For all entries..
Before fetching records from a table with for all entries,
try giving,
If vbak is not initial.
Select st with for all entries shud be here..
endif.
2.And Clearing the tables before Endloop will also count.
Hope this helps.
‎2009 Jan 05 10:47 AM
With Statement FOR ALL ENTRIES you need to check the table you are refering should not be empty.
Thare has to be atleast one record.
For That you have to put a check - > If Itab is not initial.
endif.
Also, Make sure if the refernce table is empty then system would take it as there is no where clause with SELECT statement, hence it will selct all the records from that particular client.
Vikas.
‎2009 Jan 05 10:49 AM
There is a big Mistake...
select posnr matnr kwmeng netpr *vbeln* from vbap into table ktab for all entries in
itab where vbeln = itab-vbeln.
The VBELN was missing..