Vous êtes sur la page 1sur 32

An Introduction To File Operations

April 2009

CONFIDENTIAL: For limited circulation only

2008 2009 MindTree MindTree Consulting Limited

Topics to be Covered:

Steps in File-handing Sort Merge Input/Output and Error Handling Techniques File Status Codes Compiler Options

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 2

File Operations:
FILE:
A Data File(Data Set) is Collection of relevant Records that are stored Permanently and a Record is Collection of relevant Fields. Files can be associated with an external device like Disk, Tape, Printer etc. FILE NAME: A file has Two names: Physical and Logical Name. The JCL DD Statement Connects both Logical and Physical Files. The File Handling in COBOL program involves Five steps: 1. ALLOCATION 2. DEFINITION 3. OPEN 4. PROCESS 5. CLOSE

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 3

Allocation of Files:
1. ALLOCATION: Files used in the program should be declared in FILE-CONTROL paragraph of
INPUT-OUTPUT SECTION. The mapping with JCL DDNAME is done here. FILE-CONTROL Syntax:
SELECT [OPTIONAL] Filename ASSIGN TO DDNAME ORGANIZATION IS {SEQUENTIAL / INDEXED / RELATIVE} ACCESS MODE IS {SEQUENTIAL / RANDOM / DYNAMIC } RECORD KEY IS FILE-KEY1 ALTERNATE KEY IS data-name-2 [WITH/WITHOUT DUPLICATE] [RELATIVE KEY IS WS-FILE-KEY1 ] FILE STATUS IS dataname-1 [dataname-2] . =>ALL Files =>ALL Files =>ALL Files =>KSDS =>KSDS WITH AIX =>RRDS =>ALL Files

SELECT: Gives the Relationship between the Logical File and the Physical file. Filename: Logical File Name used by COBOL to refer inside the program. DD Name: Associates the Symbolic file with External DDNAME given in JCL. DD Name can be Disk/ Printer/ Tape.

E.g.: //DDNAME DD DSN=MAIN.EMPLOYEE.DATA,DISP=SHR


OPTIONAL: This Key Word is used only for Input Files. If OPTIONAL is coded with SELECT, this file need not be present during the execution. If the file is not mapped in JCL, it is considered as Empty File and the first Read results in End of file. If Omitted, the file must be present in JCL. If not, an Execution Error will occur.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 4

Allocation of Files Continued.


ACCESS MODE: SEQUENTIAL: Records are accessed Sequentially. RANDOM: Records are accessed in any order by giving the key value to the RECORD KEY variable. A particular records of an Indexed/ Relative file is accessed provided Key Value is set prior to Read/Write Operation. DYNAMIC: Records can be accessed both Sequentially and Randomly. ORGANIZATION: Depending on the input/output requirements and device types, SEQUENTIAL: File is a Sequential File(PS file/ VSAM ESDS). The records are placed in First Come First Serve Basis. INDEXED: File is a VSAM KSDS file. Key Filed called Primary Key should be defined. RELATIVE: File is VSAM RRDS File. Relative Record Number is used to access records. Each record has a Unique Address identified by Relative Record Number. RECORD KEY: Defined for Indexed files and should be Unique and part of indexed record. ALTERNATE KEY: Defined if records are to be Read using Key Other than Primary Key and need not be Unique, but should be part of the record.
ACCESS ORG. SEQ RELATIVE INDEXED
CONFIDENTIAL: For limited circulation only

SEQ ORDER OF WRITE ASC. REL. REC. NO. ASC. KEY VALUE

RANDOM INVALID VALUE OF REL. KEY VALUE OF REC. KEY


2009 MindTree Limited

DYNAMIC INVALID SEQ. OR RANDOM SEQ. OR RANDOM


Slide 5

File Definition:
2. DEFINITION:
The File that is defined in the SELECT clause, should have an FD entry in the FILE SECTION. The layout of the file and its attributes are defined in the FD section of FILE SECTION. File Layout: FD FILENAME RECORDING MODE IS V/VB/F/FB RECORD CONTAINS M CHARACTERS (TO N CHARACTERS) BLOCK CONTAINS X CHARACTERS/RECORDS (TO Y CHARACTERS/RECORDS) LABEL RECORDS ARE OMITTED/STANDARD DATA RECORD IS FILE-RECORD. 01 FILE-RECORD PIC X(nnn). RECORDING MODE IS Clause : Records in a file Can be F / V / FB / VB

