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

inner join and outer join statement

Former Member
0 Likes
1,131

Hi all,

can any one tell the code for joining vbap and vbpa.

i want item details from vbap based on vbpa-lifnr (broker for the sales order)

common field is vbeln. In one sale order there are no of lifnr (broker) for individual items.

i want all d items corresponding to lifnr(broker) in a sales order.

please help the same.

sure reward points sure.

Regards

Deepa

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,094

Hi Deepa ,

The code would look some think like this

select VBPA~LIFNR

VBAPvbeln VBAPposnr vbap~matnr <add other feilds you want.

INTO TABLE <IT>

FROM VBPA INNER JOIN VBAP

ON VBPAVBELN = VBAPVBELN

VBPAPOSNR = VBAPPOSNR

WHERE

VBPA~VBELN = <SO Number> and

VBPA~LIFNR = <Vendor>.

Regards

Arun

9 REPLIES 9
Read only

Former Member
0 Likes
1,095

Hi Deepa ,

The code would look some think like this

select VBPA~LIFNR

VBAPvbeln VBAPposnr vbap~matnr <add other feilds you want.

INTO TABLE <IT>

FROM VBPA INNER JOIN VBAP

ON VBPAVBELN = VBAPVBELN

VBPAPOSNR = VBAPPOSNR

WHERE

VBPA~VBELN = <SO Number> and

VBPA~LIFNR = <Vendor>.

Regards

Arun

Read only

0 Likes
1,094

ThanQ one and all

Deepa

Read only

Former Member
0 Likes
1,094
select A~field1 ... B~field2 ...
         into table itab
         from vbap as A inner join
                 vbpa as B on
                 A~vbeln = B~vbeln and
                 A~lifnr = B~lifnr
                 where ...<>.
Read only

Former Member
0 Likes
1,094

Hi,

VBPA contains all the partners for the sales document.

select VBPA~LIFNR

VBAPvbeln VBAPposnr vbap~matnr .

INTO TABLE ITAB

FROM VBPA as a INNER JOIN VBAP as b

ON aVBELN = bVBELN

a~POSNR = '000000' (don't join POSNR's of both simply check whether the POSNR in VBPA is maintained or not , because most of the times the POSNR in VBPA is 000000)

WHERE

a~VBELN = <SO Number> and

a~LIFNR = <Vendor>.

reward if useful

regards,

Anji

Read only

Former Member
0 Likes
1,094

Hi Deepa,

Here is the code....

select-options:s_lifnr for vbpa-lifnr.

data: begin of itab occurs 0,

................,

................,

end of itab.

select a~.........

a~.........

b~.........

b~.........

into corresponding fields of table itab

from vbpa as a inner join vbap as b

on alifnr = blifnr

where a~lifnr in s_lifnr.

Reward points if helpful.

Regards,

Ramana

Read only

Former Member
0 Likes
1,094

Hi deepa,

Innerjoin:

select VBPA~LIFNR

VBAPvbeln VBAPposnr vbap~matnr <add other feilds you want.

INTO TABLE ><IT>

FROM VBPA INNER JOIN VBAP

ON VBPAVBELN = VBAPVBELN

VBPAPOSNR = VBAPPOSNR

WHERE

VBPA~VBELN = <SO Number> and

VBPA~LIFNR = <Vendor>.

Outer join means for all entries.

select vbeln posnr from vbap into table itab where

vbeln = p_vbeln.

if not itab[] is initial.

select lifnr from vbpa into itab1

for allentries in itab

where vbeln = itab-vbeln.

Hope this helps you, reply for queries, Shall post you the updates.

Regards.

Kumar

Read only

Former Member
0 Likes
1,094

Hi Deepa

please try this.

select <items> from vbap

into corresponding fields of itab

where vbpa-vbeln = vbap-vbeln and

vbap~lifnr = <vendor>

hope this will work for u.

please reward if helpful.

regards

ravish

Read only

Former Member
0 Likes
1,094

ThanQ all

Regards

Deepa

Message was edited by:

Deepa KN

Read only

Former Member
0 Likes
1,094

Hi All,

ThanQ

Regards

Deepa

Message was edited by:

Deepa KN