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

Join VAPMA, VBAP and VBEP

Former Member
0 Likes
1,570

We need to select order data based on material number. I've created a join starting at VAPMA and going to VBAP then to VBEP but it seems to be very expensive SQL. Should I structure this another way?

SELECT vvbeln vposnr v~matnr

pvgbel pwerks pvgpos pmeins

ewmeng ej_3asize

INTO CORRESPONDING FIELDS OF TABLE itab

FROM vapma AS v INNER JOIN vbap AS p

ON vvbeln = pvbeln AND

vposnr = pposnr

INNER JOIN vbep AS e

ON pvbeln = evbeln AND

pposnr = eposnr

INNER JOIN vbak AS k

ON kvbeln = evbeln

WHERE ....

We need to select order data based on material number. I've created a join starting at VAPMA and going to VBAP then to VBEP but it seems to be very expensive SQL. Should I structure this another way?

SELECT vvbeln vposnr v~matnr

pvgbel pwerks pvgpos pmeins

ewmeng ej_3asize

INTO CORRESPONDING FIELDS OF TABLE itab

FROM vapma AS v INNER JOIN vbap AS p

ON vvbeln = pvbeln AND

vposnr = pposnr

INNER JOIN vbep AS e

ON pvbeln = evbeln AND

pposnr = eposnr

INNER JOIN vbak AS k

ON kvbeln = evbeln

WHERE ....

5 REPLIES 5
Read only

Former Member
0 Likes
1,117

With the join conditions above, check the fields against indexes on the tables. Check how selective these fields are, using DB05, the more selective the better. Then evaluate whether or not you need a new index.

Also, look at the size and future projected growth of all 3 tables. These things change from company to company. If you have a small enough table, you may want to read it into an ABAP internal table and use the FOR ALL ENTRIES IN statement instead.

Read only

Former Member
0 Likes
1,117

Hi,

Just a suggestion, You can get the details of watever u get from VAPMA ( vvbeln vposnr v~matnr) from VBAP.then join on vbap and vbak should be able to get you the required data right?

Btw..are you using any Inequality condition in your WHERE condition?

Regards,

madhu

Read only

ThomasZloch
Active Contributor
0 Likes
1,117

VAPMA is the correct starting point for access via material number. The JOIN conditions look OK at first glance, please tell us the WHERE conditions also.

Thomas

Read only

Former Member
0 Likes
1,117

hi,

can u tell me what is the whole select statement for it as i might be the where condition is giving the problem to your performance.

Read only

Former Member
0 Likes
1,117

Hi,

INNER JOIN is always very costly in terms of performance.

You try it with FOR ALL ENTRIES...

the following links will help you to get the idea:

[http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_ForAllEntries.asp]

[http://www.sap-img.com/abap/abap-fine-tuning.htm]

Finaly check the link for related syntax

[http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm]

Reward if found helpful.

Anirban Bhattacharjee