CONFIGURATION SECTION


CONFIGURATION SECTION provides the computer environment information in which the program is compiled and executed. It is an optional section in the COBOL program.

Syntax -

[CONFIGURATION SECTION.
[SOURCE-COMPUTER. computer-name]
[OBJECT-COMPUTER. computer-name]
[SPECIAL-NAMES.   names-entry]]
Note! All statements coded in [ ] are optional.

SOURCE-COMPUTER. {source-computer-entry} -


SOURCE-COMPUTER provides the computer name on which the source program is compiled.

  • computer-name - Source computer name where the program is coded.
  • WITH DEBUGGING MODE - Activates a compile-time debugging switch for debugging lines coded in the program.

Debugging Lines -

  • A debugging line is a code with a "D" in column 7.
  • Debugging lines are allowed to code in the ENVIRONMENT DIVISION, DATA DIVISION, and PROCEDURE DIVISION.
  • If the DEBUGGING MODE is coded, the code with "D" in the 7th column is considered as code.
  • If the DEBUGGING MODE is not coded, the code with "D" in the 7th column is treated as comments.

Practical Example -


Scenario1 - Example to describe how the DEBUGGING MODE is enabled in COBOL programming.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       ...
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION. 
       SOURCE-COMPUTER. IBM3278 WITH DEBUGGING MODE.
       OBJECT-COMPUTER. IBM3278.
 
       PROCEDURE DIVISION.

      D    DISPLAY "DISPLAYING DEBUGGING LINE".
           DISPLAY "DISPLAYING NORMAL LINE".
		   ...

Output -

DISPLAYING DEBUGGING LINE
DISPLAYING NORMAL LINE

Explaining Example -

DEBUGGING MODE is coded on SOURCE-COMPUTER. Thus, all the debugging lines in the program are considered as code during the compilation and executed when we ran the program.

Scenario2 - Example to describe how the DEBUGGING MODE is disabled in COBOL programming.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       ...
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. IBM3278.
       OBJECT-COMPUTER. IBM3278.

       PROCEDURE DIVISION.

      D    DISPLAY "DISPLAYING DEBUGGING LINE". 
           DISPLAY "DISPLAYING NORMAL LINE". 
		   ...

Output -

DISPLAYING NORMAL LINE

Explaining Example -

DEBUGGING MODE not coded with SOURCE-COMPUTER. i.e., DEBUGGING MODE disabled. All the debugging lines are considered comments during the compilation and not executed when we ran the program.

OBJECT-COMPUTER. {object-computer-entry} -


OBJECT-COMPUTER paragraph specifies the system name where the object code will be executed.

  • Computer-name - Specifies where the program is executed. If it is coded, the program runs only on specified machine and doesn't run on the current machine.
  • PROGRAM COLLATING SEQUENCE IS alphabet-name - A collating sequence is used to overwrite the system collating sequence. The alphabet-name should be defined in the SPECIAL-NAMES paragraph to specify the collating sequence.
Note! If this clause is not coded, the system's default collating sequence is in effect.

SPECIAL-NAMES. {special-names-entry} -


SPECIAL-NAMES paragraph overrides system-defined objects like environment names, user-defined mnemonic names, collating sequences, class names, currency strings, commas, and decimal points.

  • environment-name-1 - specifies the system name where the compiler took the actions.
  • mnemonic-name-1 - user-defined name.
  • ALPHABET clause - Declares a name with a character code or collating sequence. For example -
    SPECIAL-NAMES. ALPHABET ALPHA-NAME IS EBCDIC.

  • SYMBOLIC CHARACTERS clause - Applies a variable to single-byte character sets. Each character represented is an alphanumeric character. For example -
    SPECIAL-NAMES. SYMBOLIC CHARACTERS SC-A IS 97.

  • CURRENCY SIGN clause - sets the currency symbol in a PICTURE clause. For example -
    SPECIAL-NAMES. CURRENCY SIGN IS "$".

  • DECIMAL-POINT IS COMMA clause - swaps the functions of the period. Also, change the comma in PICTURE character-strings and numeric literals. For example -
    SPECIAL-NAMES. DECIMAL-POINT IS COMMA.

Practical Example -


Scenario - Example to describe how the PROGRAM COLLATING SEQUENCE is used in COBOL programming.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       ...
       ENVIRONMENT DIVISION. 
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. IBM3278.
       OBJECT-COMPUTER. IBM3278
                PROGRAM COLLATING SEQUENCE IS TEST-COLLATE.
       SPECIAL-NAMES. ALPHABET TEST-COLLATE IS 'STUVWXY'. 
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-VAR        PIC X(01).

       PROCEDURE DIVISION. 

           MOVE LOW-VALUE     TO  WS-VAR.
           DISPLAY "LOWEST VALUE IS:  " WS-VAR.
		   ...

Output -

LOWEST VALUE IS:  S

Explaining Example -

TEST COLLATE is the PROGRAM COLLATING SEQUENCE that overrides the ALPHABET system collating sequence. i.e., the EBCDIC character sequence has been overridden by the 'STUVWXY'. Therefore, the LOW-VALUE is 'S,' and the same is displayed in the output.