Summary -

In this topic, we described about the below sections -

The configuration section describes about the computer environment in which the program is compiled and executed. The configuration section is an optional section for the COBOL program.

Syntax -

[CONFIGURATION SECTION. 
[Source-computer-paragraph]
[Object-computer-paragraph]
[special-names-paragraph]]

The configuration section can be specified only when the program is the main program (not a nested program/outermost program). Therefore, the configuration section should not be defined in a program (nested programs) coded within another program (outermost/main program). The entries specified in the program (outermost/main program) apply to any programs (nested programs) contained in it.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. CSMAINPR.          <-- Main/Outermost program
       AUTHOR. MTH.                                                     

       ENVIRONMENT DIVISION.     
       CONFIGURATION SECTION.         <-- This section applies to the
       .....                              nested programs coded in it
       .....                              and no need to code again.	   
	   
       PROCEDURE DIVISION.                                              
           ....
           ....
           STOP RUN.                                                    
                                                                        
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. CSNESTPR.          <-- Nested Program
       AUTHOR. MTH.                                                     
                                                                        
       PROCEDURE DIVISION.                                              
           ....
           ....
           STOP RUN.                                                    
                                                                        
       END PROGRAM CSNESTPR.                                            
       END PROGRAM CSMAINPR.                                            
**************************** Bottom of Data ****************************

Source-computer-paragraph -

SOURCE-COMPUTER is used to provide the computer system on which the source program will get compiled.

Syntax -

SOURCE-COMPUTER Paragraph

All entries of the SOURCE-COMPUTER paragraph are syntax checked and have no impact on the program execution. But, the WITH DEBUGGING MODE clause affects the execution of the program.

computer-name -

A system-name.

WITH DEBUGGING MODE -

It activates a compile-time switch for debugging lines written in the source text.

For example - To activate debugging switch

      ENVIRONMENT DIVISION.                                      
      CONFIGURATION SECTION.                                     
      SOURCE-COMPUTER. IBM3278 WITH DEBUGGING MODE.              

A debugging line is a coding line that have a D in column 7. In addition, all debugging lines must be syntactically correct.

For example - Debugging line

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      D    DISPLAY "WS-VAR HAS VALID CHARACTERS".

A debugging line is compiled or considered as a coding line only when the compile-time switch is activated. Otherwise, debugging line considers as a comment during the compilation.

If the DEBUGGING MODE is enabled on SOURCE-COMPUTER, the program recognizes the statements that had D in the 7th column as a part of the code. During the execution, the statements get executed along with the flow.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. CSMAINPR.          
       AUTHOR. MTH.                                                     

       ENVIRONMENT DIVISION.                                   
       CONFIGURATION SECTION.                                  
       SOURCE-COMPUTER. IBM3278 WITH DEBUGGING MODE.  <-- Enabling switch
       OBJECT-COMPUTER. IBM3278.                               	   
	   
       PROCEDURE DIVISION.                                              
      D    DISPLAY "DISPLAYING DUBUG LINE". <-- Considers it as part of code
           DISPLAY "DISPLAYING NORMAL LINE".
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

If the DEBUGGING MODE is not enabled on SOURCE-COMPUTER, the program doesn’t recognize the statements which had D in the 7th columns as a part of the code. Therefore, during the execution, the statements get ignored and not considered.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. CSMAINPR.          
       AUTHOR. MTH.                                                     

       ENVIRONMENT DIVISION.                                   
       CONFIGURATION SECTION.                                  
       SOURCE-COMPUTER. IBM3278.  <-- Disabling switch           
       OBJECT-COMPUTER. IBM3278.                               	   
	   
       PROCEDURE DIVISION.                                       
      D    DISPLAY "DISPLAYING DUBUG LINE". <-- ignores this line
           DISPLAY "DISPLAYING NORMAL LINE".
           STOP RUN.                                            
**************************** Bottom of Data ****************************

The presence or absence of the DEBUGGING MODE clause is logically determined after all COPY and REPLACE statements have been processed. Debugging lines can be coded in the ENVIRONMENT DIVISION, DATA DIVISION, and PROCEDURE DIVISION.


Practical Examples -

Scenario1 - Below example describes how the DEBUGGGING MODE enabled in COBOL programming.

Code -

Configuration Section with Debugging Mode Program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. SCWITHDM.                                            
       AUTHOR. MTH.                                                     
                                                                        
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM3278 WITH DEBUGGING MODE.                    
       OBJECT-COMPUTER. IBM3278.                                        
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
      D    DISPLAY "DISPLAYING DEBUGGING LINE".                         
           DISPLAY "DISPLAYING NORMAL LINE".                            
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Configuration Section with Debugging Mode Output

Explaining Example -

In the above example, we have enabled the DEBUGGING MODE on SOURCE-COMPUTER. Thus, all the debugging lines in the program are considered as code during the compilation.


Scenario2 - Below example describes how the DEBUGGGING MODE disabled in COBOL programming.

Code -

