Skip to Content
0
Former Member
Jul 02, 2007 at 12:35 PM

Time consuming in Loop ...

17 Views

Hi Experts,

Pl. have a look in the below program and explain why it takes long time in loop.

START-OF-SELECTION.

select * from mara client specified

into corresponding fields of table itab

where mandt = sy-mandt and matnr in matnr1

and matkl in ptype and mtart = 'ZFIN'.

sort itab by matnr.

select * from makt into corresponding fields of table it_makt

for all entries in itab where matnr = itab-matnr.

sort it_makt by matnr.

select * from a304 client specified

into corresponding fields of table it_a304

where mandt = sy-mandt and kschl = 'PR00'.

sort it_a304 by matnr.

select * from konp client specified

into corresponding fields of table it_konp

where mandt = sy-mandt and KSCHL = 'PR00'.

sort it_konp by knumh.

loop at itab.

it_out-matnr = itab-matnr.

it_out-matkl = itab-matkl.

read table it_makt with key matnr = itab-matnr.

it_out-maktx = it_makt-maktx.

read table it_a304 with key matnr = itab-matnr.

it_out-kschl = it_a304-kschl.

it_out-vkorg = it_a304-vkorg.

it_out-vtweg = it_a304-vtweg.

it_out-knumh = it_a304-knumh.

read table it_konp with key knumh = it_a304-knumh.

it_out-kbetr = it_konp-kbetr.

IF IT_OUT-KBETR <= '5.00'.

IT_OUT-FACTOR = IT_OUT-KBETR.

ELSE.

IT_OUT-FACTOR = ( IT_OUT-KBETR ) * '0.55'.

ENDIF.

APPEND IT_out.

endloop.