Coding Examples
The following examples illustrate some uses for the ALPHABET clause.
If PROGRAM COLLATING SEQUENCE IS USER-SEQUENCE; if the alphabet-name clause
is specified as USER-SEQUENCE IS “D”, “E”, “F”; and
if two Data Division items are defined as follows:
77 ITEM-1 PIC X(3) VALUE "ABC".
77 ITEM-2 PIC X(3) VALUE "DEF".
then the following comparison is true:
IF ITEM-1 > ITEM-2
Characters D, E, and F are in ordinal positions 1, 2, and 3 of this collating sequence. Characters A, B, and C are in ordinal positions 197, 198, and 199 of this collating sequence.
If the alphabet-name clause is USER-SEQUENCE IS 1 THRU 247, 251 THRU 256, “7”,
ALSO “8”, ALSO “9”; if all 256 EBCDIC characters have been
specified; and if the two Data Division items are specified as follows:
77 ITEM-1 PIC X(3) VALUE HIGH-VALUE.
77 ITEM-2 PIC X(3) VALUE "789".
then both of the following comparisons are true:
IF ITEM-1 = ITEM-2 . . .
IF ITEM-2 = HIGH-VALUE . . .
They compare as true because the values “7”, “8”, and “9” all occupy the same position (HIGH-VALUE) in this USER-SEQUENCE collating sequence.
If the alphabet-name clause is specified as USER-SEQUENCE IS “E”, “D”, “F”and
a table in the Data Division is defined as follows:
05 TABLE A OCCURS 6 ASCENDING KEY IS
KEY-A INDEXED BY INX-A.
10 FIELD-A ...
10 KEY-A ...
and if the contents in ascending sequence of each occurrence of KEY-A are A, B, C, D, E, G, then the results of the execution of a SEARCH ALL statement for this table will be invalid because the contents of KEY-A are not in ascending order. The proper ascending order would be E, D, A, B, C, G.