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

Using inner join

Former Member
0 Likes
723

How can I write following using inner join instead of writing diffrently ?

Select VBELV POSNV from VBFA into V1 V2

WHERE VBELN = DELIVERY_ITEM-VBELN

AND POSNN = DELIVERY_ITEM-POSNR

AND VB_TYPE_N = 'J'.

Select POSEX from VBAP into V3.

where VBELN = V1

AND POSNR = V2

WRITE:/ V3.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
640

Try this.



select single vbfa~vbelv vbfa~posnv vbap~posex into (v1, v2, v3)
           from vbfa
               inner join vbap
                  on vbfa~vbelv = vbap~vbeln
                 and vbfa~posnv = vbap~posnr
                             where vbfa~vbeln = delivery_item-vbeln
                               and vbfa~posnn = delivery_item-posnr
                               and vbfa~vb_type_n = 'J'.
       

Regards,

Rich Heilman

5 REPLIES 5
Read only

Laxmana_Appana_
Active Contributor
0 Likes
640

hi,

Check this

Select VBELV POSNV POSEX

into v1 v2 v3

from

VBFA as a inner join VBAP as b

on aVBELN = bVBELN and

aPOSNN = bPOSNR

where

a~POSNN = DELIVERY_ITEM-POSNR

AND a~VB_TYPE_N = 'J'.

laxman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
641

Try this.



select single vbfa~vbelv vbfa~posnv vbap~posex into (v1, v2, v3)
           from vbfa
               inner join vbap
                  on vbfa~vbelv = vbap~vbeln
                 and vbfa~posnv = vbap~posnr
                             where vbfa~vbeln = delivery_item-vbeln
                               and vbfa~posnn = delivery_item-posnr
                               and vbfa~vb_type_n = 'J'.
       

Regards,

Rich Heilman

Read only

Former Member
0 Likes
640

Hi Tushar,

try this way...

Select VBFA~VBELV

VBFA~POSNV

VBAP~POSEX

from VBFA

INNER JOIN VBAP

ON VBFAVBELV = VBAPVBELN

VBFAPOSNV = VBAPPOSNR

into V1 V2 V3

WHERE VBFA~VBELN = DELIVERY_ITEM-VBELN

AND VBFA~POSNN = DELIVERY_ITEM-POSNR

AND VB_TYPE_N = 'J'.

WRITE:/ V3.

Read only

Former Member
0 Likes
640

I think you are going about this the hard way. You can get the data you need from LIPS. Going to VBFA without the first elements in the primary key will be very expensive.

Rob

Read only

Former Member
0 Likes
640

Can you please close if answered?

For your current issue, I don't even go to VBFA. Don't you already have the sales order number and the item number in VGBEL, VGPOS fields of LIPS? If not check VBELV and POSNV fields. VBFA is known for perfomance issues. So try to avoid it as much as possible.