Application Development 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: 

Time_out - Time limit exceed - Error

Former Member
0 Kudos

Hi,

The following code gives the Time_out run time error.

LOOP AT i_outtab.

IF p_cust = 'X'.

Select single kunnr from vbak into sales_cust

where kunnr = i_outtab-kunnr

and ERDAT GE date.

IF sy-subrc NE 0.

DELETE i_outtab INDEX sy-tabix.

CONTINUE.

ENDIF.

ENDIF.

i_outtab1-kunnr = i_outtab-kunnr.

i_outtab1-name1 = i_outtab-name1.

i_outtab1-land1 = i_outtab-land1.

i_outtab1-ernam = i_outtab-ernam.

i_outtab1-vkorg = i_outtab-vkorg.

i_outtab1-vtweg = i_outtab-vtweg.

i_outtab1-spart = i_outtab-spart.

APPEND i_outtab1.

CLEAR i_outtab1.

ENDLOOP.

However, if the select query is omitted when the condition fails, the performance of the program is fast. Only because of this select query, it goes to run time error.

What is the issue?

Thanks,

Ezhil

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ezhilhrh,

Please see the code below. I have removed the select query from the loop.

IF p_cust = 'X'.

DATA: TEMP_ITAB LIKE TABLE OF I_OUTTAB OCCURS 0

WITH HEADERLINE.

Select single kunnr from vbak into table temp_itab

for all entries in i_outtab

where kunnr = i_outtab-kunnr

and ERDAT GE date.

IF sy-subrc EQ 0.

i_outtab[] = temp_itab[]

SORT I_OUTTAB BY KUNNR.

LOOP AT i_outtab.

READ TABLE TEMP_ITAB WITH KEY KUNNR = I_OUTTAB-KUNNR BINARY SEARCH.

IF SY-SUBRC EQ 0.

i_outtab1-kunnr = TEMP_ITAB -kunnr.

i_outtab1-name1 = i_outtab-name1.

i_outtab1-land1 = i_outtab-land1.

i_outtab1-ernam = i_outtab-ernam.

i_outtab1-vkorg = i_outtab-vkorg.

i_outtab1-vtweg = i_outtab-vtweg.

i_outtab1-spart = i_outtab-spart.

APPEND i_outtab1.

CLEAR i_outtab1.

ELSE.

DELETE i_outtab INDEX sy-tabix.

CONTINUE.

ENDIF.

ENDLOOP.

ENDIF.

This code will improve your performance as well.

Regards,

Md Ziauddin.

8 REPLIES 8

Former Member
0 Kudos

hi,

I would suggest as an developer to never use select query inside LOOP till there is no other option.

you can use read table .

Edited by: gaurav.singh on May 12, 2010 1:35 PM

Edited by: gaurav.singh on May 12, 2010 1:37 PM

Former Member
0 Kudos

Hi ,

Kindly Have an additional internal table for Storing the Customer(KUNNR) and Date (ERDAT) With respect to Salesorder Number ,

First with an " for all entries " fill ur internal table with respect to ur current Out_tab.

Instead of giving selct single (hitting the D.base each time ) have ur Second internal table to be read instead of that( reading from table using slect single)

this will obviously reduce ur Time taken and improve ur performance.

Thanks,

Muthu.

former_member192616
Active Contributor
0 Kudos

Hi,

don't read VBAK with kunnr. Instead read SAP note:

185530 Performance: Customer Developments in SD

in order to see which tables to read instead...

Kind regards,

Hermann

0 Kudos

>

> don't read VBAK with kunnr. Instead read SAP note

)

0 Kudos

Quite fortunately he provided the primary key to the SAP note

Former Member
0 Kudos

Hi Ezhilhrh,

Please see the code below. I have removed the select query from the loop.

IF p_cust = 'X'.

DATA: TEMP_ITAB LIKE TABLE OF I_OUTTAB OCCURS 0

WITH HEADERLINE.

Select single kunnr from vbak into table temp_itab

for all entries in i_outtab

where kunnr = i_outtab-kunnr

and ERDAT GE date.

IF sy-subrc EQ 0.

i_outtab[] = temp_itab[]

SORT I_OUTTAB BY KUNNR.

LOOP AT i_outtab.

READ TABLE TEMP_ITAB WITH KEY KUNNR = I_OUTTAB-KUNNR BINARY SEARCH.

IF SY-SUBRC EQ 0.

i_outtab1-kunnr = TEMP_ITAB -kunnr.

i_outtab1-name1 = i_outtab-name1.

i_outtab1-land1 = i_outtab-land1.

i_outtab1-ernam = i_outtab-ernam.

i_outtab1-vkorg = i_outtab-vkorg.

i_outtab1-vtweg = i_outtab-vtweg.

i_outtab1-spart = i_outtab-spart.

APPEND i_outtab1.

CLEAR i_outtab1.

ELSE.

DELETE i_outtab INDEX sy-tabix.

CONTINUE.

ENDIF.

ENDLOOP.

ENDIF.

This code will improve your performance as well.

Regards,

Md Ziauddin.

0 Kudos

Hi,

> Please see the code below. I have removed the select query from the loop.

>

>

> IF p_cust = 'X'.

>

> DATA: TEMP_ITAB LIKE TABLE OF I_OUTTAB OCCURS 0

> WITH HEADERLINE.

>

> Select single kunnr from vbak into table temp_itab

> for all entries in i_outtab

> where kunnr = i_outtab-kunnr

> and ERDAT GE date.

>

> IF sy-subrc EQ 0.

>

> i_outtab[] = temp_itab[]

>

> SORT I_OUTTAB BY KUNNR.

>

> LOOP AT i_outtab.

>

> READ TABLE TEMP_ITAB WITH KEY KUNNR = I_OUTTAB-KUNNR BINARY SEARCH.

> IF SY-SUBRC EQ 0.

> i_outtab1-kunnr = TEMP_ITAB -kunnr.

> i_outtab1-name1 = i_outtab-name1.

> i_outtab1-land1 = i_outtab-land1.

> i_outtab1-ernam = i_outtab-ernam.

> i_outtab1-vkorg = i_outtab-vkorg.

> i_outtab1-vtweg = i_outtab-vtweg.

> i_outtab1-spart = i_outtab-spart.

> APPEND i_outtab1.

> CLEAR i_outtab1.

> ELSE.

> DELETE i_outtab INDEX sy-tabix.

> CONTINUE.

> ENDIF.

> ENDLOOP.

> ENDIF.

>

> This code will improve your performance as well.

are you sure?

Kind regards,

Hermann

0 Kudos

Hi Hermann,

Yes I am sure,

With one correction i.e., to remove single statement from the select query.

Regards,

Md Ziauddin.