<source part list>
┌◄────── , ─────┐ ──┴─<source part>─┴────────────────────────────────────────────────────┤
<source part>
──┬─<string literal>─┬─────────────────────┬───────────────────────────┤ │ └─<unit count>────────┤ ├─<arithmetic expression>─┬──────────────┤ │ └─<unit count>─┤ ├─<digit convert part>───────────────────┤ ├─<numeric convert part>─────────────────┤ ├─<source>──<transfer part>──────────────┤ ├─<translate part>───────────────────────┤ ├─<pointer-valued attribute>─────────────┤ └─<string expression>────────────────────┘
<unit count>
── FOR ──<arithmetic expression>─┬─────────┬───────────────────────────┤
└─ WORDS ─┘
<digit convert part>
──<arithmetic expression>── FOR ─┬─<arithmetic expression>─┬───────────►
└─ * ─────────────────────┘
►─┬─ DIGITS ──┬────────────────────────────────────────────────────────┤
└─ SDIGITS ─┘
<numeric convert part>
──<arithmetic expression>── FOR ─┬─<count part>─┬─ NUMERIC ────────────┤
└─ * ──────────┘
<count part>
──┬──────────────────┬─<arithmetic expression>─────────────────────────┤ └─<residual count>─┘
<residual count>
──<simple variable>── : ───────────────────────────────────────────────┤
<source>
──┬──────────────────┬─<pointer expression>────────────────────────────┤ └─<update pointer>─┘
<transfer part>
──┬─<unit count>─────────────────┬─────────────────────────────────────┤ ├─ WITH ──<picture identifier>─┤ └─<scan part>──────────────────┘
<scan part>
──┬─────────────────────┬─<condition>──────────────────────────────────┤ └─ FOR ──<count part>─┘
<condition>
──┬─ WHILE ─┬─┬─<relational operator>──<arithmetic expression>─┬───────┤ └─ UNTIL ─┘ └─ IN ──<truth set table>────────────────────────┘
<truth set table>
──┬─<subscripted variable>────────────┬────────────────────────────────┤ ├─<truth set identifier>────────────┤ ├─<string literal>──────────────────┤ ├─ ( ──<membership expression>── ) ─┤ ├─ ALPHA ───────────────────────────┤ ├─ ALPHA7 ──────────────────────────┤ └─ ALPHA8 ──────────────────────────┘
<translate part>
──<source>── FOR ──<arithmetic expression>── WITH ──<translate table>──┤
<translate table>
──┬─<subscripted variable>───────┬─────────────────────────────────────┤ ├─<translate table identifier>─┤ └─<intrinsic translate table>──┘
<intrinsic translate table>
──┬─ ASCIITOEBCDIC ─┬──────────────────────────────────────────────────┤ ├─ ASCIITOHEX ────┤ ├─ EBCDICTOASCII ─┤ ├─ EBCDICTOHEX ───┤ ├─ HEXTOASCII ────┤ └─ HEXTOEBCDIC ───┘
The source part list consists of one or more source parts. Each source part specifies source data and the processing to be performed on the data. All the data specified by a single source part is processed by a single method, but the various source parts of the source part list can specify a variety of processing methods.
With certain forms of the source part, provisions are made to store the final value of the stack-source-pointer. With several source parts in a single REPLACE statement, several final values for the stack-source-pointer arise. Corresponding to these final values are values of the stack-destination-pointer. These latter values are not accessible to the programmer but serve as the initial values of the stack-destination-pointer for the processing of the next source part.
The syntactic construct <source> is the same construct encountered in the SCAN statement. The source construct contains a pointer expression that initializes the stack-source-pointer to a particular character position in an array row. The character size associated with this pointer expression must be the same as that associated with the pointer expression that initialized the stack-destination-pointer.
The stack-source-pointer and the stack-destination-pointer can both reference the same array during a REPLACE statement. However, if the stack-source-pointer references a character position between the initial position of the stack-destination-pointer and its current position, the result is undefined. For example, the following REPLACE statement produces an undefined result:
REPLACE POINTER(A)+6 BY POINTER(A) FOR 12
On the other hand, the following REPLACE statement produces a well-defined result:
REPLACE POINTER(A) BY POINTER(A) FOR 12

