6.2.37.6 Data Flow
When the STRING statement is executed, data is transferred from the
sending fields to the receiving field. The order in which sending fields
are processed is the order in which they are specified. The following
rules apply:
- Characters from the sending fields are transferred to the receiving
field, according to the rules for alphanumeric to alphanumeric
elementary moves, except that no space filling is provided (see "MOVE
Statement" in topic 6.2.24).
- When DELIMITED BY identifier/literal is specified, the contents of
each sending item are transferred, character-by-character, beginning
with the leftmost character and continuing until either:
- A delimiter for this sending field is reached (the delimiter
itself is not transferred), or
- The rightmost character of this sending field has been
transferred.
- When DELIMITED BY SIZE identifier is specified, each entire sending
field is transferred to the receiving field.
- When the receiving field is filled, or when all the sending fields
have been processed, the operation is ended.
- When the POINTER phrase is specified, an explicit pointer field is
available to the COBOL user to control placement of data in the
receiving field. The user must set the explicit pointer's initial
value, which must not be less than 1 and not more than the character
count of the receiving field. (Note that the pointer field must be
defined as a field large enough to contain a value equal to the length
of the receiving field plus 1; this precludes arithmetic overflow when
the system updates the pointer at the end of the transfer.)
- When the POINTER phrase is not specified, no pointer is available to
the user. However, a conceptual implicit pointer with an initial
value of 1 is used by the system.
- Conceptually, when the STRING statement is executed, the initial
pointer value (explicit or implicit) is the first character position
within the receiving field into which data is to be transferred.
Beginning at that position, data is then positioned,
character-by-character, from left to right. After each character is
positioned, the explicit or implicit pointer is increased by 1. The
value in the pointer field is changed only in this manner. At the end
of processing, the pointer value always indicates a value equal to one
character beyond the last character transferred into the receiving
field.
Note: Subscript, reference modification, variable-length or variable
location calculations, and function evaluations are performed only once,
at the beginning of the execution of the STRING statement. Therefore, if
identifier-3 or identifier-4 is used as a subscript, reference-modifier,
or function argument in the STRING statement, or affects the length or
location of any of the identifiers in the STRING statement, these values
are determined at the beginning of the STRING statement, and are not
affected by any results of the STRING statement.
After STRING statement execution is completed, only that part of the
receiving field into which data was transferred is changed. The rest of
the receiving field contains the data that was present before this
execution of the STRING statement.
When the following STRING statement is executed, the results obtained will
be like those illustrated in Figure 18.
STRING ID-1 ID-2 DELIMITED BY ID-3
ID-4 ID-5 DELIMITED BY SIZE
INTO ID-7 WITH POINTER ID-8
END-STRING
ID_1 at execution ID_2 at execution ID_4 at execution ID_5 at execution
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
| 1| 2| 3| *| 4| 5| | A| *| B| C| | 6| 7| 8| 9| *| 0| | D| E| *| F| G|
|__|__|__|__|__|__| |__|__|__|__| |__|__|__|__|__|__| |__|__|__|__|__|
|___ ____| |_ | |________ ________| |_______ ______|
First group of Second group of Third group of Fourth group of
characters moved characters moved characters moved characters moved
| | |
|_____________ | ________________| |
| | | __________________|
ID_3 | | | |
(delimiter)
at execution ________ __ _________________ ______________
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
| *| | 1| 2| 3| A| 6| 7| 8| 9| *| 0| D| E| *| F| G| Z| Z| Z| Z| Z| Z|
|__| |__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|__|
ID_7 after execution (initialized to ALL Z before execution)
ID_8
(pointer)
after execution
__ __
| 1| 6|
|__|__|
(initialized to 01 before execution)
Figure 18. STRING Statement Execution Results
© Copyright IBM Corp. 1991, 1998
IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.
Return to library:
z/OS |
z/OS.e |
TPF |
z/VSE |
z/VM |
IBM Hardware |
IBM System z Redbooks
Glossary:
IBM terminology
Publications:
How to order publications
Readers:
Download IBM Library Reader |
Download IBM Softcopy Reader |
Download Adobe® Acrobat® Reader®
Library management:
Download IBM Softcopy Librarian
Contacts:
Contact z/OS
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks
of Adobe Systems incorporated.