2008 Jan 09 6:56 AM
I need to work out on a report that is continuously throwing Runtime error of Time Out. After debugging, i realised that its running in a Loop infinitely. And i suppose that would be causing timeout. Could anyone suggest a way to deal with such errors and solve them?
I need to work out on a report that is continuously throwing Runtime error of Time Out. After debugging, i realised that its running in a Loop infinitely. And i suppose that would be causing timeout. Could anyone suggest a way to deal with such errors and solve them?
2008 Jan 09 7:01 AM
Hi Divya,
Is it a Standard program or Z Program? If it is Z Program, paste the code inside loop.. endloop.
Regards,
Satish
2008 Jan 09 7:07 AM
Its a Z program...the code inside loop...endloop is as follows:
LOOP AT TCATSPM.
COUNT_TRANS = COUNT_TRANS + 1.
SELECT SINGLE RUECK FROM AFRU INTO AFRU-RUECK
WHERE CATSBELNR = TCATSPM-BELNR
AND STOKZ = TCATSPM-STOKZ. .
IF NOT SY-SUBRC IS INITIAL.
does record in error-pool exist ?
SELECT SINGLE * FROM AFRV
WHERE CATSBELNR = TCATSPM-BELNR.
Satz ist in Zielapplikation schon vorhanden
IF SY-SUBRC IS INITIAL.
DELETE TCATSPM.
COUNT_EXIST = COUNT_EXIST + 1.
ELSE.
CLEAR TCATSPM-TRANSFER.
MODIFY TCATSPM.
COUNT_UPDAT = COUNT_UPDAT + 1.
ENDIF.
ELSE.
DELETE TCATSPM.
COUNT_EXIST = COUNT_EXIST + 1.
ENDIF.
ENDLOOP.
2008 Jan 09 7:10 AM
Hi,
Keep Select Queries Outside the loop and use Read Statements inside the loop. Your Problem Will get resolved.
Regards,
Satish
2008 Jan 09 7:18 AM
As in, remove select query & use read statement instead? Or use select statement to fill a workarea or internal tab and then use read statement in the loop?
2008 Jan 09 7:24 AM
Hi,
Do like this
data: lv_lines type i.
describe table tcatspm lines lv_lines.
LOOP AT TCATSPM.
COUNT_TRANS = COUNT_TRANS + 1.
SELECT SINGLE RUECK FROM AFRU INTO AFRU-RUECK
WHERE CATSBELNR = TCATSPM-BELNR
AND STOKZ = TCATSPM-STOKZ. .
IF NOT SY-SUBRC IS INITIAL.
does record in error-pool exist ?
SELECT SINGLE * FROM AFRV
WHERE CATSBELNR = TCATSPM-BELNR.
Satz ist in Zielapplikation schon vorhanden
IF SY-SUBRC IS INITIAL.
DELETE TCATSPM.
COUNT_EXIST = COUNT_EXIST + 1.
ELSE.
CLEAR TCATSPM-TRANSFER.
MODIFY TCATSPM.
COUNT_UPDAT = COUNT_UPDAT + 1.
ENDIF.
ELSE.
DELETE TCATSPM.
COUNT_EXIST = COUNT_EXIST + 1.
ENDIF.
If COUNT_TRANS = lv_lines.
exit.
endif.
ENDLOOP.
2008 Jan 09 7:32 AM
Ok...Breaking the loop once it reaches its end...I shall try this code right away, and get back to you.
2008 Jan 09 8:26 AM
its still throwin a timeout....pointing at the very first select query in the loop...
2008 Jan 09 8:38 AM
Then try this
TYPES: BEGIN OF TY_RUECK,
RUECK TYPE AFRU-RUECK,
CATSBELNR TYPE AFRU-CATSBELNR,
STOKZ TYPE AFRU-STOKZ,
END OF TY_RUECK.
DATA: IT_RUECK TYPE TABLE OF TY_RUECK,
WA_RUECK TYPE TY_RUECK,
IT_AFRV TYPE TABLE OF AFRV,
WA_AFRV TYPE AFRV.
SELECT RUECK CATSBELNR STOKZ FROM AFRU INTO TABLE IT_RUECK
FOR ALL ENTRIES IN TCATSPM
WHERE CATSBELNR = TCATSPM-BELNR
AND STOKZ = TCATSPM-STOKZ.
IF SY-SUBRC = 0.
SELECT * FROM AFRV INTO TABLE IT_AFRV
FOR ALL ENTRIES IN TCATSPM
WHERE CATSBELNR = TCATSPM-BELNR.
ENDIF.
SORT IT_RUECK.
LOOP AT TCATSPM.
COUNT_TRANS = COUNT_TRANS + 1.
READ TABLE IT_RUECK INTO WA_RUECK WITH KEY CATSBELNR = TCATSPM-BELNR STOKZ = TCATSPM-STOKZ BINARY SEARCH.
IF NOT SY-SUBRC IS INITIAL.
does record in error-pool exist ?
READ TABLE IT_AFRV INTO WA_AFRV WITH KEY CATSBELNR = TCATSPM-BELNR.
Satz ist in Zielapplikation schon vorhanden
IF SY-SUBRC IS INITIAL.
DELETE TCATSPM.
COUNT_EXIST = COUNT_EXIST + 1.
ELSE.
CLEAR TCATSPM-TRANSFER.
MODIFY TCATSPM.
COUNT_UPDAT = COUNT_UPDAT + 1.
ENDIF.
ELSE.
DELETE TCATSPM.
COUNT_EXIST = COUNT_EXIST + 1.
ENDIF.
Regards,
Satish
2008 Jan 09 8:47 AM
ok..now you replaced select queries with read statement, the method you suggested earlier...I too coded similar to the code you wrote, with slight changes. Anyways, trying to run the code you gave now.
2008 Jan 09 9:04 AM
its still giving runtime (time out) on the same query:
SELECT SINGLE RUECK FROM AFRU INTO AFRU-RUECK
WHERE CATSBELNR = TCATSPM-BELNR
AND STOKZ = TCATSPM-STOKZ.
What could be taking time in this?Total entries in afru are around 2.521.450 and the total entries in TCATSPM comes out to 2.445.804... Could it be this huge amount of data access in the code that causes time out? how could this be handled?I think basis wil have to set some memory parameters and increase them.... It also gives msg "low memory..." during execution.
2008 Jan 09 10:49 AM
Hi Divya,
BTW, within your codes IF SY-SUBRC IS INITIAL.
In my opinion , it's not right.
2008 Jan 09 11:05 AM
tommy, that code is running fine... And I just checked report again. The report is fine. The problem is with the server. So its solved now. Thanks for the help and time Satish and Tommy!
2008 Jan 09 9:22 AM
Avoid using Select single..
Instead select all relevent data and retrieve first value by read statement..This will shift processing from database layer to your application layer.
Also try creating secondary index with specified field in your select query (this will be secondary index combined on both tables).
Regards,
Mohaiyuddin
2008 Jan 09 11:07 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |