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

Select taking more time when selecting data fromVBRP

Former Member
1,482
  • SAP Managed Tags

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.

1 ACCEPTED SOLUTION
Read only

gaurav09
Explorer
0 Likes
1,345
  • SAP Managed Tags

Are you Interested in single records or multiple records?

7 REPLIES 7
Read only

gaurav09
Explorer
0 Likes
1,346
  • SAP Managed Tags

Are you Interested in single records or multiple records?

Read only

Former Member
1,345
  • SAP Managed Tags

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.

Read only

0 Likes
1,345
  • SAP Managed Tags

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.

Read only

gaurav09
Explorer
0 Likes
1,345
  • SAP Managed Tags

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.

Read only

roberto_forti
Contributor
1,345
  • SAP Managed Tags

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,

Read only

pjcools
SAP Champion
SAP Champion
1,345
  • SAP Managed Tags

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

Read only

1,345
  • SAP Managed Tags

exactly, we are talking about Best practices!

Regards