Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt on Joins and for all entries

Former Member
0 Kudos

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.

7 REPLIES 7

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

SuhaSaha
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

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..

Former Member
0 Kudos

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