‎2007 May 02 11:28 PM
I have an abap program that performs 20% better with a simple change in the structure of the if statement. Anyone got any explaination why this would be so? I would really appreciate any insight into this.
This code:
IF sy-tcode IN r_order_tcodes.
...some logic #1....
ELSEIF sy-batch EQ 'X' OR
( sy-cprog = 'ZSR_ECAT_GENERATE_V3' ).
...some logic #1....
ENDIF.
executes 20% faster than this code:
IF sy-tcode IN r_order_tcodes OR
sy-tcode IN r_ecat_tcodes OR
( sy-batch EQ 'X' AND
( sy-cprog EQ 'ZSR_GENERATE_ECAT_V3' OR
sy-cprog EQ 'ZSR_ECAT_SINGLE_CONFIG'
)
).
...some logic #1...
endif.
Thanks.
Scott
‎2007 May 03 7:27 AM
hi,
it's giving 20% more performance because in this case it's checking only one condition at a time. i.e. IF sy-tcode IN r_order_tcodes,if this is satisfied then it won't check else condition.
In the second case it has to check all the conditions.
IF sy-tcode IN r_order_tcodes OR
sy-tcode IN r_ecat_tcodes OR
( sy-batch EQ 'X' AND
( sy-cprog EQ 'ZSR_GENERATE_ECAT_V3' OR
sy-cprog EQ 'ZSR_ECAT_SINGLE_CONFIG'
)
).her it has to check all the conditions specified in the if.
so performance will be decreased
if helpful reward points
‎2007 May 02 11:58 PM
Hi,
I believe the tcodes in r_order_tcodes and r_ecat_tcodes will have the same programs given in the else condition...
Looks like This following simple IF statement will work for all the scenarios..
Try this..
IF SY-CPROG = 'ZSR_GENERATE_ECAT_V3' OR
SY-CPROG = 'ZSR_ECAT_SINGLE_CONFIG'.
...some logic #1....
ENDIF.
Thanks,
Naren
‎2007 May 03 7:27 AM
hi,
it's giving 20% more performance because in this case it's checking only one condition at a time. i.e. IF sy-tcode IN r_order_tcodes,if this is satisfied then it won't check else condition.
In the second case it has to check all the conditions.
IF sy-tcode IN r_order_tcodes OR
sy-tcode IN r_ecat_tcodes OR
( sy-batch EQ 'X' AND
( sy-cprog EQ 'ZSR_GENERATE_ECAT_V3' OR
sy-cprog EQ 'ZSR_ECAT_SINGLE_CONFIG'
)
).her it has to check all the conditions specified in the if.
so performance will be decreased
if helpful reward points