COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
string is moved into the receiving item character position designated by the pointer value,
which is incremented by 1 after each character is moved.
◦ Overflowing the size of the receiving item
Overflow occurs if not all of the characters of a transfer string can be moved to the
receiving item. The overflow condition exists when the pointer value exceeds the size of
the receiving item during assignment of any transfer string or after completing assignment
of any transfer string except the last one. After assignment of the last transfer string, the
pointer value can be one character past the end of the receiving item, and overflow does
not occur unless there are leftover characters in the transfer string.
If the overflow condition exists, the string operation terminates immediately. Any remaining
characters in the current transfer string are ignored; any sending values not yet processed
are ignored.
• State of the Rest of result
After termination of the string operation, only the portion of the data item specified by result
that was referenced as described earlier is changed. That is, any portions preceding the first
character assigned or following the last character assigned retain their previous value.
When the execution of a STRING statement specifying a POINTER phrase terminates, either
normally or due to an overflow condition, the contents of the data item specified by pointer
contains a value equal to its initial value plus the total number of characters transferred into
the data item specified by result.
• Overflow Condition
When an overflow condition exists, execution of the STRING statement terminates at that point.
If the OVERFLOW phrase is specified, the imperative statement in that phrase is executed;
otherwise control passes directly to the end of the STRING statement.
• Overlapping Operands
If any part of the storage area referenced by result or of that referenced by pointer is
the same as the storage area referenced by any other identifier appearing in the STRING
statement, the execution of the STRING statement will produce unpredictable results.
• National Data Items and National Literals
If any of the data items part-1, delimiter, and result is a national data item or
national literal, then all of them must be national items.
In Example 137, STRING builds a single data item from several data items. Also see the examples
in UNSTRING.
Example 137 STRING Statement
Input:
WORKING-STORAGE SECTION.
77 PART-1 PIC X(10).
77 PART-2 PIC X(26).
77 PART-3 PIC X(10).
77 RESULT-1 PIC X(80) VALUE SPACES.
77 COUNT-1 PIC 99.
PROCEDURE DIVISION.
A10-START.
DISPLAY "ENTER PART-1 (MAX 10 NUMERIC CHARACTERS)"
ACCEPT PART-1
INSPECT PART-1 REPLACING ALL " " BY "0"
IF PART-1 NOT NUMERIC DISPLAY "NOT NUMERIC"
GO TO A10-START
END-IF
STRING 465










