You must initialize identifier-2 before execution of the INSPECT statement begins.
So says the IBM Enterprise COBOL Language Reference, and the words will be similar in any COBOL manual.
identifier-2
is the target field of your TALLLYING.
If you do not set this to an initial value prior to the INSPECT, the current value will be used to add to (or not, in your case).
This is useful sometimes, but if you do not want to make use of it, you must set the identifier-2
field to zero before the INPSECT
.
In your case that would be, for example (you could also use INITIALIZE
, SET
an 88 which has a zero in the first position of its VALUE
clause, etc):
MOVE ZERO TO WS-COUNT
If you show your data-definitions, representative sample input and expected output, you may even get some hints about doing what it is that you want in a tidier way. If you tell us what it is you want.