COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-281
UNSTRING
•
National Data Items and National Literals
If any of the data items delim-1, delim-2, result, or delimstore is a 
national data item or national literal, then all of them must be national items.
In Example 9-70, UNSTRING breaks a data item into a collection of data items. 
UNSTRING uses the MOVE statement rules in transferring values into shorter data 
items.
In Example 9-71, UNSTRING separates a name, entered as it would be typed on a 
mailing envelope, into a last name and a remainder. You could use this mechanism to 
build records that can be sorted on last and first name.
Example 9-70. UNSTRING Statement
Input:
DATA DIVISION.
WORKING-STORAGE SECTION.
77 SOURCE-STRING PIC X(18) VALUE "12345 MICKEY ABCDE".
77 UNPART-1 PIC X(3).
77 UNPART-2 PIC X(3).
77 UNPART-3 PIC X(3).
PROCEDURE DIVISION.
A10-START.
 UNSTRING SOURCE-STRING DELIMITED BY " "
 INTO UNPART-1 UNPART-2 UNPART-3
 DISPLAY "UNPART-1 = " UNPART-1
 DISPLAY "UNPART-2 = " UNPART-2
 DISPLAY "UNPART-3 = " UNPART-3
 STOP RUN.
Output:
>RUN RUNUNIT
UNPART-1 = 123
UNPART-2 = MIC
UNPART-3 = ABC
Example 9-71. UNSTRING Statement (page 1 of 2)
 WORKING-STORAGE SECTION.
 01 NAMES-TABLE.
 03 NAMES PIC X(50) OCCURS 10 TIMES
 INDEXED BY NAME-INDEX,
 FIRST-NAME-INDEX.
 01 WORK-GROUP.
 03 NAME-COUNT PIC 99 COMP.
 03 WHOLE-NAME PIC X(50).
 03 LAST-NAME PIC X(50).
 03 REST-OF-NAME PIC X(50).
 03 POINTER-1 PIC 99 COMP.
 ...










