‎2008 Jun 13 11:08 AM
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
‎2008 Jun 13 11:15 AM
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
‎2008 Jun 13 11:20 AM
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
‎2008 Jun 13 11:21 AM
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
‎2008 Jun 13 11:23 AM
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.
‎2008 Jun 13 11:32 AM
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...
‎2008 Jun 13 11:45 AM
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.