04-21-2008 2:45 PM
Hi,
Is there any way to improve Performance other than the loop statement..
FORM first_working_day.
DATA: save40(1).
CLEAR: firstday, save40.
LOOP AT it_p0041 INTO wa_p0041.
CLEAR f_date.
DO 12 TIMES
VARYING f_date FROM wa_p0041-dar01 NEXT wa_p0041-dar02.
IF f_date-dar EQ '40'.
firstday = f_date-dat.
save40 = 'X'.
ENDIF.
ENDDO.
ENDLOOP.
IF save40 IS INITIAL.
PERFORM error_list USING 'PA0041' text-e09.
ENDIF.
04-21-2008 2:48 PM
Avoid using subroutines within processing loop statements..
<REMOVED BY MODERATOR>
Dara
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:38 PM
04-21-2008 2:51 PM
Instead of loop .. endloop ..
read it_p0041 INTO wa_p0041 using key
FORM first_working_day.
DATA: save40(1).
CLEAR: firstday, save40.
read table it_p0041 INTO wa_p0041
with key = <pernr> ...
if sy-subrc = 0.
DO 12 TIMES
VARYING f_date FROM wa_p0041-dar01 NEXT wa_p0041-dar02.
IF f_date-dar EQ '40'.
firstday = f_date-dat.
save40 = 'X'.
EXIT.
ENDIF.
ENDDO.
ENDIF.
IF save40 IS INITIAL.
PERFORM error_list USING 'PA0041' text-e09.
ENDIF.
or change your coding as ...
FORM first_working_day.
DATA: save40(1).
CLEAR: firstday, save40.
LOOP AT it_p0041 INTO wa_p0041
where pernr = <pernr>. <--pass pernr
CLEAR f_date.
DO 12 TIMES
VARYING f_date FROM wa_p0041-dar01 NEXT wa_p0041-dar02.
IF f_date-dar EQ '40'.
firstday = f_date-dat.
save40 = 'X'.
EXIT. <-- exit ...
ENDIF.
ENDDO.
ENDLOOP.
IF save40 IS INITIAL.
PERFORM error_list USING 'PA0041' text-e09.
ENDIF
04-21-2008 2:58 PM
Hi Krishna,
to improve performance you could in general use field-symbols.
FORM first_working_day.
DATA: save40(1).
Field-symbols: <FS_p0041> TYPE wa_p0041.
CLEAR: firstday, save40.
LOOP AT it_p0041 assigning <FS_p0041>.
CLEAR f_date.
DO 12 TIMES
VARYING f_date FROM <FS_p0041>-dar01 NEXT <FS_p0041>-dar02.
...
Kind regards
Axel
04-21-2008 8:43 PM
1. If u can use READ instead of LOOP. Please use READ.
2. If you can use statement ASSIGNING use that insted of INTO wa.
A
04-22-2008 9:48 AM
Hi,
please analyse the program context:
can you read the table with a specific key?
If yes - apply the statement read table ... or loop at ... where ...
If you are dealing with mass data (table size higher then 200 records) and key access take special care of your table-type definitions (use hashed table) and table key-definitions.
Field access with field symbols always shows better performance.
Kind regards,
Axel
04-22-2008 10:07 AM
HI.
LOOP AT it_p0041 INTO wa_p0041
WHERE pernr = pernr.
CLEAR f_date.
DO 12 TIMES
VARYING f_date FROM wa_p0041-dar01 NEXT wa_p0041-dar02.
IF f_date-dar EQ '40'.
firstday = f_date-dat.
save40 = 'X'.
EXIT.
ENDIF.
if f_date-dar is initial
exit
endif
ENDDO.
ENDLOOP.
Regards,
Vamshi.