CUS-SUB had value of 13
PERFORM VARYING CUS-NDX FROM CUS-SUB BY +1
UNTIL CUSTOMER-NOT-FOUND
OR CUST-RANGE-FND
IF CUS-NBR (CUS-NDX) = EMRC-EMR-SERVD-ENT-PHNUM
SET WS-DISP-INX TO CUS-NDX
DISPLAY 'CUS-NDX VALUE=' WS-DISP-INX
SET CUST-RANGE-FND TO TRUE
ELSE
IF CUS-NBR (CUS-NDX) > EMRC-EMR-SERVD-ENT-PHNUM
SET CUSTOMER-NOT-FOUND TO TRUE
END-IF
END-IF
END-PERFORM
SET WS-DISP-INX TO CUS-NDX
DISPLAY 'CUS-NDX VALUE=' WS-DISP-INX
UNTIL CUSTOMER-NOT-FOUND
OR CUST-RANGE-FND
IF CUS-NBR (CUS-NDX) = EMRC-EMR-SERVD-ENT-PHNUM
SET WS-DISP-INX TO CUS-NDX
DISPLAY 'CUS-NDX VALUE=' WS-DISP-INX
SET CUST-RANGE-FND TO TRUE
ELSE
IF CUS-NBR (CUS-NDX) > EMRC-EMR-SERVD-ENT-PHNUM
SET CUSTOMER-NOT-FOUND TO TRUE
END-IF
END-IF
END-PERFORM
SET WS-DISP-INX TO CUS-NDX
DISPLAY 'CUS-NDX VALUE=' WS-DISP-INX
Output:
CUS-NDX VALUE= 13
CUS-NDX VALUE= 14
When I execute this code, the value of WS-DISP-INX displayed as 13 inside the perform and displayed as 14 outside the PERFORM statement..
How the counter value has been incremented?.. Is it right??
I thought index value will come as 13 outside the perform statement..
Because based on the indexed value, am doing subsequent operation further in my program...
please help me why the index field got different values..