The SCAN statement examines a contiguous portion of character data in an array row, one character at a time, in a left-to-right direction.
<scan statement>
── SCAN ──<source>──<scan part>────────────────────────────────────────┤
For more information on <source> and <scan part>, see REPLACE Statement.
The source is always a pointer expression, and at the completion of the SCAN statement the final value of the stack-source-pointer can be stored in a pointer variable.
The scan part is basically a testing operation that determines when the SCAN statement is to stop. The scan part can specify that scanning is to stop after a given number of source characters, or when a source character fails or passes a specified test.
The count part is used in a scan part when a limited number of source characters are to be scanned. A residual count can be used, in which case the value of the remaining count is stored in the specified simple arithmetic variable at the completion of the SCAN statement.
The relational operator in the condition option specifies the comparison to be made between the arithmetic expression and the source characters. The arithmetic expression can be of any valid form, but most often takes the form of a one-character string literal.
Before the scan operation begins, the arithmetic expression in the condition option is evaluated, and the value of bit [7:8] or [3:4] (depending on the character size of the source pointer) of the arithmetic expression is assigned to the stack-source-operand.

