Skip to Content
avatar image
Former Member

Select taking more time when selecting data fromVBRP

Hi All,

Below query is taking more time.

SELECT fkimg matnr werks edatu
FROM vbrp
INTO TABLE gt_vbrp
FOR ALL ENTRIES IN zimport_matnr
WHERE matnr = zimport_matnr-matnr
AND edatu >= zstart_edatu
AND edatu <= zend_edatu
AND fkimg > 0.

Can someone help in getting time reduced for the above query.

SQL
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    May 03 at 09:16 AM
    -2

    Are you Interested in single records or multiple records?

    Add comment
    10|10000 characters needed characters exceeded

  • May 05 at 02:27 AM

    This is always going to take a long time as you are reading VBRP without the main key fields - VBELN and POSNR. You should look to read VBRK first based on some selections you can make and then read the VBRP for the records you retrieved. This will speed your selection considerably.

    Never a good idea to read an item table before reading the header table. You should read HEADER then ITEM or both if you have a join and have fields to select records on.

    Thanks

    Phil Cooley

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 03 at 10:04 AM

    We are selecting multiple records for last 4 years.. We are selection year by year.

    As you can see that we are having where condition on Non-key fields..

    We even tried with secondary index. but not helpful.

    Add comment
    10|10000 characters needed characters exceeded

    • Good Luck. You need to change your requirement to read the VBRK record first as I stated previously. Going down this path will not get the results you want.

  • May 05 at 01:20 AM

    Hi Vidyaprasanna,

    However, check the possibility to retrieve using primary key.

    Depends on the scenario implement ABAP Inner JOIN reading header Vs Item.

    Also consider working with SAP transaction ST05 (SQL trace) and analysing the explain.

    After that you can determine which secondary index is better for this scenario as well as If will be possible to implement %_HINTS...

    Regards,

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 03 at 11:52 AM

    Dear Vidhya,

    Try this,

    Data: zimp_mat type zimport_matnr-matnr.

    SELECT fkimg matnr werks edatu

    FROM vbrp
    INTO TABLE gt_vbrp
    FOR ALL ENTRIES IN zimport_matnr
    WHERE matnr = zimp_mat

    AND edatu >= zstart_edatu
    AND edatu <= zend_edatu
    AND fkimg > 0.

    Add comment
    10|10000 characters needed characters exceeded