Hi Experts,
The below is the code I am writing the comd for user exit variable.
The variable is working as expected but to improve the performance need few inputs from you to optimize the code.
How can I modify the code as per below.
Currently all the read statements will execute inside the loop…I want to modify
IF 1ST Read is successful then the remaining 4 reads shouldn’t execute
IF 1st Read is NOT successfully then it should perform 2nd Read, if 2nd read is successfully then reads 3,4 & 5 shouldn’t be executed
IF 1st ,2nd Reads are NOT successfully then it should perform 3rd Read, if 3rd read is successfully then reads 4 & 5 shouldn’t be executed.
IF 1st ,2nd, ,3rd Reads are NOT successfully then it should perform 4th Read, if 4th read is successfully then read 5 shouldn’t be executed.
IF 1st ,2nd, ,3rd, 4th Reads are NOT successfully then it should perform 5th Read
Please advise
LOOP AT IT_TPCTR INTO WA_IT_TPCTR.
*Read - 1
READ TABLE IT_STORES INTO WA_IT_STORES
WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXSEGMT.
IF SY-SUBRC = 0.
L_S_RANGE-LOW = WA_IT_TPCTR-PROFIT_CTR.
INSERT L_S_RANGE INTO TABLE E_T_RANGE.
ENDIF.
*Read - 2
READ TABLE IT_STORES INTO WA_IT_STORES
WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXSUBSG.
IF SY-SUBRC = 0.
L_S_RANGE-LOW = WA_IT_TPCTR-PROFIT_CTR.
INSERT L_S_RANGE INTO TABLE E_T_RANGE.
ENDIF.
*Read-3
READ TABLE IT_STORES INTO WA_IT_STORES
WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXBUSA.
IF SY-SUBRC = 0.
L_S_RANGE-LOW = WA_IT_TPCTR-PROFIT_CTR.
INSERT L_S_RANGE INTO TABLE E_T_RANGE.
ENDIF.
*Read-4
READ TABLE IT_STORES INTO WA_IT_STORES
WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXCTRCT.
IF SY-SUBRC = 0.
L_S_RANGE-LOW = WA_IT_TPCTR-PROFIT_CTR.
INSERT L_S_RANGE INTO TABLE E_T_RANGE.
ENDIF.
*Read 5
READ TABLE IT_STORES INTO WA_IT_STORES
WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXSITE.
IF SY-SUBRC = 0.
L_S_RANGE-LOW = WA_IT_TPCTR-PROFIT_CTR.
INSERT L_S_RANGE INTO TABLE E_T_RANGE.
ENDIF.
ENDLOOP.
Thanks in advance