Hi,
Iam having performance problem when running the below code. I have used nested loops and the outer loop have around 60,000 records and inner loop around 90,000 records. When I run the job its taking more than a day to complete. Can any one suggest how to improve the below code. Please dont give any docs or tutorials but suggest the improvement in below code.
___________________________________________________________________________________
DATA:w_output1 TYPE ty_output.
t_final_zuonr[] = t_output[].
SORT t_output BY bukrs zuonr.
DELETE ADJACENT DUPLICATES FROM t_final_zuonr COMPARING bukrs zuonr.
MESSAGE 'To find the categories based on zuonr(assignement number)' TYPE 'S'.
LOOP AT t_final_zuonr INTO w_output1.
LOOP AT t_output INTO w_output WHERE bukrs EQ w_output1-bukrs
AND zuonr EQ w_output1-zuonr.
IF w_output-augbl <> space.
w_output-rlc = '1'.
MODIFY t_output FROM w_output TRANSPORTING rlc WHERE bukrs = w_output-bukrs AND
zuonr = w_output-zuonr.
ENDIF.
IF w_output-rlc IS INITIAL.
CASE w_output-blart.
WHEN 'WE'.
v_blart = 'X'.
WHEN 'RE' OR 'RN'.
v_blart1 = 'X'.
ENDCASE.
IF v_blart = 'X'.
v_sum_3 = v_sum_3 + w_output-dmbtr.
ENDIF.
IF v_blart = 'X' AND
v_blart1 = 'X'.
w_output-rlc = '2'.
ELSEIF v_blart1 = 'X' AND
v_blart = ' ' AND
w_output-dmbtr GE 0.
w_output-rlc = '4'.
ELSEIF v_blart1 = 'X' AND
v_blart = ' ' AND
w_output-dmbtr LE 0.
w_output-rlc = '5'.
ELSEIF v_blart = 'X' AND
v_sum_3 LE 0.
w_output-rlc = '3'.
ELSEIF v_blart = 'X' AND
v_sum_3 GT 0.
w_output-rlc = '6'.
ELSE.
w_output-rlc = '7'.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR :v_blart,
v_blart1.
MODIFY t_output FROM w_output TRANSPORTING rlc WHERE bukrs = w_output-bukrs AND
zuonr = w_output-zuonr.
REFRESH t_zuonr.
ENDLOOP.
REFRESH t_final_zuonr.
MESSAGE 'Rlc category updated to output table' TYPE 'S'.
Best Regards
Suresh
_____________________________________________________________________________________