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

Former Member
0 Likes
1,299

Hi experts,

Please let me know inner join for following two queries, i am not able to write , it's giving error. Points will be given for sure.

1) Select customer menu’s associated with the retroactive pricing condition record

Select VBAP.VBELN (Contract #)

VBAP.POSNR (Item #)

Where KONV.KNUMH = KONH.KNUMH (Condition record number)

VBAK.KNUMV = KONV.KNUMV (Document condition number)

VBAK.AUART = “ZMNU” (Document Type)

VBAP.POSNR = KONV.KPOSN (Item #)

2) Select all customer menu and item combinations that are associated with each customer pricing contact that have an associated output condition record in table – B504 (Customer Pricing Contact – PARNR)

Select B504.PARNR (Contact #)

VBPA.VBELN (Contract #),

VBPA.POSNR (Item #)

Where VBPA.PARNR = B504.PARNR (Contact #)

VBPA.PARVW = “Z8”

VBAK.AUART = “ZMNU”

Inner Join VBAK.VBELN = VBPA.VBELN

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,043

Hi Anand,

Please find the queries.

1. SELECT <field list>

INTO <target list>

FROM

( ( VBAK JOIN VBAP ON VBAKVBELN = VBAPVBELN )

( KONH JOIN KONV ON KONHKNUMH = KONVKNUMH ) )

WHERE VBAKKNUMV = KONVKNUMV AND

VBAK~AUART = 'ZMNU' AND

VBAPPOSNR = KONVKPOSN.

2. SELECT <field list>

INTO <target list>

FROM

( ( VBAK JOIN VBPA ON VBAKVBELN = VBAPVBELN )

JOIN B504 ON VBPA.PARNR = B504.PARNR )

WHERE

VBPA.PARVW = 'Z8' AND

VBAK.AUART = 'ZMNU'.

Regards,

Prasanth

7 REPLIES 7
Read only

Former Member
0 Likes
1,043

YOu want to have it in native SQL or in abap open SQL . Becosue what you have written here looks for native...

Read only

Former Member
0 Likes
1,043

Hi

1) It should be like this:

DATA: BEGIN OF RESULT,

VBELN TYPE VBELN,

POSNR TYPE POSNR,

END OF RESULT.

SELECT AVBELN BPOSNR INTO RESULT

FROM VBAK AS A INNER JOIN VBAP AS B

ON AVBELN = BVBELN

WHERE A~AUART = 'ZMNU' .

WRITE: / RESULT-VBELN, RESULT-POSNR.

ENDSELECT.

You can't use the table KONV because it's a cluster table.

2- The second query will be similar.

Max

Read only

0 Likes
1,043

Thanx Max,

This has really helped alot.

I have written the code, it's final testing will be tomorrow, if some thing goes wrong i will again reply with queries, if goes right then i will close this thread.

Thanx for your help.

Anand

Read only

Former Member
0 Likes
1,044

Hi Anand,

Please find the queries.

1. SELECT <field list>

INTO <target list>

FROM

( ( VBAK JOIN VBAP ON VBAKVBELN = VBAPVBELN )

( KONH JOIN KONV ON KONHKNUMH = KONVKNUMH ) )

WHERE VBAKKNUMV = KONVKNUMV AND

VBAK~AUART = 'ZMNU' AND

VBAPPOSNR = KONVKPOSN.

2. SELECT <field list>

INTO <target list>

FROM

( ( VBAK JOIN VBPA ON VBAKVBELN = VBAPVBELN )

JOIN B504 ON VBPA.PARNR = B504.PARNR )

WHERE

VBPA.PARVW = 'Z8' AND

VBAK.AUART = 'ZMNU'.

Regards,

Prasanth

Read only

Former Member
0 Likes
1,043

SELECT AVBAK fields BVBAP fields INTO TABLE internal table

FROM VBAK AS A INNER JOIN VBAP AS B

ON AVBELN = BVBELN

WHERE A~AUART = Selection screen values .

Read only

Former Member
0 Likes
1,043

1) Select customer menu’s associated with the retroactive pricing condition record

Select VBAP.VBELN (Contract #)

VBAP.POSNR (Item #)

Where KONV.KNUMH = KONH.KNUMH (Condition record number)

VBAK.KNUMV = KONV.KNUMV (Document condition number)

VBAK.AUART = “ZMNU” (Document Type)

VBAP.POSNR = KONV.KPOSN (Item #)

--> I did not get your point of using konh in the above.

select Avbeln Bposnr into table itab

from vbak as A inner join vbap as b on Avbeln = bvbeln

inner join konv as c on Aknumv = Cknumv

where bposnr = ckposn and A~auart = 'ZMNU'.

-XXX-

Select B504.PARNR (Contact #)

VBPA.VBELN (Contract #),

VBPA.POSNR (Item #)

Where VBPA.PARNR = B504.PARNR (Contact #)

VBPA.PARVW = “Z8”

VBAK.AUART = “ZMNU”

Inner Join VBAK.VBELN = VBPA.VBELN

-->

SELECT AVBELN APOSNR B~PARNR into table itab

from VBPA as A inner join VBAK as K on AVBELN = KVBELN

inner join B504 as B on APARNR = BPARNR

where APARVW = 'Z8' and KAUART = 'ZMNU'.

Message was edited by: Anurag Bankley

Read only

0 Likes
1,043

anurag u helped me lot, thanx

I have given points to every one & have given more points to you & max. As i replied to max that i have written the code & testing would be tomorrow, so unce evrything goes right i will close the thred or else i will post again with the queries.

thanx for help