A few things to point out here.
First COBOL subscripts start with 1 when referenceing table elements. If you are used to languages such as Java and C, subscripts generally start with 0. A subscript of 0 is out of bounds and can cause all kinds of wierd behaviour if you do not have bounds checking turned on.
Next, your condition for loop termination is wrong. You may be used to DO WHILE some-condition-is-true
. In
COBOL we generally PERFORM UNTIL some-condition-is-true
, meaning stop performing when the condition
becomes true. So look at:
PERFORM VARYING SUB FROM 0 BY 1 UNTIL SUB < TABLECOUNTER
DISPLAY 'BEFORE IF STATEMENT'
IF PROVM(SUB) <= P-PROVIDER AND
P-PROVIDER <= PTHRU(SUB) THEN
DISPLAY 'FOUND'
ADD 1 TO T-REC-FOUND
END-IF
END-PERFORM.
Since SUB
is initialized to zero, and I presume TABLECOUNTER
is 1 or greater, the condition is true so
the loop body is never executed.