ENVIRONMENT DIVISION


Ø       It is a machine dependent division.
Ø       The Division itself is optional but for file handling it is essential.
Ø       Should begin in Area A.
Ø       Division is terminated by a period.
Ø       Describes the computer used, peripheral devices, etc.
Ø       Contains two sections namely, CONFIGURATION and INPUT-OUTPUT.

 CONFIGURATION SECTION

Ø       Mentions the name of the source-computer, object-computer, special-names, symbolic-names and classes defined by programmer.
Ø       The paragraphs of configuration section are SOURCE-COMPUTER, OBJECT-COMPUTER, and SPECIAL-NAMES.

SOURCE-COMPUTER

Ø          Used to specify the name of the Source Computer compiling the COBOL program.
Ø         The “With Debugging Mode” option can be mentioned to enable the Compiler to include all the lines with ‘D’ in the 7th column as syntax (Otherwise it is taken as comment). It can also include the debug Declaratives in PROCEDURE DIVISION.

OBJECT COMPUTER

Ø          Used to specify the target system.
Ø         The program collating sequence can also be specified in this paragraph for SORTING and STRING COMPARISON. By default, EBCDIC code is followed in MVS. We can change it to ASCII, or any other order if we define SPECIAL-NAMES.

SPECIAL-NAMES

Ø          Specifies collating sequence.
Ø          Maps IBM specified environment names to user defined mnemonic names.
Ø          Substitutes character for currency sign.
Ø          Indicates that ‘ , ‘ and ‘ . ‘ are to be interchanged in the PIC clause.
Ø          We can also specify symbolic characters, such as, PERCENTAGE-SIGN IS 38.
Ø         Regardless of the number of entries in this paragraph, there should be only one period at the end.

INPUT-OUTPUT SECTION

Ø          Contains information regarding files to be used in the program.
Ø          Consists of two paragraphs FILE-CONTROL and I-O CONTROL.

  FILE-CONTROL

Associates each file used in a COBOL program with an external ddname. Physical dataset is assigned in DD statement of JCL at execution time.
       Three formats for the FILE-CONTROL paragraph are:
Ø          Sequential file entries
Ø          Indexed file entries
Ø          Relative file entries

Coding rules for FILE-CONTROL paragraph.
Ø          SELECT clause must appear first
Ø          Other clauses may appear in any order
Ø         Each clause must start in Area B

 I-O CONTROL

Ø          Optional Paragraph.
Ø          Specifies when check points are to be taken.
Ø          Specifies the storage areas to be shared by different files.
Ø         The key word I-O control must begin in Area A.
Example:


IDENTIFICATION DIVISION.
PROGRAM-ID.     EDS001.
AUTHOR.         A343.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-390 WITH DEBUGGING MODE.        
OBJECT-COMPUTER. IBM-390
PROGRAM COLLATING SEQUENCE IS A01.
SPECIAL-NAMES.
     ALPHABET A01 IS
     "A"     ALSO     "a"
     "B"     ALSO     "b"
     ALPHABET A IS STANDARD-1
     SYSIN IS PROGIN
     CURRENCY IS "@"
     DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL
SELECT OUTFILE ASSIGN TO DD1
ORGANIZATION IS SEQUENTIAL
ACCESS MODE SEQUENTIAL
FILE STATUS IS WS-FST.

0 comments:

Computers TopOfBlogs Technology Blogs Mainframe interview question and answers,mainframe jobs,cobol,vsam,jcl,cics,db2,rdbms,mvs,tso,ispf,ibm,hcl,tcs,cts,wibro Blog Directory