Application Development and Automation 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: 
Read only

select for many table

adil
Participant
0 Likes
637

Hi

i want select all postes orders

that have:

- vbap-matnr in s_matnr

-vbak-vbtyp = ' c'

-vbep-edatu in s_erdat

-vbuk-lfstk <>' '

-orders existe in VBFA

have you a good source for that?

Edited by: yassine82 on Jun 13, 2008 12:14 PM

6 REPLIES 6
Read only

Former Member
0 Likes
617

try this query

select *

from vbak as a join vbep as b

on avbeln = bvbeln

join vbuk as c

on bvbeln = cvbeln

where a~matnr in s_matnr and

a~vbtyp = ' c' and

b~edatu in s_erdat and

c~-lfstk eq ' '

reward points if useful

Read only

Former Member
0 Likes
617

Hi,

Put a join on the tables from which you want to select the data.

To Put a join the pre requisite is that there should be some fields in common between tables,

In your case for VBAK/VBEP there are common fields. So go ahead and put join on these tables. You will get the required results.

To check the syntax, do F1 help on key word INNER JOIN.

Hope this helps!!

Regards,

Lalit Kabra

Read only

Former Member
0 Likes
617

Hi,

you can do it using:

1. Joins as explained in the above post. Or

2. FOR ALL ENTRIES

use second option as it has better performance.

Reward if useful.

Regards

- Rishika

Read only

Former Member
0 Likes
617

You can write For all entries using Primaary keys of each table sequencially.

select matnr

from vabp

into -i_vbap

where matnr in s_matnr.

if i_vabp is not initial

sort i_vabp by vbeln.

endif.

select matnr

from vbak

into table i_vbak

for all entries in i_vbap

where matnr = i_vbap-matnr.

so on....

if this is useful for you , please assign points.

Read only

former_member195383
Active Contributor
0 Likes
617

Hi Make use of join statement

as

select *

from vbak join vbep

on vbakvbeln = vbepvbeln

join vbuk

on vbepvbeln = vbukvbeln

where vbak~matnr in s_matnr and

vbak~vbtyp = ' c' and

vbep~edatu in s_erdat and

vbuk~-lfstk eq ' '.

Reward if useful...

Read only

Former Member
0 Likes
617

Hi,

Try this piece of code.

SELECT a~vbeln

a~matnr

a~posnr

b~lfstk

c~vbtyp

d~edatu

FROM vbap AS a JOIN vbuk AS b

ON avbeln = bvbeln

JOIN vbak AS c

ON bvbeln = c vbeln

JOIN vbep AS d

ON cvbeln = d vbeln

INTO TABLE itab

WHERE a~matnr IN s_matnr

AND b~lfstk = u2018u2019

AND c~vbtyp = u2018Cu2019

AND d~edatu IN s_erdat .

We can even do the other way round by selecting the data from one table then using for all entries of above select for other select statements.

Plz reward if useful.

Thanks,

Dhanashri.