Skip to Content
author's profile photo Former Member
Former Member

Join VAPMA, VBAP and VBEP

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 ....

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 12:13 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 04:34 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 04, 2008 at 08:34 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 12:16 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2008 at 12:44 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.