Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

ALPHABET clause

Syntax rules

  1. If the literal phrase is specified in the ALPHABET clause, any given character for literal-1, literal-2 etc. which is referenced by alphabet-name in the PROGRAM COLLATING SEQUENCE clause (see section "OBJECT-COMPUTER paragraph") or in the COLLATING SEQUENCE phrase of the SORT or MERGE statement (see chapter "Procedure Division") may be used once only (see Example 6-10 and Example 6-11).

  2. The words THROUGH and THRU are equivalent.

  3. The NATIVE and EBCDIC phrases mean the same thing in BS2000.

General rules

  1. The ALPHABET clause provides a means for relating a name to a particular character set and/or alphanumeric collating sequence. When referenced in the PROGRAM COLLATING SEQUENCE clause (see section "OBJECT-COMPUTER paragraph") or the COLLATING SEQUENCE phrase of a SORT or MERGE statement (see chapter "Procedure Division") alphabet-name specifies a collating sequence. When alphabet-name-1 is referenced in the SYMBOLIC-CHARACTERS clause or in a CODE-SET clause of a file description entry (for sequentially organized files), the ALPHABET clause specifies a character set.

    1. If the STANDARD-1 phrase is specified, the character set or collating sequence is that defined in the American National Standard Code for Information Interchange (ASCII), X3.4-1968.

    2. If the STANDARD-2 phrase is specified, the character set identified is the International Reference Version of the ISO 7-bit code, as defined in International Standard 646, "7-Bit Coded Character Set for Information Processing Interchange". Each character of the standard character set is associated with a corresponding character from the native character set.

    3. If the NATIVE or EBCDIC phrase is specified, the native character set or native collating sequence is used (EBCDIC).

    4. If the literal phrase of the ALPHABET clause is specified, the alphabet-name must not be referenced in a CODE-SET clause (see the section "CODE-SET clause").

      • The value of the literal specifies the ordinal number of a character (beginning with 1) within the native character set, if the literal is numeric. This value must not exceed the number of characters in the native character set (256).

      • The value of the literal specifies the actual character within the native character set, if the literal is alphanumeric. If the value of the alphanumeric literal contains multiple characters, each character in the literal is inserted into the collating sequence in the order specified (see Example 6-2).

      • The order in which the literals appear in the ALPHABET clause specifies, in ascending sequence, the ordinal number of the character within the collating sequence being specified (see Example 6-3).

      • All characters within the EBCDIC collating sequence which are not specified explicitly with the literal specification have a higher position in the collating sequence than each of the explicitly defined characters. The relative order within the set of these unspecified characters is unchanged from the EBCDIC collating sequence.

      • If the THROUGH/THRU phrase is specified, the set of contiguous characters in the EBCDIC character set beginning with the character specified by the value of literal-1, and ending with the character specified by the value of literal-2, is assigned a successive ascending position in the collating sequence being specified. In addition, the set of contiguous characters specified by a given THROUGH/THRU phrase may contain characters of the EBCDIC character set in either ascending or descending sequence (see Example 6-4).

      • If the ALSO phrase is specified, the characters of the EBCDIC character set specified by the value of literal-1 and literal-3 are assigned to the same ordinal position in the collating sequence being specified or in the character set (see Example 6-5).
        If alphabet-name-1 is referenced in a SYMBOLIC CHARACTERS clause, only literal-1 is used to represent the character in the EBCDIC character set.

  2. The character that has the highest ordinal position in the program collating sequence specified is associated with the figurative constant HIGH-VALUE. If more than one character has the highest position in the program collating sequence, the last character specified is associated with the figurative constant HIGH-VALUE (see Example 6-6 and Example 6-7).

  3. The character that has the lowest ordinal position in the program collating sequence specified is associated with the figurative constant LOW-VALUE. If more than one character has the lowest position in the program collating sequence, the first character specified is associated with the figurative constant LOW-VALUE (see Example 6-8 and Example 6-9).

Example 6-2

ALPHABET ALPHATAB IS "AJKCDF".

First character is A
Second character is J
.
.
Sixth character is F

Example 6-3

ALPHABET ALPHATAB IS "A" "C" "D" "Z".

First character in the collating sequence is "A"
Second character in the collating sequence is "C"
Third character in the collating sequence is "D"
Fourth character in the collating sequence is "Z"

Example 6-4

ALPHABET ALPHATAB IS "A" THRU "I".

First character is A
Second character is B
Third character is C
.
.
Eighth character is H
Ninth character is I

Example 6-5

ALPHABET ALPHATAB IS "A" ALSO "B" ALSO "C" ALSO "D".

