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

Combining two queries in one..

Former Member
0 Likes
997

Hi,

Can someone tell me how to combine follwoing two queries in one so that it will increase performance..

SELECT single PLNNR from AFKO

into T1

WHERE AUFNR = '007200000100'.

SELECT single STATU from PLKO

into T2

WHERE PLNNR = T1.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
877

check out the JOIN option

SELECT single Fplnnr pSTATU

INTO (t1, t2)

FROM AFKO AS F INNER JOIN PLKO AS P

ON Fplnnr = Pplnnr

WHERE AUFNR = '007200000100'.

Hi,

Can someone tell me how to combine follwoing two queries in one so that it will increase performance..

SELECT single PLNNR from AFKO

into T1

WHERE AUFNR = '007200000100'.

SELECT single STATU from PLKO

into T2

WHERE PLNNR = T1.

4 REPLIES 4
Read only

Former Member
0 Likes
878

check out the JOIN option

SELECT single Fplnnr pSTATU

INTO (t1, t2)

FROM AFKO AS F INNER JOIN PLKO AS P

ON Fplnnr = Pplnnr

WHERE AUFNR = '007200000100'.

Read only

0 Likes
877



data: statu type plko-statu.



select single statu into statu
       from afko
          inner join plko
             on afko~plnnr = plko~plnnr
                      where aufnr = '007200000100'.

Regards,

Rich Heilman

Read only

0 Likes
877

oops....

sorry u cant use select single in a sub query

the syntax of a subquery is quite restricted...the link will give you the details...

but in any case....either u use joins or subqueries...i dont think there will be a major impact on performance in this particular case that you have specified.

regards,

PJ

Read only

Former Member
0 Likes
877

using subqueries it is possible

select single statu from plko into t2 where plnnr in (select single plnnr from afko where aufnr eq '007200000100').

read about subqueries at this link...

http://help.sap.com/saphelp_erp2004/helpdata/en/dc/dc7614099b11d295320000e8353423/frameset.htm

regards,

PJ