Skip to Content
0

Select taking more time when selecting data fromVBRP

May 03 at 06:51 AM

63

avatar image
Former Member

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
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

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

Are you Interested in single records or multiple records?

Share
10 |10000 characters needed characters left characters exceeded
Phil Cooley May 05 at 02:27 AM
3

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

exactly, we are talking about Best practices!

Regards

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

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.

Show 1 Share
10 |10000 characters needed characters left 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.

0
ROBERTO Forti Santos May 05 at 01:20 AM
0

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,

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 03 at 11:52 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded