2007 Dec 13 9:38 AM
Hi gurus,
Iv been optimizing this code.. inlcude workarea but still the same. It has 1000 records after retrieving the data from the select statement for less than 1 minute. It takes 10-12 mins in looping. I already debug it and PERFORM takes half a minute or less. So, I need to focus with the loop.
See the codes below.
[code]
SELECT (FIELD_LIST)
INTO CORRESPONDING FIELDS OF TABLE I_ZZUWT PACKAGE SIZE 1000
FROM ZZUWT CLIENT SPECIFIED
WHERE KUNNR IN SELR_KUNNR
AND RACCT IN SELR_RACCT
AND RASSC IN SELR_RASSC
AND RBUKRS IN SELR_RBUKRS
AND RDATLT IN SELR_RDATLT
AND RLDNR IN SELR_RLDNR
AND RPMAX IN SELR_RPMAX
AND RRCTY IN SELR_RRCTY
AND RVERS IN SELR_RVERS
AND RYEAR IN SELR_RYEAR
AND RCLNT IN MANDTTAB
GROUP BY (GROUP_LIST).
LOOP AT I_ZZUWT INTO ZZUWT .
ZZUWT = I_ZZUWT .
PERFORM PZZUWT USING I_ZZUWT-_COUNTER.
CLEAR: $RWTAB, ZZUWT .
CLEAR GLDBZ .
ENDLOOP.
ENDSELECT.
[/code]
2007 Dec 13 10:08 AM
hi,
1: avoid looping within a select statement,
2: try to read the database with an array fetch,
3: loop over internal table with field-symbols rather than workareas.
2007 Dec 13 10:08 AM
hi,
1: avoid looping within a select statement,
2: try to read the database with an array fetch,
3: loop over internal table with field-symbols rather than workareas.
2007 Dec 13 10:15 AM
can u paste the code what the perform is doing??
PERFORM PZZUWT USING I_ZZUWT-_COUNTER
may be u can optimise this.
2007 Dec 13 12:55 PM
Check SQL Trace of your problem
/people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
How long does the SELECT take, how many records are read, what is the minimal time per record. Check the explain, is an index used? or is it a full table scan?
A full table scan is o.k., if you read more the 10% of the table. If less then add
the client to the WHERE condition, if you really need all clients.
Read all clients from the T000 and add WHERE mandt in (...).
Siegfried
2007 Dec 13 1:22 PM
Hi,
do not use select and end-select!, try out the folowing:
SELECT (FIELD_LIST)
INTO CORRESPONDING FIELDS OF TABLE I_ZZUWT PACKAGE SIZE 1000
FROM ZZUWT CLIENT SPECIFIED
WHERE KUNNR IN SELR_KUNNR
AND RACCT IN SELR_RACCT
AND RASSC IN SELR_RASSC
AND RBUKRS IN SELR_RBUKRS
AND RDATLT IN SELR_RDATLT
AND RLDNR IN SELR_RLDNR
AND RPMAX IN SELR_RPMAX
AND RRCTY IN SELR_RRCTY
AND RVERS IN SELR_RVERS
AND RYEAR IN SELR_RYEAR
AND RCLNT IN MANDTTAB
GROUP BY (GROUP_LIST).
<b>if sy-subrc = 0.
LOOP AT I_ZZUWT INTO ZZUWT .
ZZUWT = I_ZZUWT .
PERFORM PZZUWT USING I_ZZUWT-_COUNTER.
CLEAR: $RWTAB, ZZUWT .
CLEAR GLDBZ .
ENDLOOP.
endif.</b>
Thanks and Regards,
sooness
2007 Dec 13 1:24 PM
To optimize this loop please follow these steps
1) remove the loop from the select and after the select use the loop.
2) don't use the CORRESPONDING FIELDS command, create the internal table as fields are selected from database table . It will increase the select performance.
Please send the code of PERFORM PZZUWT USING I_ZZUWT-_COUNTER.
2007 Dec 13 7:23 PM
Hi,
Avoid using SELECT...ENDSELECT.
Use FOR ALL ENTRIES rather or/ and put it into an internal table and use that internal table in the loop.
VJ
2007 Dec 14 5:01 AM
Hi,
Do a select into table statement. - This will fetch the entire content in one single go. Select-endselect will hit the database for every record!
then call the perform statement by passing the table content of the select statement.
You can loop inside the perform and do your modifications to the internal table.
Regards,
Shruthi
2007 Dec 14 5:42 PM
maui bayog,
The problem is most likely your subroutine (PERFORM). By your own admission it takes half a minute (30 seconds) to execute. For 1000 records this is multiplied by 1000. For all the 1000 records, execution of the subroutine itself should take 30,000 seconds.
If you post the subroutine code we could help you.
2007 Dec 19 3:54 AM
Hi Mark,
I wanted to but It's too long to paste it... perform has several perform routines a I go through the inner routines these programs are SAP Standards. That's why I'm hesitant to edit the affected areas.
2007 Dec 19 2:34 PM
Use transaction SE30 to analyse the persormance of the subroutine. It will give you a good idea which of the subroutine called withing the subroutine in question causes the performace to degrade. You can then send us the code in that subroutine and we could help you.