12-22-2008 4:16 AM
Hi,
In my report I have selected some sales orders from vbak table into an internal table.
Now I have selected all items for the above sales order from vbap table.
My requirement is to
Access MVKE table with matnr = vbap-matnr,
vkorg = vbak-vkorg,
vtweg = vbak-vtweg.
and take mvke-prat4.
How to achieve this?
Thanks,
Sandeep.
12-22-2008 4:27 AM
Hi,
First get the data from VBAK table to ur internal table i.e itab.
If itab is not initial.
Select data from VBAP into table JTAB for all entries in itab where vbeln = itab-vbeln.
Endif,
If JTAB is not initial .
Access MVKE table into KTAB for all entries in JTAB where matnr = JTAB-matnr
vkorg = vbak-vkorg,
vtweg = vbak-vtweg.
Endif.
Edited by: Upender Verma on Dec 22, 2008 5:27 AM
12-22-2008 4:31 AM
hi,
use the following code :
select * from vbak into table g_t_vbak where....
if g_t_vbak is not initial.
select * from vbap into table g_T_vbap for all entires
where matnr = g_t_vbak-matnr.....
select prat4 from mvke into g_t_mvke
for all entries in g_T_vbak
where matnr = g_t_vbak-matnr
and vkorg = g_t_vbak-vkorg,
vtweg = g_t_vbak-vtweg.
endif.
Regards,
Mansi
12-22-2008 4:42 AM
hi
first select from vbak tablle
select field1 field2 from vbak into tableit_vbak where....
then if record found select from vbap for all entries in vbak.
if it_vbak is not initial.
select field1 field2 from vbap into table it_vbap for all entires
where matnr = it_vbak-matnr.....
then select from mvke table
select prat4 from mvke into it_mvke
for all entries in it_vbak
where matnr = it_vbak-matnr
and vkorg = it_vbak-vkorg,
vtweg = it_vbak-vtweg.
endif.
thanks
12-22-2008 4:43 AM
hi
first select from vbak tablle
select field1 field2 from vbak into tableit_vbak where....
then if record found select from vbap for all entries in vbak.
if it_vbak is not initial.
select field1 field2 from vbap into table it_vbap for all entires
where matnr = it_vbak-matnr.....
then select from mvke table
select prat4 from mvke into it_mvke
for all entries in it_vbak
where matnr = it_vbak-matnr and
vkorg = it_vbak-vkorg and
vtweg = it_vbak-vtweg.
endif.
thanks
12-22-2008 5:02 AM
Hello Sandeep,
Your qn has been answered by SDNers & i do not want to add to their posts.
My qn is whats your doubt: to use JOINS or FOR ALL ENTRIES(FAE) ?
If so plz refer to this famous blog on FAE, it will help definitely )
[https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4241] [original link is broken] [original link is broken] [original link is broken];
My personal opinion unless you write the code & check the metrics you cannot come to any conclusion.
BR,
Suhas
Edited by: Suhas Saha on Dec 22, 2008 6:05 AM
12-22-2008 6:11 AM
Hi,
first.
select matnr from vbap into it_vbak.
second.
if not it_vbap[] is initial.
select matnr vkorg vtweg prat4 from mvke
for all entries in it_vbak
where matnr = it_vbak-matnr.
endif.
Third,
select vkorg vtweg from vbak into table it_vbak.
fourth.
loop at it_vbak.
read table it_mvke with key
vkorg = it_vbak-vkorg
vtweg = it_vbak-vtweg.
if sy-subrc = 0.
it_final-prat4 = it_mvke-prat4.
append it_final.
endif.
endloop.
mow it_final contains the req result.
Thanks,
Krishna..
12-22-2008 6:31 AM
Hi,
You can use this select query where it_vbap contains items from vbap table.
SELECT a~prat4
INTO TABLE it_mvke
FROM mvke AS a INNER JOIN vbak AS b
ON a~vkorg = b~vkorg AND
a~vtweg = b~vtweg
FOR ALL ENTRIES IN it_vbap
WHERE a~matnr = it_vbap-matnr AND
b~vbeln = it_vbap-vbeln.
Regards,
Manoj Kumar P