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 query - Time out error

Former Member
0 Likes
1,849

Hello Experts,

Please help me this below query. If I ran the program, it will take so much time to execute the below query and its goes to time out.

Please help me.

SELECT mvgr1 "Line of Business

werks "Plant

lgort "Storage Location

charg "Batch

matnr "Material Number

kwmeng "Ordered quantity

posnr "Item

vbeln "Sales Order Number

FROM vbap

INTO TABLE gt_salesdatatemp

FOR ALL ENTRIES IN gt_matmerge

WHERE matnr EQ gt_matmerge-matnr

AND werks EQ gt_matmerge-werks

AND mvgr1 EQ gt_matmerge-mvgr1

AND lgort EQ gt_matmerge-lgort

AND charg EQ gt_matmerge-charg

AND abgru EQ space.

Thanks in advance.

9 REPLIES 9
Read only

former_member195698
Active Contributor
0 Likes
1,150

one solution can be creation of secondary index on the table VBAP for the selection fields

Read only

sachin_mathapati
Contributor
0 Likes
1,150

Hi Srivalli,

1. If the select query is giving time out error , then Run the report in background or.

2.Increase the Default Timeout level.(Contact BASIS)

Regards,

Sachin M M

Read only

ThomasZloch
Active Contributor
0 Likes
1,150

make use of index table VAPMA, which is essentially a reduced version of VBAP sorted by MATNR. You can obtain all desired fields via a JOIN of VBAP and VAPMA.

Thomas

Read only

alison_lloyd
Active Participant
0 Likes
1,150

Have you checked gt_matmerge isn't empty?

Make sure you haven't got any duplicates in gt_matmerge by fields used for selection

sort gt_matmerge by fields used for selection

Is there no staus field you can use on VBAP/ have you got anything to go to VBAK with first?

Consider splitting into groups i.e. select for each 50000 entries and append lines

Read only

Former Member
0 Likes
1,150

Hi,

have u done this check?

if not gt_salesdatatemp[] is initial.

select ....

endif.

if it is empty, it will fetch all the data from vbap.

regards,

madhu

Read only

Former Member
0 Likes
1,150

Hi,

If the number of records to be fetched is very very high then you can use the cursor concept.

Please see the below code.

=====

OPEN CURSOR dbcur FOR SELECT .... FROM ....... WHERE ...... .

DO.

FETCH NEXT CURSOR dbcur INTO TABLE itab PACKAGE SIZE 10000.

IF sy-subrc NE 0.

EXIT.

ENDIF.

ENDDO.

CLOSE CURSOR dbcur.

=====

Using this concept you can fetch the data in packets.

Additionally, you can take care of the following points to have better performance.

a. Check that your query is using the index.

b. Check that the internal table is not initial. If it is initial then the select will happen for all records in the DB.

Regards,

Saurabh

Read only

Former Member
0 Likes
1,150

hi dear

u r using VBAP sales document item data table..which is large one. so check ur when clause correctly..

check whether u used correct primary keys and those keys must b in correct sequence as well.. remove unneccesary when clause. and use table VBRK for header info corresponding to VBRP.

regds

jigar

Read only

Former Member
0 Likes
1,150

Hi Srivalli,

I have same issue with the same query, Please let me know your solution on this if your problem has solved. I request you to please give me a reply on it, Please dont ignore.

Regards,

Krishna Reddy

Read only

Former Member
0 Likes
1,150

Hi ,

first sort that internal table by ur where condition key fields and check whether gt_matmerge has some records or not and also you can use field symbol for referencing the for all entries .

fareed