Variable record file identification: If there is no Recording Mode/Record Contains Clause, it is still possible to identify variable length records. If there is an OCCURS depending on clause or there are multiple 01 levels and every 01 level is of different size, then the file would be of variable length.
E.G for Implicit Redefinition : Multiple 01 level in File section.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 6

File Definition Continued.


FD-RECORD CONTAINS Clause : Specifies the Length of the Record in terms of bytes. (For Variable Format Files, it will be RECORD contains m to n CHARACTERS) This has to match with record length in the DD statement parameter.

FD-BLOCK CONTAINS Clause : The BLOCK CONTAINS RECORDS specifies the No of Logical Records in each Physical Record, i.e., Multiples of LRECL. The BLOCK CONTAINS CHARACTERS clause Specifies the Physical Record Size.(for Disk Files) It is suggested to code BLOCK CONTAINS 0 RECORDS, so that system will decide the optimum size for the file based on the device used for storing the file. BLOCK CONTAINS clause is treated as comments for VSAM files.
Advantage of Blocking: I-O time is reduced as n No of records are read into main memory buffer during an I-O. Inter Record Gap is removed and the gap exist only between blocks. So memory wastage due to IRG is avoided. FD-LABEL RECORDS Clause: LABEL RECORDS are STANDARD is coded for Disk and Tape files, LABEL RECORDS ARE OMITTED is coded for printer files. FD-DATA RECORD IS Clause: It is used to name the data record(s) of the file. More than one record can be coded here.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 7

INPUT OUTPUT Statements:


3. OPEN: Connects the Dataset to the program.
The mode of OPEN decides the operation allowed and the position of the initial pointer in the dataset.

Syntax:

OPEN OPENMODE FILENAME

OPENMODE can be: INPUT To READ an Existing File. OUTPUT To Write/To add to an Existing File/Create New file. I-O - FOR READ, WRITE, REWRITE and DELETE an existing File. EXTEND - FOR appending records at the End of the File. EXTEND mode allows only write access and the pointer is kept on the End of File to append.

4. PROCESS: Files can be Processed as per requirement, using the I-O statements
provided by COBOL. (READ/READ NEXT, START, WRITE, REWRITE and DELETE)

5. CLOSE: Disconnects the File from the program.


If we dont close the files, the completion of the program closes all the files used in the program. Syntax: CLOSE Filename
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 8

INPUT OUTPUT Statements:


READ: Reads the record from the file.
Syntax:
READ FILENAME NEXT RECORD [INTO ws-record] [KEY IS FILE-KEY1] [AT END/INVALID KEY imperative statement1] [NOT AT END/NOT INVALID KEY imperative statement2] END-READ

NEXT phrase: Optional for SEQUENTIAL

Access Mode but is must for DYNAMIC. When the READ NEXT statement is the first statement to be executed after the OPEN statement on the file, the next record is the first record in the file.

INTO Clause: If coded, then the file is directly read into Working Storage Section record.
It is preferred as it avoids another move of File-Section record to Working-Storage-record followed by simple READ. read is not known.

READ-INTO: Not preferred for Variable size records where the length of the record being
KEY IS Clause: Used while accessing a record randomly using Primary/Alternate Record Key. AT END / NOT AT END: Used during sequential file READ. INVALID KEY / NOT INVALID KEY: Used during Random File Read.
Before accessing the file randomly, the key field should have a value before READ.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 9

INPUT OUTPUT Processing Continued.


SEQUENTIAL READ: Syntax: READ file-name NEXT RECORD [ INTO identifier-1 ] [ AT END imperative-stmt-1] [ NOT AT END imperative-stmt-2 ] END-READ.

USAGE: When the Exact Key value is not known.

To search the VSAM file for a Particular Key for processing. When Alternate key is used as key to the Indexed File. This is because the
Alternate Key may not be unique. To process records with part of the key matching.

