COBOL Configuration Section

The Configuration Section defines special names, collating sequences, currency symbols, and other system-specific settings. Learn to configure program behavior through SPECIAL-NAMES and environment settings.

Basic Configuration Section

cobol
1
2
3
4
5
6
7
8
CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-390. OBJECT-COMPUTER. IBM-390. SPECIAL-NAMES. CONSOLE IS CRT PRINTER IS PRT CURRENCY SIGN IS '$' DECIMAL-POINT IS COMMA.

The Configuration Section comes after the IDENTIFICATION DIVISION. Define source and object computers, then use SPECIAL-NAMES to map system functions to user-defined names and set currency/decimal symbols.

SPECIAL-NAMES for I/O

cobol
1
2
3
4
5
6
7
SPECIAL-NAMES. CONSOLE IS CRT PRINTER IS PRT SYSIN IS INPUT-STREAM SYSOUT IS OUTPUT-STREAM SYSPRINT IS PRINT-STREAM SYSERR IS ERROR-STREAM.

Map standard I/O streams to meaningful names. CONSOLE maps to CRT, PRINTER to PRT, and standard streams (SYSIN, SYSOUT, SYSPRINT, SYSERR) to descriptive names for better code readability.

Collating Sequence

cobol
1
2
3
4
5
6
7
8
9
10
SPECIAL-NAMES. PROGRAM COLLATING SEQUENCE IS ASCII-SEQUENCE. *> Custom collating sequence SPECIAL-NAMES. PROGRAM COLLATING SEQUENCE IS CUSTOM-SEQUENCE. WORKING-STORAGE SECTION. 01 CUSTOM-SEQUENCE PIC X(256) VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.

Define collating sequences for character ordering. Use ASCII-SEQUENCE for standard ASCII ordering, or define custom sequences for special sorting requirements. This affects SORT operations and comparisons.

Currency and Decimal Settings

cobol
1
2
3
4
SPECIAL-NAMES. CURRENCY SIGN IS '$' DECIMAL-POINT IS COMMA CURRENCY SIGN IS 'EUR' WITH PICTURE SYMBOL '€'.

Set currency symbols and decimal point characters. CURRENCY SIGN defines the symbol used in PICTURE clauses. DECIMAL-POINT sets the character used for decimal places (COMMA for European format).

Alphabet Names

cobol
1
2
3
4
5
6
7
8
9
SPECIAL-NAMES. ALPHABET ALPHA-NUMERIC IS 'A' THROUGH 'Z' 'a' THROUGH 'z' '0' THROUGH '9'. ALPHABET UPPER-CASE IS 'A' THROUGH 'Z'. ALPHABET LOWER-CASE IS 'a' THROUGH 'z'. ALPHABET DIGITS IS '0' THROUGH '9'.

Define custom alphabets for character set validation and processing. Create alphabets for alphanumeric, upper-case, lower-case, and digits. Use these in CLASS clauses for data validation.

Class Names

cobol
1
2
3
4
5
6
7
8
9
10
SPECIAL-NAMES. CLASS VALID-CHARS IS 'A' THROUGH 'Z' '0' THROUGH '9'. CLASS INVALID-CHARS IS '!' THROUGH '/' ':' THROUGH '@'. *> Use in validation IF CUSTOMER-ID IS VALID-CHARS DISPLAY 'Valid customer ID' ELSE DISPLAY 'Invalid characters in customer ID' END-IF.

Define custom character classes for validation. Create classes for valid and invalid characters. Use these classes in IF statements with IS clause for data validation and error checking.

Switch Names

cobol
1
2
3
4
5
6
7
8
9
10
11
12
SPECIAL-NAMES. SWITCH-1 IS DEBUG-SWITCH ON STATUS IS DEBUG-ON SWITCH-2 IS TRACE-SWITCH ON STATUS IS TRACE-ON. *> Use switches in program logic IF DEBUG-SWITCH DISPLAY 'Debug information: ' DEBUG-DATA END-IF. IF TRACE-SWITCH DISPLAY 'Trace: ' TRACE-MESSAGE END-IF.

Map system switches to meaningful names. Define switch names with ON/OFF status conditions. Use switches to control program behavior like debug output and tracing without code changes.

Environment-Specific Configuration

cobol
1
2
3
4
5
6
7
8
9
10
CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-390 WITH DEBUGGING MODE. OBJECT-COMPUTER. IBM-390 PROGRAM COLLATING SEQUENCE IS ASCII-SEQUENCE MEMORY SIZE 32M. SPECIAL-NAMES. CONSOLE IS CRT PRINTER IS PRT CURRENCY SIGN IS '$' DECIMAL-POINT IS PERIOD.

Configure environment-specific settings. Enable debugging mode for development, set memory requirements, and configure system-specific parameters. This ensures proper program behavior across different environments.