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: 

Performance issue

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

Avoid using subroutines within processing loop statements..

<REMOVED BY MODERATOR>

Dara

Edited by: Alvaro Tejada Galindo on Apr 21, 2008 3:38 PM

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.