E.G: The key field of the EMP-MATER file is Emp-No, Designation, Date-of-Joining. To process all employees belonging to designation Associates, we use Sequential Read of the Indexed File. RANDOM READ: The random read of Indexed File is faster. Syntax: READ file-name RECORD [ INTO identifier-1 ] [ KEY IS data-name-1 ] [ INVALID KEY imperative-stmt-3 ] [ NOT INVALID KEY imperative-stmt-4 ]
2009 MindTree Limited Slide 10

END-READ.
CONFIDENTIAL: For limited circulation only

INPUT OUTPUT Processing Continued.

USAGE:- When the key value for the file is exactly known. In Real Time Systems like Patient monitoring system in hospitals to retrieve a particular patients record. The full key value for the Patient master file is known. Hence we use random read in this case. READ Example: File- Indexed, Dynamic Access, and Record Key is EMP-NO. Record Description: 01 EMP-REC 05 EMP-NO PIC 9(4). 05 EMP-NAME PIC X(10).
Operation OPEN input READ NEXT READ KEY 0100 READ NEXT READ KEY 0015 READ KEY 0090 READ NEXT File Position Pointer 0004 0010 0401 End of File 0016 Undefined Undefined Record Area Not defined 0004 RAJESH 0100 SARITA 0401 RANI 0015 GOPAL Undefined (Invalid key) Undefined

EMP # 0004 0010 0015 0016 0100 0401

EMP Name RAJESH RAMESH GOPAL RAGHAVAN SARITA RANI

Table: File position indicator example

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 11

INPUT OUTPUT Processing Continued.


START: Used with Dynamic Access Mode of Indexed Files.

Positions the pointer at a Specific Position. Establishes the current location in the cluster for READ NEXT statement. START itself does not retrieve any record. It only sorts the current record pointer described under File position indicator .
RULES: Invalid Key arises if the record position is empty. When the KEY phrase is not specified, KEY IS EQUAL (to the prime record key) is implied. All the Numeric and Nonnumeric comparison rules apply.

When the START statement is executed, a comparison is made between the current value
in the key data-name and the corresponding key field in the file's index.

If the operands in the comparison are of unequal lengths, the comparison proceeds as if
the longer field were truncated on the right to the length of the shorter field. Syntax: START Filename [KEY IS EQUAL TO/NOT LESS THAN/GREATER THAN key-name] [INVALID KEY Imperative Statement1] END-START.
2009 MindTree Limited Slide 12

CONFIDENTIAL: For limited circulation only

INPUT OUTPUT Processing Continued.


START Example: File- Indexed, Dynamic Access and Record Key is EMP-NO Record Description: 01 EMP-REC 05 EMP-NO PIC 9(4). 05 EMP-NAME PIC X(10). EMP # 0004 0010 0015 0016 0100 0401 EMP Name RAJESH RAMESH GOPAL RAGHAVAN SARITA RANI OPERATION
OPEN I-O START ASSOC.NO-KEY = 0004 READ NEXT START ASSOC-NO-KEY > 0016 READ NEXT START ASSOC-NO-KEY > 0401
POINTER VALUE Top of File 0004 REC-AREA Not defined Not defined

0010 0100 0401 Unknown

0004 RAJESH 0004 RAJESH 0100 SARITA 0100 SARITA

Table: Illustration of START statement

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 13

INPUT OUTPUT Processing Continued.


WRITE: Writes a New Record to the file.
If the file is Opened in :

EXTEND mode, the record will be appended. OUTPUT mode, the record will be added at the current position.
WRITE File-record [FROM identifer-1] [INVALID KEY imperative statement1] [NOT INVALID KEY imperative statement2] END-WRITE.

WRITE Syntax for Disk File :