Configuration Section without Debugging Mode Program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. SCWOUTDM.                                            
       AUTHOR. MTH.                                                     
                                                                        
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM3278.                                        
       OBJECT-COMPUTER. IBM3278.                                        
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
      D    DISPLAY "DISPLAYING DEBUGGING LINE".                         
           DISPLAY "DISPLAYING NORMAL LINE".                            
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Configuration Section without Debugging Mode Output

Explaining Example -

In the above example, DEBUGGING MODE not coded with SOURCE-COMPUTER. i.e., DEBUGGING MODE disabled and all the debugging lines in the program are considered as comments during the compilation.

Object-computer-paragraph -

The OBJECT-COMPUTER paragraph specifies the system name for which the object program is designated. The OBJECT-COMPUTER does not affect the program execution.

Syntax -

OBJECT-COMPUTER Paragraph

If OBJECT-COMPUTER is not specified in the program, the program doesn’t run on the current machine. All entries of the OBJECT-COMPUTER paragraph are syntax checked and have no impact on the program execution. But the PROGRAM COLLATING SEQUENCE clause affects the execution of the program.

computer-name -

A system-name.

PROGRAM COLLATING SEQUENCE IS alphabet-name -

A collating sequence is used to compare non-numeric data items. The alphabet-name should be defined in the SPECIAL-NAMES paragraph to specify the collating sequence.

For example -

ENVIRONMENT DIVISION.                                
CONFIGURATION SECTION.                               
SOURCE-COMPUTER. IBM3278.                            
OBJECT-COMPUTER. IBM3278                             
         PROGRAM COLLATING SEQUENCE IS TEST-COLLATE. 
SPECIAL-NAMES. ALPHABET TEST-COLLATE IS 'DOWNSTREAM'.

If this clause is not specified, the system's collating sequence is assumed.

The PROGRAM COLLATING SEQUENCE clause applies to any MERGE or SORT keys described with usage DISPLAY, unless the COLLATING SEQUENCE phrase is specified separately in the MERGE or SORT statement.


Practical Example -

Scenario - Below example describes how the PROGRAM COLLATING SEQUENCE used in COBOL programming.

Code -

Configuration Section with Program Collating Sequence Program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. OCWITHSC.                                            
       AUTHOR. MTH.                                                     
                                                                        
       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.                         
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Configuration Section with Program Collating Sequence  Output

Explaining Example -

In the above 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 specified sequence 'STUVWXY'. Therefore, the LOW-VALUE in the sequence is 'S' and the same displayed in the output.

Special-names-paragraph -

SPECIAL-NAMES used for providing symbolic characters and the special function names relation to the existing mnemonic names in the source program.

Syntax -

SPECIAL NAMES Paragraph

The environment-names are related to user-specified mnemonic-names. The entries in the SPECIAL-NAMES paragraph can appear in any order.

The constant entries can get created by using SPECIAL-NAMES to validate the fields at a program level.

ALPHABET clause -

The ALPHABET clause relates an alphabet-name to a specified character code set or collating sequence.

For example -

SPECIAL-NAMES. ALPHABET ALPHA-NAME IS EBCDIC.

SYMBOLIC CHARACTERS clause -

It offers a resource for specifying one or more symbolic characters. The SYMBOLIC CHARACTERS clause applies 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 -

The CURRENCY SIGN clause specifies the currency symbol used to represent the currency sign value in a PICTURE clause. This clause affects numeric-edited data items whose PICTURE character-strings contain a currency symbol.

For example -

SPECIAL-NAMES. CURRENCY SIGN IS "$".

DECIMAL-POINT IS COMMA clause -

The DECIMAL-POINT IS COMMA clause exchanges the functions of the period. Also, exchanges the comma in PICTURE character-strings and numeric literals.

For example -

SPECIAL-NAMES. DECIMAL-POINT IS COMMA.

environment-name-1 -

It specifies the system device or standard system where the compiler took the actions.

mnemonic-name-1 -

mnemonic-name-1 is the user-defined name. mnemonic-name-1 can be used in ACCEPT, DISPLAY, and WRITE statements.


Practical Example -

Scenario - Below example describes how the SPECIAL NAME usage in COBOL programming.

Code -

Configuration Section with Program Collating Sequence Program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. SPECIALN.                                            
       AUTHOR. MTH.                                                     
                                                                        
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM3278.                                        
       OBJECT-COMPUTER. IBM3278.                                        
       SPECIAL-NAMES. CLASS HAS-VALID-CHAR IS "A" THRU "Z"              
                                              "0" THRU "9".             
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
                                                                        
       01 WS-VAR        PIC X(10) VALUE "MAINFRAMES".                   
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
           IF WS-VAR  HAS-VALID-CHAR                                    
              DISPLAY "WS-VAR HAS VALID CHARACTERS"                     
           ELSE                                                         
              DISPLAY "WS-VAR HAS INVALID CHARACTERS"                   
           END-IF.                                                      
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Configuration Section with Program Collating Sequence  Output

Explaining Example -

In the above example, HAS-VALID-CHAR is a special name defined with valid characters 'A' to 'Z' and 0 to 9. HAS-VALID-CHAR is used to validate WS-VAR has the valid characters defined in symbolic name and displays the corresponding message based on the validation.