The characters A, B, C, and D will be associated with the lowest ordinal positions in the collating sequence.

Example 6-6

ALPHABET ALPHATAB IS 193 THRU 1, 255 THRU 194.

The highest ordinal position in the collating sequence is occupied by the character that appears in the 194th position of the EBCDIC character set, i.e. the character A.A is associated with the figurative constant HIGH-VALUE.

Example 6-7

ALPHABET ALPHATAB IS 193 THRU 1, 255 THRU 197, "A" ALSO "B" ALSO "C".

Positions 1 through 193 of the collating sequence are associated with the characters which appear at positions 193 to 1 of the EBCDIC character set.

Positions 194 through 253 of the collating sequence are associated with the characters which appear at positions 255 to 197 of the EBCDIC character set.

Position 254 is assigned the characters A, B, C; with this all characters in the EBCDIC character set are associated with a position in the collating sequence. The highestorder position (254) is occupied by the characters A, B, C. Being the character specified last, C is associated with the figurative constant HIGH-VALUE.

Example 6-8

ALPHABET ALPHATAB IS "0" "1" "2".

The lowest ordinal character in the collating sequence is 0. Hence 0 is associated with the figurative constant LOW-VALUE.

Example 6-9

ALPHABET ALPHATAB IS "A" ALSO "B" ALSO "C".

The lowest ordinal position in the collating sequence is occupied by the characters A, B, C. The character A, which was specified first, is associated with the figurative constant LOW-VALUE.

Example 6-10

PROGRAM COLLATING SEQUENCE and ALPHABET clauses:


IDENTIFICATION DIVISION.
PROGRAM-ID. ABC.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
OBJECT-COMPUTER.
    PROGRAM COLLATING SEQUENCE IS ALPHATAB.
SPECIAL-NAMES.
    TERMINAL IS T
    ALPHABET ALPHATAB IS "X" "Y" "Z".
DATA DIVISION.
WORKING-STORAGE SECTION.
77  ITEM-1 PIC X(3) VALUE "ABC".
77  ITEM-2 PIC X(3) VALUE "XYZ".
PROCEDURE DIVISION.
MAIN.
    IF ITEM-1 > ITEM-2
    THEN
      DISPLAY "Collating sequence ok" UPON T
    END-IF
    STOP RUN.


With the definition of the alphabet-name ALPHATAB in the SPECIAL-NAMES paragraph, the character X was assigned to the first position in the collating sequence, Y to the second and Z to the third.

All remaining characters of the EBCDIC character set are assigned a position in the collating sequence implicitly, since their positions in the collating sequence are higher than those of the specified characters X, Y, Z and their order in the collating sequence was taken from the EBCDIC character set without alteration.

Positions 1 through 231 in the EBCDIC character set correspond to positions 4 through 234 in the collating sequence.

Positions 235 through 256 in the EBCDIC character set correspond to positions 235 through 256 in the collating sequence.

Thus, A occupies position 197, B position 198, and C position 199.

Hence, the relation ITEM-1 > ITEM-2 is true.

Example 6-11

PROGRAM COLLATING SEQUENCE and ALPHABET clauses:

IDENTIFICATION DIVISION.
PROGRAM-ID. ALPH.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
OBJECT-COMPUTER.
    PROGRAM COLLATING SEQUENCE IS ALPHA.
SPECIAL-NAMES.
    TERMINAL IS T
    ALPHABET ALPHA 1 THRU 247, 251 THRU 256
                   "7" ALSO "8" ALSO "9".
DATA DIVISION.

WORKING-STORAGE SECTION.
77  ITEM-1 PIC X(3) VALUE HIGH-VALUE.
77  ITEM-2 PIC X(3) VALUE "789".
PROCEDURE DIVISION.
P1 SECTION.
COMPARISON.
    IF ITEM-1 = ITEM-2 
    THEN 
      DISPLAY "First relation ok" UPON T
    ELSE 
      DISPLAY "First relation not ok" UPON T
    END-IF
    IF ITEM-2 = HIGH-VALUE 
    THEN
      DISPLAY "Second relation ok" UPON T
    ELSE 
      DISPLAY "Second relation not ok" UPON T
    END-IF.
FINISH-PAR.
    STOP RUN.


Characters less than 7 remain as in native collating sequence. Characters greater than 9 are then appended, thereby becoming less than 7.
The characters 7, 8, 9 are set at the highest ordinal position, with 9, being the last character specified, corresponding to "HIGH-VALUE".

Result:

First relation OK
Second relation OK