Skip to Content
0
Former Member
May 11, 2010 at 05:09 AM

How to reduce nested if conditions

383 Views

Hi all,

Can you please tell me the alternative for the below code which is taking a long time for execution. the below code is for validating the quantity decimal places. If the decimal place is more than 3, it should show the error in the output. I have to validate 24 quantity fields in the report as mentioned below and i would be using 24 'IF' statements and 24 'ENDIF' statement which will take a long time. Please let me know what is the simple code to validate all the 24 quantity fields.

MOVE wa_excel-m1 TO v_qnty.

SPLIT v_qnty AT '.' INTO qty1 qty2.

IF ( STRLEN( qty2 ) LT 4 ).

MOVE wa_excel-m2 TO v_qnty1.

SPLIT v_qnty1 AT '.' INTO qty3 qty4.

IF ( STRLEN( qty4 ) LT 4 ).

MOVE wa_excel-m3 TO v_qnty2.

SPLIT v_qnty2 AT '.' INTO qty5 qty6.

ELSE.

CONCATENATE text-036 wa_excel-m15 text-037 INTO wa_final_test-remarks SEPARATED BY space.

rec_rej = rec_rej + 1.

rec_chek = rec_chek + 1.

PERFORM final_output.

ENDIF.

ELSE.

CONCATENATE text-036 wa_excel-m1 text-037 INTO wa_final_test-remarks SEPARATED BY space.

rec_rej = rec_rej + 1.

rec_chek = rec_chek + 1.

PERFORM final_output.

ENDIF.

ENDIF.