FROM Clause: Avoids the Explicit move of Working Storage record to File Section record
before WRITE. INVALID KEY: Not Allowed for ESDS.
WRITE Syntax for Printer File : WRITE File-record [FROM identifer-1] [{BEFORE ADVANCING {(N Lines/identifer-2 Lines) AFTER ADVANCING {(N Lines/identifer-2 Lines) Mnemonic-Name PAGE }] [AT { END-OF-PAGE stmt-1 EOP } ] [NOT AT { END-OF-PAGE stmt-2 EOP } ] END-WRITE.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 14

INPUT OUTPUT Processing Continued. ADVANCING phrase is only for Printer Files.
RULES: 1.BEFORE ADVANCING specifies, the line is printed before the page is advanced. 2.AFTER ADVANCING specifies, the page is advanced before the line is printed. 3.When identifier-2 is specified, the page is advanced the number of lines equal to the current value in identifier-2. Identifier-2 must name an elementary integer data item.

When ADVANCING option is used

- First char of record is reserved for Printer Control. - If compiler has ADV, the LRECL of file should be more than FD entry record area length. - If compiler option is NOADV then LRECL of file is same as FD entry record area length.

File Position is not affected by this statement.


Facilities for Paper Movement are provided by:
Print and Advance Advance and Print Position to New Page Advance by given number of lines End of Page Logic (FD entry for this file must contain a LINAGE clause)
2009 MindTree Limited Slide 15

CONFIDENTIAL: For limited circulation only

INPUT OUTPUT Processing Continued.


REWRITE: Updates an already read record.
Syntax: REWRITE File-record [FROM identifier-1] [INVALID KEY imperative statement1] [NOT INVALID KEY imperative statement2] END-REWRITE.

For a file in sequential access mode, the INVALID KEY and NOT INVALID KEY phrases should not be specified.

DELETE: Logically Removes the most recently read record in the file.
Syntax: DELETE Filename RECORD [INVALID KEY imperative statement1] [NOT INVALID KEY imperative statement2] END-DELETE.

For a file in Sequential Access Mode:


key(KSDS) or RELATIVE key(RRDS).
CONFIDENTIAL: For limited circulation only

For Random or Dynamic Access, system removes record pointed by the RECORD
2009 MindTree Limited Slide 16

The INVALID KEY and NOT INVALID KEY phrases should not be specified. Logically Removes the most recently read record in the file.

FILE SORTING:
SORT: The process of sequencing records in file in some predetermined order on some fields in which it was not initially stored is called SORTING.
External Sort: The SORT in JCL is External Sort. Internal Sort : The Programming SORT is Internal Sort.

SORT accepts an Input File and creates a Sorted Output File. The SORT uses a Temporary file called SORT Work File for sorting the given input file.
SORT requires 3 Files for processing : 1.Unsorted Input File, 2.SORT Work file/ SORTFILE 3.Sorted Output File.

The fields based on which the records are sequenced are called SORT KEYS. The sequencing can be ascending or descending order of the KEY. Internal Sort is preferred, When we want to manipulate the data before feeding to sort
or after sorting before writing it to the output file. Internal Sort, in turn invokes the SORT product of the installation (DFSORT). In the run JCL, we need to allocate at least three sort work files.(SORT-WKnn). nn =(00-99).
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 17

FILE SORTING Continued.


FASTSRT BY PASS COBOL IN/OUT SORT PROCS BY USING DFSORT.
That is FASTSRT Compiler option makes the DFSORT to do all file I-O operation than the COBOL program and would significantly improve the performance.

The result of the SORT can be checked in SORT-RETURN Register. If Sorting is Successful, the Value will be 0 else 16.
Syntax:
SORT SORTFILE ON ASCENDING /DESCENDING KEY sd-key-1 sd-key2 USING file1 file2 / INPUT PROCEDURE IS section-1 GIVING file3 / OUTPUT PROCEDURE IS section-2 END-SORT

File1, File2 are Unsorted Input Files and File3 is Sorted-Output file that should be defined in FD(File Description) Entry. SORTFILE is SORT Work file that is defined at SD Entry. It is not associated with any Physical File hence No Explicit Opening or Closing. The format of SD entry is same as the FD entry. The SORT verb opens input, output and the work files before the sorting begins and closes these files when sorting is over.

INPUT PROCEDURE and USING are Mutually Exclusive. If USING is used, then file1 and file2 should not be Opened or READ explicitly.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 18

FILE SORTING Continued.


If INPUT PROCEDURE is used, File1 and file2 are Opened and all the records are READ one by one until End of File and the required records are passed to Sort-Work-File using the command RELEASE.

INPUT-PROCEDURE is specified to Select or Modify the Input record before Sort. It validates data in the input record. Eliminates records with blank fields and Removes records that are not needed. Counts the input records. Syntax: RELEASE Sort-Work-Record FROM Input-File-Record.

Transfers records to the initial phase of Sort operation. Its like WRITE statement that should be used in conjunction with SORT File only. At-least one RELEASE stmt must be executed, for every INPUT PROCEDURE used.

OUTPUT PROCEDURE and GIVING are Mutually Exclusive.

If GIVING is used, then file3 should not be Opened or Written explicitly. If OUTPUT PROCEDURE is used, File3 will be Opened and then the required sorted records
from Sort Work File are RETURNed to the Out File for WRITE. Once AT END is reached for Sort-Work-File, Close the Output file. OUTPUT-PROCEDURE is specified to Select or Modify the Output record after Sort.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 19

FILE SORTING Continued.


Syntax: RETURN Sort-Work-File-Name AT END Imperative Statement.

Transfers records from the final phase of a sorting or merging operation to an OUTPUT PROCEDURE. Its like READ statement. If OUTPUT PROCEDURE is used, at-least one RETURN statement must be executed.

The INPUT and OUTPUT PROCEDURES are nothing but Sections placed outside the SORT statement. They are performed implicitly by sort statement in order to perform editing.

Simple SORT E.G: To SORT the file on DEPARTMENT in Ascending order and then within each DEPARTMENT, Arrange BASIC-PAY on Descending Order.
ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EMP-FILE SELECT OUTPUT-FILE SELECT SORT-FILE DATA DIVISION. FILE SECTION.

ASSIGN TO EMPIN. ASSIGN TO EMPOUT. ASSIGN TO WORKFILE.

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 20

FILE SORTING Continued.


FD EMP-FILE. 01 EMP-REC. 02 EMP-NO 02 EMP-NAME 02 DEPARTMENT 02 BASIC-PAY 02 ALLOWANCE 02 DEDUCTION SD SORT-FILE 01 SORT-REC. 02 FILLER 02 S-DEPARTMENT 02 S-BASIC-PAY 02 FILLER FD OUTPUT-FILE. 01 OUT-REC PIC X(59). PIC X(30). PIC X(10). PIC 9(5)V99. PIC X(12).

PIC 9(6). PIC X(24). PIC X(10). PIC 9(5)V99. PIC 9(4)V99. PIC 9(4)V99.

PROCEDURE DIVISION. 1000-Para. SORT SORT-FILE ON ASCENDING KEY S-DEPARTMENT DESCENDING KEY S-BASIC-PAY USING EMP-FILE GIVING OUTPUT-FILE. STOP RUN. 1000-EXIT. EXIT. -------------------------------------------------------------------------------------------------------------------------------Advanced SORT E.G: To SORT the file on TERRITORY, AREA and DEPARTMENT in Ascending order and To Eliminate records with BLANK TERRITORY.

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 21

FILE MERGING:
MERGE: Merges Two or more identical files sorted on the same field.


Syntax:

Sometimes it becomes necessary to create a new output file from 2 input files. These 2 files needs to be merged and new file needs to be created. It is same as sort. USING is mandatory. There should be minimum two files in USING. MERGE SORTFILE ON ASCENDING/DESCENDING KEY dataname1 dataname2 USING file1 file2 GIVING file3 / OUTPUT PROCEDURE is section-1 THRU section-2 END-MERGE.

Example: MERGE SORTED-FILE ON ASCENDING S-LAST-NM S-FIRST-NM DESCENDING S-EMP-NBR USING EMP-PH-FILE EMP-ADDON-PH-FILE GIVING NEW-EMP-PH-FILE END-MERGE.

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 22

INPUT/OUTPUT ERROR HANDLING TECHNIQUES:


The following are techniques of intercepting and Handling input/output Errors. The END-OF-FILE PHRASE (AT END) The EXCEPTION/ERROR declarative The INVALID KEY phrase. The FILE STATUS key THE END-OF-FILE PHRASE (AT END): An End-of-File condition may or may not represent an error. During Sequential Read, the End of a File is expected. And If We code an AT END phrase, the specified phrase will be executed upon End-of-File condition. If We do not have any Error Handling in our program(if we dont have an AT END phrase) and if we dont have a specific record in the file, the random read of a record would immediately terminate the program with error RECORD NOT FOUND. Example: When we are processing a file containing transactions in order to update a Master File.
PERFORM UNTIL WS-TRAN-EOF = "TRUE" READ UPDATE-TRANS-FILE INTO WS-TRANS-RECORD AT END DISPLAY "END OF TRANSACTION UPDATE FILE REACHED" MOVE "TRUE" TO WS-TRAN-EOF END READ END-PERFORM.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 23

INPUT/OUTPUT ERROR HANDLING TECHNIQUES:


EXCEPTION/ERROR Declarative: We can have one or more ERROR declarative procedures in the program that will be given control, if an Input/Output Error occurs: A Single, Common Procedure for the entire program. Group procedures for each file open mode (whether INPUT, OUTPUT, I-O, or EXTEND). Individual procedures for each particular file.

INVALID KEY Phrase: Control will be given to INVALID KEY when an Input/Output Error occurs because of a Faulty Index Key. The sudden termination can be avoided by handling this error, with INVALID KEY clause. We can include INVALID KEY phrases on READ, START, WRITE, REWRITE, and DELETE requests for Indexed and Relative Files.
If we specify INVALID KEY in a statement that causes an INVALID Condition, Control is transferred to the INVALID KEY imperative statement. In which case, any ERROR Declaratives that are coded will not be executed.

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 24

INPUT/OUTPUT ERROR HANDLING TECHNIQUES:


INVALID KEY phrase differ from ERROR declaratives in three ways: 1. INVALID KEY phrases operates for only limited types of errors, Whereas the ERROR declarative encompasses all forms. 2. INVALID KEY phrases are coded directly onto the Input/Output verb, Whereas ERROR declaratives are coded separately. 3. INVALID KEY phrases are specific for a Single Input/Output operation, Whereas ERROR declaratives are more general.

FILE STATUS Key: The system updates the FILE STATUS key for every Input/Output Execution and Places the values of Status Code in two digits of the File Status Key. The First Digit denotes general category under which the Error Code Falls. The Second Digit will denote the particular type of error under that category.
FILE STATUS Key is established using the FILE STATUS clause in the FILE-CONTROL and Data Definitions in the Data Division.

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 25

ERROR CODES:
If FILE STATUS key has a non allowable Return Code, then program will be ended abnormally with error statements that would be easier to debug. This is MOST PREFERRED ERROR HANDLING METHOD in structured programming. If FILE STATUS Code has: - Status key 1: Tells the type of error . - Status key 2: Gives the detail.

Attached is the List of Error Codes with different Status Codes:

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 26

COMPILER OPTIONS:
Ways of Overriding the Default Options: 1. Compiler options can be passed to COBOL Compiler Program (IGYCRCTL) through the PARM in JCL. 2. PROCESS or CBL statement with compiler options, can be placed before the IDENTIFICATION DIVISION. 3. If the Organization uses any third party product or its own utility then these options can be coded in the pre-defined line of the utility panel. Precedence of Compiler Options:

1. (Highest precedence). Installation defaults, fixed by the installation.


2. Options coded on PROCESS /CBL statement. 3. Options coded on JCL PARM parameters.

4. (Lowest Precedence). Installation defaults, but not fixed.

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 27

COMPILER OPTIONS:
List of Compiler Option are: ASPECT
SOURCE LANGUAGE DATE PROCESSING MAPS, LISTING AND DIAGNOSTICS OBJECT CODE GENERATION OBJECT CODE CONTROL DEBUGGING OTHER

COMPILER OPTION
APOST, CMPR2, CURRENCY, DBCS, LIB, NUMBER, QUOTE, SEQUENCE, WORD. DATEPROC, INTDATE, YEARWINDOW LANGUAGE, LINECOUNT, LIST, MAP, NUMBER, OFFSET, SEQUENCE,SOURCE, SPACE, TERMINAL, VBREF, XREF COMPILE, DECK, NAME, OBJECT, PGMNAME,CMPR2 ADV, AWO, DLL, EXPORTALL, FASTSRT, OPTIMIZE, NUMPROC, OUTDD, RENT, RESIDENT, SSRANGE, TRUNC, ZWB DUMP, FLAG, FLAGMIG, FLAGSTD, SSRANGE, TYPECHK , FDUMP, TEST ADATA, ANALYZE, EXIT, IDLGEN

ADV: To ADD 1 BYTE FOR PRINTER CONTROL CHARACTER. Used in Programs with Printer Files with WRITE..ADVANCING keyword. If we are Manually populating Printing Control Character in the Program, then we compile the Program with NOADV.

DUMP: TO PRODUCE A SYSTEM DUMP OF THE COMPILER.


CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 28

COMPILER OPTIONS Continued.


LIST/OFFSET: LIST and OFFSET are mutually exclusive. If We use both, LIST will be ignored.
LIST: OBJECT CODE LISTING IN ASSEMBLY LANGUAGE (-OFFSET) (LIST produces Listing of the Assembler Language expansion of the code). OFFSET: LIST RELATIVE ADDRESSES OF PROCEDURE DIVISION (-LIST) (OFFSET produces a Condensed Procedure Division listing). With OFFSET, the procedure portion of the listing will contain Line Numbers, Statement References, and the Location of the First Instruction generated for each statement. MAP: REQUEST TO LIST DATA DIVISION MAP (Used to produce a Listing of the Items Defined in the Data Division). SSRANGE: RANGE CHECK FOR SUBSCRIPT/INDEXES/REFERENCE MOD If the program is compiled with SSRANGE option, then any attempt to refer an area outside the region of the table will abnormally terminate with Protection Exception, usually S0C4.

It also avoids any meaningless operation on Reference Modification like Negative Number in the Starting Position of Reference Modification Expression.
If the program is compiled with NOSSRANGE, then the program may proceed further with junk or irrelevant data. Usually the programs are compiled with SSRANGE during development and testing.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 29

COMPILER OPTIONS Continued.


DYNAM: TREAT ALL UNRESOLVED CALL IDs AS DYNAMIC (RESIDENT +) Loads the Separately Compiled programs dynamically at run time that are invoked through the CALL literal. DYNAM causes dynamic loads (for CALL) and deletes (for CANCEL) of separately compiled programs at object time. When we specify DYNAM, RESIDENT is also put into effect. RENT: TO COMPILE THE PROGRAM TO BE REENTRANT (RESIDENT+) A program compiled as RENT is generated as a Re-Entrant Object Module. CICS programs should be compiled with RENT option to share the same copy of the program by multiple transactions (Multithreading).

RESIDENT: Used to request the COBOL Library Management Feature. (The COBOL Library Management Feature causes most COBOL library routines to be located dynamically at run time, instead of being link-edited with the COBOL program.). CICS Programs should be compiled with RESIENT option.
XREF: STORED CROSS REFERENCE PROV DUP/UND/EXT/IMP ERRORS Used to get a Sorted Cross-Reference Listing. EBCDIC Data-names and Procedure-names will be listed in Alphanumeric Order. It also includes listing, where all the data-names that are referenced within the program and the line number where they are defined. This is useful for identifying the fields that are defined but not used anywhere after the development of new program.
CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 30

Reference Books and Web-Links


Reference Books
Cobol Programming by M K ROY and D GHOSH DASTIDAR

Structured COBOL Programming by STERN / STERN

Web-Links
www.ibmmainframes.com

CONFIDENTIAL: For limited circulation only

2009 MindTree Limited

Slide 31

Thank You

Seema Narasimhaiah Seema_ Narasimhaiah@mindtree.com www.mindtree.com


CONFIDENTIAL: For limited circulation only 2009 MindTree Limited Slide 32

Vous aimerez peut-être aussi