93240449 cobol training new 1
TRANSCRIPT
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 1/186
Naveen Kumar / Romi Rimesh
16/06/2008
-----------------------------------------------------------------------------------
COBOL/400
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 2/186
COBOL/400- 1 -
COBOL 400
Structure of COBOL program:
A COBOL Program consists of following 4 divisions:
– IDENTIFICATION DIVISION
– ENVIRONMENT DIVISION
– DATA DIVISION
– PROCEDURE DIVISION
All the divisions must appear in the same order as shown above.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 3/186
COBOL/400- 2 -
COBOL - DIVISION1
Identification Division
It names the program and may include the date the program was written, the date of compilation,and other such documentary information about the program.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 4/186
COBOL/400- 3 -
Identification Division
– PROGRAM-ID. – AUTHOR. |
– INSTALLATION. |
– DATE-WRITTEN. | Optional
– DATE-COMPILED. |
– SECURITY. |
Coding Example:
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTPGM.
AUTHOR. PROGRAMMER NAME.
INSTALLATION. TCS.
DATE-WRITTEN. 15/02/02.
DATE-COMPILED. 15/02/02.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 5/186
COBOL/400- 4 -
COBOL - DIVISION2
Environment Division
– Configuration Section
– Input-Output Section.
The Configuration Section is optional.
When specified, it can describe the computer on which the source program is compiled and thecomputer on which the object program is executed.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 6/186
COBOL/400- 5 -
Environment Division
Configuration Section
– SOURCE-COMPUTER
– OBJECT-COMPUTER
– SPECIAL-NAMES
Input-Output Section
– File-Control.
– I-O-Control
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 7/186COBOL/400- 6 -
COBOL - DIVISION2
Configuration Section can:
– Relate IBM-defined environment-names to user-defined mnemonic names
– Specify a substitution for the currency sign
– Interchange the functions of the comma and the period in PICTURE clauses and numeric literals
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 8/186
COBOL/400- 7 -
Configuration Section
Coding Example:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-AS400.
OBJECT-COMPUTER. IBM-AS400.
SPECIAL-NAMES. TOP IS TOP-OF-PAGE.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 9/186
COBOL/400- 8 -
Input-Output Section
The Input-Output Section
– Define each file to be used
– Identify its external storage medium
– Assign the file to one or more input/ output devices
– Specify information needed for efficient transmission of data between the external medium andthe COBOL program
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 10/186
COBOL/400- 9 -
Input-Output Section
File-Control Paragraph
– Names and associates the files with the external media.
A COBOL/400 program can process:
Data Base Files:• Physical Files
• Logical Files
Device Files:• Display Files
• Tape Files
• Printer Files
• Diskette Files
• ICF Files
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 11/186
COBOL/400- 10 -
Input-Output Section
Coding Example1:
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DISPLAY-FILE
ASSIGN TO WORKSTATION-TESTDSPF
ORGANIZATION IS TRANSACTION ACCESS IS DYNAMIC
RELATIVE KEY IS RRN
FILE STATUS IS FILE-STATUS.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 12/186
COBOL/400- 11 -
Input-Output Section
Coding Example2:
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PHY-FILE1
ASSIGN TO DATABASE-PHYSICAL1
ORGANIZATION IS INDEXED ACCESS IS DYNAMIC
RECORD KEY IS EXTERNALLY-DESCRIBED-KEY
FILE STATUS IS WS-PHY-FILE1-STATUS.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 13/186
COBOL/400- 12 -
Input-Output Section
SELECT Paragraph
• Makes association between the file and the external medium
• It consists of 3 parts:
– Device
– File Name
– Attribute
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 14/186
COBOL/400- 13 -
SELECT ParagraphDEVICE:
– Specifies the type of Device that the file will use – It can be changed at run-time
List of Different Devices:
Device File
WORKSTATION Display File
DATABASE Externally described Database File
DISK Program described Database file
FORMATFILE Externally described Printer file
PRINTER Program described Printer file
TAPEFILE Tape File
DISKETTE Diskette File
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 15/186
COBOL/400- 14 -
SELECT Paragraph
FILE-NAME:
– 1 thru 10 char. system name of the actual external file
– For Database files, a member name can not be specified in the COBOL program. If a particularmember is to be specified, the OVRDBF command must be used at execution time to specify themember name
– The file-name can be changed at execution time with the TOFILE parameter of the OVRxxxFcommand
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 16/186
COBOL/400- 15 -
SELECT Paragraph
ATTRIBUTE:
– This part can be SI
– SI indicates that a separate indicator area has been specified in the DDS for the FORMATFILEor WORKSTATION file
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 17/186
COBOL/400- 16 -
SELECT Paragraph
Device File Name Default SIFile-name
WORKSTATION Required - Optional
DATABASE Required - N/A
DISK Required - N/A
FORMATFILE Required - Optional
PRINTER Optional QPRINT N/A
TAPE FILE Optional QTAPE N/A
DISKETTE Optional QDKT N/A
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 18/186
COBOL/400- 17 -
Input-Output Section
ORGANIZATION Clause
• For Database files, it indicates the use of the file in the program (permanent logical structure of thefile)
• 4 types of organization:
– Sequential
– Indexed
– Relative
– Transaction
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 19/186
COBOL/400- 18 -
Input-Output Section
SEQUENTIAL ORGANIZATION
– The physical order in which the records are placed in the file determines the sequence ofrecords
– The relationships among records in the file do not change, except that the file can be extended
– There are no keys. Both database files and device files can have sequential organization
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 20/186
COBOL/400- 19 -
Input-Output Section
INDEXED ORGANIZATION
– Each record in the file has an embedded key called a key data item that is associated with anindex
– An index provides a logical path to the data records, according to the contents of the associatedembedded record key data items
– Only database files can have indexed organization
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 21/186
COBOL/400- 20 -
Input-Output Section
RELATIVE ORGANIZATION
– Each record area is identified by a relative record number; the access method stores andretrieves a record, based on its relative record number
– Relative files must be assigned to DISK or DATABASE
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 22/186
COBOL/400- 21 -
Input-Output Section
TRANSACTION ORGANIZATION
– Work station and data communication files can have TRANSACTION organization
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 23/186
COBOL/400- 22 -
Input-Output Section
ACCESS MODE Clause
– It defines the manner in which the records of the file are made available for processing
– If the ACCESS MODE clause is not specified, sequential access is assumed
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 24/186
COBOL/400- 23 -
Input-Output Section
ACCESS MODE Clause
– Sequential Access Mode• Sequential Organization
• Indexed Organization
• Relative Organization
– Random Access Mode
• Indexed Organization• Relative Organization
– Dynamic Access Mode• Indexed Organization
• Relative Organization
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 25/186
COBOL/400- 24 -
Input-Output Section
ACCESS MODE Clause
– Sequential-Access Mode: Allows reading and writing records of a file in a serial manner; theorder of reference is implicitly determined by the position of a record in the file
– Random-Access Mode: Allows reading and writing records in a programmer-specified manner;the control of successive references to the file is expressed by specifically defined keyssupplied by the user
– Dynamic-Access Mode: Allows a specific I/O request to determine the access mode. Therefore,records may be processed sequentially and/or randomly
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 26/186
COBOL/400- 25 -
Input-Output Section
RECORD KEY Clause
– It must be specified for an indexed file
– Each record in the file must have a unique record key value
– EXTERNALLY-DESCRIBED-KEY specifies that the key(s) for this file are same that areexternally described in DDS
– WITH DUPLICATES phrase can be specified for files assigned to DATABASE
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 27/186
COBOL/400- 26 -
Input-Output Section
RECORD KEY Clause
Note:
An error will be encountered at run-time, if
• ‗DUPLICATES’ is specified in COBOL program and file was created with ‘UNIQUE” specified in DDS
• ‘DUPLICATES’ is not specified in COBOL program and file was created allowing non unique keys
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 28/186
COBOL/400- 27 -
Input-Output Section
RELATIVE KEY Clause
– It specifies the relative record number for a specific logical record within a relative file.
– The POSITION parameter on the OVRDBF command can be used to set the file positionindicator. This causes processing to begin with a record other than the first record.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 29/186
COBOL/400- 28 -
Input-Output Section
FILE-STATUS Clause
– It monitors the execution of each input-output request for the file
– In some cases it indicates the I-O errors
– It must be defined in Data Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 30/186
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 31/186
COBOL/400- 30 -
Input-Output Section
SAME AREA Clause
– It specifies that two or more files, that do not represent sort or merge files, are to use the samemain storage area during processing
– The files named in a SAME AREA clause need not have the same organization or access
– The SAME AREA clause is syntax checked, but is treated as documentation
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 32/186
COBOL/400- 31 -
Input-Output Section
SAME RECORD AREA Clause
– It specifies that two or more files are to use the same main storage area for processing thecurrent logical record. All of the files may be open at the same tim
– A logical record in the shared storage area is considered to be both of the following:
• A logical record of each opened output file in the clause
• A logical record of the most recently read input file in the clause
– This clause allows transfer of data from one file to another with no explicit data manipulationbecause the I/O record areas of named files are identical, and all are available to the user
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 33/186
COBOL/400- 32 -
Input-Output Section
SAME SORT AREA Clause
– This clause optimizes the storage area assignment to a given SORT statement
– When the SAME SORT AREA clause is specified, at least one file-name specified must name asort file. Files that are not sort files may also be specified
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 34/186
COBOL/400- 33 -
Input-Output Section
SAME SORT AREA Clause
The following rules apply:
• More than one SAME SORT AREA clause may be specified. However, a given sort file must not be namedin more than one such clause
• If a file that is not a sort file is named in both a SAME AREA clause and in one or more SAME SORT AREAclauses, all the files in the SAME AREA clause must also appear in that SAME SORT AREA clause
• Files named in a SAME SORT AREA clause need not have the same organization or access
• Files named in a SAME SORT AREA clause that are not sort files do not share storage with each otherunless the user names them in a SAME AREA or SAME RECORD AREA clause
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 35/186
COBOL/400- 34 -
Input-Output Section
SAME SORT-MERGE AREA Clause
– This clause optimizes the storage area assignment to a given SORT or MERGE statement
– When the SAME SORT-MERGE AREA clause is specified, at least one file-name specified mustname a sort or merge file. Files that are not sort or merge files may also be specified
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 36/186
COBOL/400- 35 -
Input-Output Section
SAME SORT-MERGE AREA Clause
– The following rules apply:
• More than one SAME SORT-MERGE AREA clause may be specified. However, a given sort ormerge file must not be named in more than one such clause
• If a file that is not a sort or merge file is named in both a SAME AREA clause and in one or moreSAME SORT-MERGE AREA clauses, all the files in the SAME AREA clause must also appear inthat SAME SORT-MERGE AREA clause
• Files named in a SAME SORT-MERGE AREA clause need not have the same organization oraccess
• Files named in a SAME SORT-MERGE AREA clause that are not sort or merge files do not sharestorage with each other unless the user names them in a SAME AREA or SAME RECORD AREAclause
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 37/186
COBOL/400- 36 -
Input-Output Section
COMMITMENT CONTROL Clause
– This clause specifies the files that will be placed under commitment control when they areopened. These files will be affected by the COMMIT and ROLLBACK statements
– The COMMIT statement allows the synchronization of changes to database records whilepreventing other jobs from modifying those records until the COMMIT is complete
– The ROLLBACK statement provides a method of canceling changes made to database fileswhen those changes should not be made permanent
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 38/186
COBOL/400- 37 -
Input-Output Section
COMMITMENT CONTROL Clause
– This clause can specify only files assigned to a device type of DATABASE
– Files under commitment control may have an organization of sequential, relative or indexed, andmay have any access mode valid for a particular organization
– The system locks records contained in files under commitment control when these records are
accessed. Records remain locked until released by a COMMIT or ROLLBACK statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 39/186
COBOL/400- 38 -
COBOL - DIVISION3
Data Division
– The Data Division of a COBOL source program describes, in a structured manner, all the data tobe processed by the object program
– This section outlines the structure of the Data Division and explains the types of data and howthey are related in a COBOL program
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 40/186
COBOL/400- 39 -
Data Division
• File Section
– Describes externally stored data (including sort-merge files)
• Working-Storage Section
– Describes internal data
• Linkage Section
– Describes data made available by another program.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 41/186
COBOL/400- 40 -
Data Division
Coding Example:
DATA DIVISION.
FILE SECTION.
FD DISPLAY-FILE.
01 DISPLAY-REC
COPY DD-ALL-FORMATS OF TESTDSPF.
FD PHY-FILE1.
01 PHY-FILE1-RCD.
COPY DDS-ALL-FORMATS OF PHYSICAL1.
FD PHY-FILE2.
01 PHY-FILE2-REC.
COPY DDSR-ALL-FORMATS OF PHYSICAL2.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 42/186
COBOL/400- 41 -
Data Division
WORKING-STORAGE SECTION.
FD DISPLAY-FILE.
01 PHYSICAL2-PARMS.
05 PHYSICAL2-PRODCD PIC X(04).
05 PHYSICAL2-INV PIC S9(03).
05 PHYSICAL2-STATUS PIC X(01).
88 PHYSICAL2-NONE-FOUND VALUE "0".
88 PHYSICAL2-ALL-VERIFIED VALUE "1".
88 PHYSICAL2-UNVERIFIED VALUE "2".
77 ERR-MESSAGE PIC X(80)
VALUE SPACES.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 43/186
COBOL/400- 42 -
Data Division
LINKAGE SECTION.
01 FUNCTION-MEMBER.
05 FUNCTION-CODE PIC X.
88 END-OF-PGM VALUE SPACES.
88 ENTRY-OPERATION VALUE "E".
88 VERIFY-OPERATION VALUE "V".
05 MEMBER-CODE PIC X.
88 ENTRY-MEMBER VALUE "E".
88 CLUSTER-MEMBER VALUE "C".
01 USER-ID PIC X(10).
01 JOB-NUMBER PIC X(10).
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 44/186
COBOL/400- 43 -
File Section
• For all files except sort/merge, the File Section must contain an FD (File Description) entry
• For each sort or merge file, the File Section must contain an SD (Sort Description) entry
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 45/186
COBOL/400- 44 -
File Section
file-description-entry
• Represent the highest level of organization in the File Section
• Provide information about the physical structure and identification of a file, and gives the record-name(s) associated with that file
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 46/186
COBOL/400- 45 -
File Section
record-description-entry
• A set of data description entries that describe the particular record(s) contained within a particularfile
• More than one record description entry may be specified; each is an alternative description of thesame record storage area
• Data areas described in the File Section are not available for processing unless the file containingthe data area is open
• The initial value of a data item in the File Section is undefined
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 47/186
COBOL/400- 46 -
File Section
file-name
• Must follow the level indicator (FD or SD), and must be the same as that specified in the associatedSELECT clause
• The file-name must be unique within this program
• One or more record description entries must follow the file-name. When more than one record
description entry is specified, each entry implies a redefinition of the same storage area
• The clauses that follow file-name are optional; they may appear in any order
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 48/186
COBOL/400- 47 -
File Section
BLOCK CONTAINS Clause
– Specify the size of the physical records
– If the records in the file are not blocked, the clause may be omitted
– This clause is always active for tape files, but is syntax-checked only for diskette files
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 49/186
COBOL/400- 48 -
File Section
RECORDS
– Specify the number of logical records contained in each physical record
– Maximum record size is 32766; maximum block size is 32766
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 50/186
COBOL/400- 49 -
File Section
RECORD CONTAINS Clause
– Specify the number of character positions for fixed length records
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 51/186
COBOL/400- 50 -
File Section
RECORD CONTAINS Clause
– Specify the number of character positions for fixed length records
– When the record length determined from the record description entries does not match thelength specified in the RECORD CONTAINS clause, the former will be used
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 52/186
COBOL/400- 51 -
File Section
LABEL RECORDS Clause
– Indicate the presence or absence of labels
– If it is not specified for a file, label records for that file must conform to the system labelspecifications
– Generally treated as documentation
STANDARD
Labels conforming to system specifications exist for this file
OMITTED
No labels exist for this file
Note: The LABEL RECORDS clause is an obsolete element and is to be deleted from the next revision of the
ANSI Standard
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 53/186
COBOL/400- 52 -
File Section
VALUE OF Clause
– Describe an item in the label records associated with this file
– The clause is syntax checked, then treated as documentation
Note: The VALUE OF clause is an obsolete element and will be deleted from the next revision of the ANSI
Standard
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 54/186
COBOL/400- 53 -
Data Types
• File Data (External Data)
– File data is contained in files
• Program Data (Internal Data)
– Program data is created by the program itself
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 55/186
COBOL/400- 54 -
Data Types
Data Relationships
– The relationships among all data to be used in a program are defined in the Data Division,through a system of level indicators and level-numbers
– A level indicator, with its descriptive entry, identifies each file in a program. Level indicatorsrepresent the highest level of any data hierarchy with which they are associated; FD is the filedescription level indicator and SD is the sort-merge file description level indicator
– A level-number, with its descriptive entry, indicates the properties of specific data
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 56/186
COBOL/400- 55 -
Data Types
Levels of Data
• After a record has been defined, it can be subdivided to provide more detailed data references
• A system of level-numbers specifies the organization of elementary and group items into records.Special level- numbers are also used; they identify data items used for special purposes
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 57/186
COBOL/400- 56 -
Data Types
• A level-number is a 1- or 2-digit integer between 01 and 49, or one of three special level-numbers:
66, 77, or 88
• The following level-numbers are used to structure records:
– 01 Specify the record itself, and is the most inclusive level- number possible. Alevel-01 entry may be either a group item or an elementary item
– 02-49 Specify group and elementary items within a record
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 58/186
COBOL/400- 57 -
Data Types
Special Level-Numbers
• Special level-numbers identify items that do not structure a record. The special level-numbers are:
– 66 Identifies items that must contain a RENAMES clause; such items regrouppreviously defined data items
– 77 Identifies data item description entries — independent Working-
Storage or Linkage Section items that are not subdivisions of other items, andare not sub-divided themselves
– 88 Identifies any condition-name entry that is associated with a particularvalue of a conditional variable
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 59/186
COBOL/400- 58 -
Data Types
BLANK WHEN ZERO Clause
– Specify that an item contains nothing but spaces when its value is zero
– Specify only for elementary numeric or numeric-edited items
– These items must be described, either implicitly or explicitly, as USAGE IS DISPLAY. When thisclause is specified for a numeric item, the item is considered a numeric-edited item
– Must not be specified for level-66 or level-88 items
– Not allowed for items described with the USAGE IS INDEX clause or the USAGE IS POINTERclause
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 60/186
COBOL/400- 59 -
Data Types
JUSTIFIED Clause
– Override standard positioning rules for a receiving item of the alphabetic or alphanumericcategories
– May be specified only at elementary level. JUST is an abbreviation for JUSTIFIED, and has thesame meaning. RIGHT is an optional word and has no effect on the execution of the program
– Cannot be specified for numeric, numeric-edited, or alphanumeric-edited items
– Must not be specified with level-66 (RENAMES) and level-88 (condition-name) entries
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 61/186
COBOL/400- 60 -
Data Types
Coding Example:
01 WS-DATE628-PARMS.
05 CVTDATE PIC X(6) JUSTIFIED RIGHT.
05 RTNDATE PIC X(8).
05 DTERR PIC X.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 62/186
COBOL/400- 61 -
Data Types
LIKE Clause
– Define the PICTURE, USAGE, and SIGN characteristics of a data item by copying them from apreviously defined data item
– Make the length of the data item you define different from the length of the original item
– Cause the new data item to inherit specific characteristics from the existing data item. These
characteristics are the PICTURE, USAGE, SIGN, and BLANK WHEN ZERO attributes of theexisting item
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 63/186
COBOL/400- 62 -
Data Types
Coding Example:
01 EMPLOYEE-RECORDS PIC 1.
88 MORE-EMPLOYEE-RECORDS VALUE B"1".
88 NO-MORE-EMPLOYEE-RECORDS VALUE B"0".
01 NEW- EMPLOYEE -REC.
05 NEW-EMPLOYEE-RECORD LIKE EMPLOYEE-RECORD.
01 WS-CNT1 PIC S9(3).
01 WS-CNT2 Like WS-CNT1.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 64/186
COBOL/400- 63 -
Data Types
PICTURE Clause
– Specify the general characteristics and editing requirements of an elementary item
– Must be specified for every elementary item except an index data item or the subject of theRENAMES clause
– The PICTURE character-string may contain a max of 30 chars
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 65/186
COBOL/400- 64 -
Data Types
Coding Example:
LINKAGE SECTION.
01 FROMDATE.
05 FROMMM PIC 99.
05 FROMDD PIC 99.
05 FROMYY PIC 99.
01 TODATE.
05 TOMM PIC 99.
05 TODD PIC 99.
05 TOYY PIC 99.
01 DAYS PIC S9(7) COMP-3.
01 STATUS-CODE PIC 1.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 66/186
COBOL/400- 65 -
Data Types
REDEFINES Clause
– To use different data description entries to describe the same computer storage area
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 67/186
COBOL/400- 66 -
Data Types
Coding Example:
01 TODAYS-DATE.
05 DATE-YY PIC XX.
05 DATE-MM PIC XX.
05 DATE-DD PIC XX.
01 TODAYS-DATE-HOLD REDEFINES TODAYS-DATE PIC 9(6).
01 TODAYS-DATE PIC X(6).
01 TODAYS-DATE-HOLD REDEFINES TODAYS-DATE.
05 DATE-YY PIC XX.
05 DATE-MM PIC XX.
05 DATE-DD PIC XX.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 68/186
COBOL/400- 67 -
Data Types
RENAMES Clause
– Specify alternative, possibly overlapping, groupings of elementary data items
– The special level-number 66 must be specified for data description entries that contain theRENAMES clause
– One or more RENAMES entries can be written for a logical record
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 69/186
COBOL/400- 68 -
Data Types
Coding Example:
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE
ASSIGN TO DATABASE-EMPLOYEE ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS EMPID
FILE STATUS IS WS-EMPLOYEE-STATUS.
FILE SECTION.
FD EMPLOYEE
01 EMP-REC.
COPY DDS-EMPREC OF EMPLOYEE.
66 EMPID RENAMES EMPNO IN EMP-REC
THRU DOJ IN EMP-REC.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 70/186
COBOL/400- 69 -
Data Types
Coding Example:
MOVE WS-EMPNO TO EMPNO OF EMP-REC.
MOVE WS-DOJ TO DOJ OF EMP-REC.
IF WS-EMPNO > ZERO THEN
SET ONE-EMPOYEE TO TRUE.
START EMPLOYEE KEY NOT < EMPID
INVALID KEY
MOVE ―Invalid Emp No.‖ TO WS-ERR.MSG
END-START.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 71/186
COBOL/400- 70 -
Data Types
SIGN Clause
– Specify the position and mode of representation of the operational sign for a numeric entry
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 72/186
COBOL/400- 71 -
Data Types
USAGE Clause
– Specify for an entry at any level. However, if it is specified at the group level, it applies to eachelementary item in the group
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 73/186
COBOL/400- 72 -
Data Types
Coding Example:
01 EMPLOYEE-WORK-FIELDS.
05 EMPLOYEE-FILE-STATUS PIC X(2).
05 EMPLOYEE-END-OF-PAGE PIC X(1) VALUE "N".
05 EMPLOYEE-SALARY PIC 9(7)
USAGE PACKED-DECIMAL
VALUE ZERO.
01 EMPLOYEE-WORK-FIELDS.
05 EMPLOYEE-FILE-STATUS PIC X(2).
05 EMPLOYEE-RRN PIC 9(5)
USAGE IS COMP.
01 RECORD-COUNT PIC S9(10)V9(5) COMP-3 VALUE 0.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 74/186
COBOL/400- 73 -
Data Types
Computational Items
– Value used in arithmetic operations
– Must be numeric
– The maximum length of a computational item is 18 decimal digits
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 75/186
COBOL/400- 74 -
Data Types
BINARY
– Specified for binary data items
PACKED-DECIMAL
– Specified for internal decimal items
COMPUTATIONAL or COMP
– Specified for internal decimal items
COMPUTATIONAL-3 or COMP-3 (internal decimal)
– This is the equivalent of PACKED-DECIMAL
COMPUTATIONAL-4 or COMP-4 (binary)
– This is the equivalent of BINARY
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 76/186
COBOL/400- 75 -
Data Types
VALUE Clause
– Specify the initial contents of a data item or the value(s) associated with a condition-name
– Use of the VALUE clause differs depending on the Data Division section in which it is specified;In the File and Linkage sections, the VALUE clause must be used only in condition-nameentries;
in the Working-Storage Section, the VALUE clause may be used in condition-name entries, or in
specifying the initial value of any data item
– The data item assumes the specified value at the beginning of program execution.
– If the initial value is not explicitly specified, it is unpredictable
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 77/186
COBOL/400- 76 -
Working-Storage Section
• The Working-Storage Section describes data records that are not part of external data files but are
developed and processed internally
• The Working-Storage Section contains record description entries and data description entries forindependent data items, called data item description entries
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 78/186
COBOL/400- 77 -
Working-Storage Section
record-description-entry
• Data entries in the Working-Storage Section that bear a definite hierarchic relationship to oneanother must be grouped into records structured by level number
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 79/186
COBOL/400- 78 -
Working-Storage Section
data-item-description-entry
• Independent items in the Working-Storage Section that bear no hierarchic relationship to oneanother need not be grouped into records, provided that they do not need to be further subdivided.Instead, they are classified and defined as independent elementary items. Each is defined in aseparate data-item description entry that begins with either the level number 77 or 01
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 80/186
COBOL/400- 79 -
Working-Storage Section
• The initial value of any data item in the Working-Storage Section, except an index data item, is
specified by associating a VALUE clause with the item
• The initial value of any index data item, or of any data item not associated with a VALUE clause, isundefined
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 81/186
COBOL/400- 80 -
Linkage Section
• Describe data made available from another program
• Record description entries and data item description entries in the Linkage Section provide namesand descriptions, but storage within the program is not reserved because the data area existselsewhere
• Any data description clause may be used to describe items in the Linkage Section, with oneexception: the VALUE clause may not be specified for items other than level-88 items
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 82/186
COBOL/400- 81 -
Linkage Section
Coding Example:
LINKAGE SECTION.
01 FROMDATE.
05 FROMMM PIC 99.
05 FROMDD PIC 99.
05 FROMYY PIC 99.
01 TODATE.
05 TOMM PIC 99.
05 TODD PIC 99.05 TOYY PIC 99.
01 DAYS PIC S9(7) COMP-3.
01 STATUS-CODE PIC 1.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 83/186
COBOL/400- 82 -
COBOL - DIVISION4
Procedure Division
Consists of optional declaratives, and procedures that contain sections and/or paragraphs,sentences, and statements
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 84/186
COBOL/400- 83 -
Procedure Division
Procedure Division Header
• The USING Phrase
– Required only if the object program is to be invoked by a CALL statement and that statementincludes a USING phrase
– Makes data items defined in a calling program available to a called subprogram
– Each USING identifier must be defined as a level-01 or level-77 item in the Linkage Section ofthe called subprogram
– Must not contain a REDEFINES clause
– Maximum number of data-names - 30
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 85/186
COBOL/400- 84 -
Procedure Division
Declaratives
– Provide one or more special-purpose sections that are executed when an exceptional conditionoccurs
– When Declarative Sections are specified, they must be grouped at the beginning of theProcedure Division, and the entire Procedure Division must be divided into sections
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 86/186
COBOL/400- 85 -
Procedure Division
Procedures
– Within the Procedure Division, a procedure consists of:
• A section or a group of sections
• A paragraph or group of paragraphs
– A procedure-name is a user-defined name that identifies a section or a paragraph
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 87/186
COBOL/400- 86 -
Procedure Division
Section
A section header optionally followed by one or more paragraphs
– Section-header
– A section-name followed by:
• the keyword SECTION
• an optional segment-number
• a separator period
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 88/186
COBOL/400- 87 -
Procedure Division
Section-name
– A user-defined word that identifies a section
– If referenced, a section-name must be unique within the program in which it is defined
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 89/186
COBOL/400- 88 -
Procedure Division
Paragraph
A paragraph-name followed by a separator period, optionally followed by one or more sentences
Paragraph-name
– A user-defined word that identifies a paragraph
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 90/186
COBOL/400- 89 -
Procedure Division
Sentence
One or more statements terminated by a separator period
Statement
– A syntactically valid combination of identifiers and symbols beginning with a COBOL verb
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 91/186
COBOL/400- 90 -
Procedure Division
Identifier
– A syntactically correct combination of a data name
– In any Procedure Division reference, the contents of an identifier must be compatible with theclass specified through its PICTURE clause, or results are unpredictable
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 92/186
COBOL/400- 91 -
Procedure Division
Coding Example:
PROCEDURE DIVISION.
DECLARATIVES.
ERROR-IT SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON INPUT-DATA.
ERROR-ROUTINE.
IF CHECK-IT = "30" ADD 1 TO DECLARATIVE-ERRORS.
END DECLARATIVES.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 93/186
COBOL/400- 92 -
Procedure Division
Common Phrases
There are several phrases common to arithmetic and data manipulation statements; these phrasesare described below
CORRESPONDING Phrase
– Allows ADD, SUBTRACT, and MOVE operations to be performed on elementary data items of
the same name if the group items to which they belong are specified
– Both identifiers following the key word CORRESPONDING must name group items
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 94/186
COBOL/400- 93 -
Procedure Division
Coding Example:
MOVE CORRESPONDING DATE-YYMMDD TO DATE-WITH-SLASHES.
01 DATE-YYMMDD.
05 YY PIC XX.
05 MM PIC XX.
05 DD PIC XX.
01 DATE-WITH-SLASHES.05 MM PIC XX.
05 SLASHA PIC X VALUE "/".
05 DD PIC XX.
05 SLASHB PIC X VALUE "/".
05 YY PIC XX.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 95/186
COBOL/400- 94 -
Procedure Division
GIVING Phrase
– The value of the identifier that follows the word GIVING is set equal to the calculated result ofthe arithmetic operation
– Because this identifier is not involved in the computation, it may be a numeric edited item
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 96/186
COBOL/400- 95 -
Procedure Division
Coding Example:
SUBTRACT SUB1 FROM SUB2 GIVING RESULT.
DIVIDE NUM1 BY 10 GIVING RESULT.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 97/186
COBOL/400- 96 -
Procedure Division
ROUNDED Phrase
– After decimal point alignment, the number of places in the fraction of the result of an arithmeticoperation is compared with the number of places provided for the fraction of the resultantidentifier
– When the size of the fractional result exceeds the number of places provided for its storage,truncation occurs unless ROUNDED is specified. When ROUNDED is specified, the leastsignificant digit of the resultant identifier is increased by 1 when-ever the most significant digit of
the excess is greater than or equal to 5
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 98/186
COBOL/400- 97 -
Procedure Division
Coding Example:
DIVIDE NUM1 BY 10 GIVING RESULT ROUNDED.
COMPUTE RESULT ROUNDED = NUM1 * NUM2.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 99/186
COBOL/400- 98 -
Procedure Division
SIZE ERROR Phrases
– A size error condition can occur in three different ways:
• When the absolute value of the result of an arithmetic evaluation, after decimal point alignment, exceeds thelargest value that can be contained in the result field
• When division by zero occurs
• In an exponential expression, when
– Zero raised to the exponent Zero
– Zero raised to a negative exponent
– A negative number raised to a fractional exponent
– The size error condition applies only to final results, not to any intermediate results
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 100/186
COBOL/400- 99 -
Procedure Division
Coding Example:
ADD 1 TO NUM1
ON SIZE ERROR MOVE 0 TO NUM1
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 101/186
COBOL/400- 100 -
Procedure Division
Input-Output Statements
– Transfer data to and from files stored on external media
– Control low-volume data that is obtained from or sent to an input/output device
Common Processing Facilities
Applied to more than one input-output statement:
• Status key
• INVALID KEY condition
• INTO/FROM identifier phrase
• File position indicator
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 102/186
COBOL/400- 101 -
Procedure Division
Status Key
– If the FILE STATUS clause is specified in the FILE-CONTROL entry, a value is placed in thespecified status key (the 2-character data item named in the FILE STATUS clause) duringexecution of any request on that file, which indicates the status of that request
– The value is placed in the status key before execution of any EXCEPTION/ERROR declarativeor INVALID KEY/AT END phrase associated with the request
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 103/186
COBOL/400- 102 -
Procedure Division
Coding Example:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PROJECT-FILE
ASSIGN TO DATABASE_PROJECT
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS EXTERNALLY-DESCRIBED-KEY
FILE STATUS IS WS-PROJECT-FILE-STATUS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-PROJECT-FILE-STATUS PIC XX.
88 WS-IO-SUCCESSFUL VALUE "00" THRU "09".
88 WS-END-OF-FILE VALUE "10" THRU "19".
88 WS-INVALID-KEY VALUE "20" THRU "29".
88 WS-IO-ERROR VALUE "30" THRU "99".
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 104/186
COBOL/400- 103 -
Procedure Division
INVALID KEY Condition
– Can occur during execution of a START, READ, WRITE, REWRITE, or DELETE statement
– When occurs, the input-output statement that caused the condition is unsuccessful
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 105/186
COBOL/400- 104 -
Procedure Division
Coding Example:
READ PROJECT RECORD
INVALID KEY
MOVE "N" TO PROJECT-RECORD-FOUND
NOT INVALID KEY
MOVE "Y" TO PROJECT-RECORD-FOUND
END-READ.
IF WS-PROJECT-FILE-STATUS >= "30"MOVE "N" TO PROJECT-RECORD-FOUND
END-IF.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 106/186
COBOL/400- 105 -
Procedure Division
INTO/FROM Identifier Phrase
– Valid for READ, RETURN, RELEASE, REWRITE, and WRITE statements
– The identifier specified must be the name of an entry in the Working-Storage Section or theLinkage Section, or of a record description for another previously opened file
– Record-name/file-name and identifier must not refer to the same storage area
– The INTO phrase may be specified in a READ or RETURN statement
– The FROM phrase may be specified in a RELEASE, REWRITE, or WRITE statement
P d Di i i
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 107/186
COBOL/400- 106 -
Procedure Division
Coding Example:
READ PROJECT RECORD
INTO WS-PROJECT
FORMAT IS "PROJECT1"
INDICATORS ARE WS-INDICATOR-TABLE
END-READ.
REWRITE SUBFILE PROJECT-RCD
FROM WS-PROJECT1SFL-OFORMAT IS ―PROJECT11SFL"
INDICATORS ARE WS-INDICATOR-TABLE
INVALID KEY CONTINUE
END-REWRITE.
P d Di i i
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 108/186
COBOL/400- 107 -
Procedure Division
Procedure Division Statements
ACCEPT Statement
– Transfer data into the specified identifier
– No editing or error checking of the incoming data
P d Di i i
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 109/186
COBOL/400- 108 -
Procedure Division
Coding Example:
ACCEPT SYSTEM-DATE FROM DATE.
ACCEPT SYSTEM-TIME FROM TIME.
P d Di i i
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 110/186
COBOL/400- 109 -
Procedure Division
ACQUIRE Statement
– Acquire a program device for a TRANSACTION file
P d Di i i
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 111/186
COBOL/400- 110 -
Procedure Division
ADD Statement
– Sum two or more numeric operands and stores the result
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 112/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 113/186
COBOL/400- 112 -
Procedure Division
CALL Statement
– Transfer control from one object program to another within the run unit
– Pass control to the first non-declarative instruction of the called subprogram
– Called subprograms themselves can contain CALL statements, but a called subprogram thatcontains a CALL statement that directly or indirectly calls the calling program givesunpredictable results
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 114/186
COBOL/400- 113 -
Procedure Division
Coding Example:
CALL "XXXVALIDDT" USING DATE-CHECK.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 115/186
COBOL/400- 114 -
Procedure Division
CANCEL Statement
– Ensure that the next time the referenced subprogram is called it will be entered in its initial state
– Close all open files
– Operate only on the program specified, and not on any program that may have been called bythe canceled program
– No action is taken when a CANCEL statement is executed, naming a program that has not beencalled in the run unit, or that names a program that was called and subsequently canceled. Ineither case, control passes to the next statement
– If names a program that does not exist in the library list, an error message is issued
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 116/186
COBOL/400- 115 -
Procedure Division
Coding Example:
CANCEL "XXXVALIDDT―.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 117/186
COBOL/400- 116 -
Procedure Division
CLOSE Statement
– Terminate the processing of volumes and files, with optional rewind and/or lock or removal,where applicable
– Terminate the processing of volumes and files, with optional rewind and/or lock or removal,where applicable
– If the file is in an open status and the execution of a CLOSE statement is unsuccessful, theEXCEPTION/ERROR procedure (if specified) for this file is executed
– If a CLOSE statement for an open file is not processed before a STOP RUN for this run unit, thefile is implicitly closed
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 118/186
COBOL/400- 117 -
Procedure Division
Coding Example:
CLOSE PROJECT.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 119/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 120/186
COBOL/400- 119 -
Procedure Division
COMPUTE Statement
– Assign the value of an arithmetic expression to one or more data items
– With the COMPUTE statement, arithmetic operations can be combined without the restrictionson receiving data items imposed by the rules for the ADD, SUBTRACT, MULTIPLY, andDIVIDE statements
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 121/186
COBOL/400- 120 -
Procedure Division
Coding Example:
COMPUTE RESULT = NUM1 - 1.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 122/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 123/186
COBOL/400- 122 -
Procedure Division
Coding Example:
READ PROJECT
INVALID KEY
CONTINUE
END-READ.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 124/186
COBOL/400- 123 -
Procedure Division
DELETE Statement
– Remove a record from an indexed or relative file
– For indexed files, the key may then be reused for record addition
– For relative files, the space is then available for a new record with the same RELATIVE KEYvalue
– File must be open in I-O mode
– Record is logically removed from the file and can no longer be accessed
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 125/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 126/186
COBOL/400- 125 -
Procedure Division
DISPLAY Statement
– Transfer the contents of each operand to the output device
– Contents are displayed on the output device in the order, left to right, in which the operands arelisted
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 127/186
COBOL/400- 126 -
Procedure Division
Coding Example:
DISPLAY IO-ERR-MSG UPON CNSL.
DISPLAY USER-MSG.
SPECIAL-NAMES. SYSTEM-CONSOLE IS CNSL.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 128/186
COBOL/400- 127 -
Procedure Division
DIVIDE Statement
– Divide one numeric data item into or by one or more others, and sets the values of data itemsequal to the quotient and remainder
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 129/186
COBOL/400- 128 -
Procedure Division
Coding Example:
DIVIDE WS-HOURS BY 24
GIVING WS-DAYS
REMAINDER WS-REMAINDER-HOURS.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 130/186
COBOL/400- 129 -
EVALUATE Statement
– Provide a shorthand notation for a series of nested IF statements
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 131/186
COBOL/400- 130 -
IF (MENU-INPUT = ‖0") THEN
PERFORM INIT-PROC
ELSE
IF (MENU-INPUT >= "1") AND (MENU-INPUT <= "9") THEN
PERFORM PROCESS-PROC
ELSE
IF (MENU-INPUT = "R") THEN
PERFORM READ-PARMS
ELSE
IF (MENU-INPUT = "X") THEN
PERFORM CLEANUP-PROC
ELSE
PERFORM ERROR-PROCEND-IF
END-IF
END-IF
END-IF.
EVALUATE MENU-INPUT
WHEN ‖0"
PERFORM INIT-PROCWHEN "1" THRU "9"
PERFORM PROCESS-PROC
WHEN "R"
PERFORM READ-PARMS
WHEN "X"
PERFORM CLEANUP-PROC
WHEN OTHER
PERFORM ERROR-PROC
END-EVALUATE.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 132/186
COBOL/400- 131 -
EXIT Statement
– Provide a common end point for a series of paragraphs
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 133/186
COBOL/400- 132 -
Coding Example:
200-PROCESS.
IF PROJECT-FOUND = ―Y"
PERFORM 250-PARA1
ELSE
PERFORM 260-PARA2
END-IF.
200-EXIT.
EXIT.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 134/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 135/186
COBOL/400- 134 -
Coding Example:
END-OF-JOB.
IF NO-PROJ-ERROR THEN
CLOSE PROJECT.
IF NO-DISPLAY-ERROR THEN
CLOSE DISPLAY-FILE.
EOJ-EXIT.
EXIT PROGRAM.
STOP RUN.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 136/186
COBOL/400- 135 -
GOBACK Statement
– Function like the EXIT PROGRAM statement when it is coded as part of a program that is asubprogram in a COBOL run unit, and like the STOP RUN statement when coded in a programthat is a main program in a COBOL run unit
– Specify the logical end of a program
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 137/186
COBOL/400- 136 -
Coding Example:
PROCEDURE DIVISION USING LINK-PARMS.
100-MAIN.
IF PROJECT-FOUND = ―Y"
PERFORM 150-PARA1
ELSE
PERFORM 250-PARA2
END-IF.
GOBACK.100-EXIT.
EXIT.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 138/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 139/186
COBOL/400- 138 -
Coding Example:
IF PROJECT1 NOT = PROJECT2 THEN
GO TO 220-READ-NEXT-PROJECT
END-IF
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 140/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 141/186
COBOL/400- 140 -
Coding Example:
IF (MENU-INPUT >= "1") AND (MENU-INPUT <= "9") THEN
PERFORM PROCESS-PROC
ELSE
IF (MENU-INPUT = "R") THEN
PERFORM READ-PARMS
END-IF
END-IF.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 142/186
COBOL/400- 141 -
INITIALIZE Statement
– Sets selected categories of data fields to predetermined values
– Functionally equivalent to one or more MOVE statements
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 143/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 144/186
COBOL/400- 143 -
INSPECT Statement
– Specify that characters in a data item are to be counted (tallied) or replaced or both
– Count the occurrence of a specific character (alphabetic, numeric, or special character) in adata item
– Fill all or portions of a data item with spaces or zeros
– Translate characters from one collating sequence to another
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 145/186
COBOL/400- 144 -
Coding Example:
INSPECT WS-PAGE-IN-ERROR
REPLACING LEADING ZEROS BY SPACES.
INSPECT PROJECT1-FIELD1
TALLYING WS-SPACE-CNTR FOR ALL ― ―.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 146/186
COBOL/400- 145 -
MERGE Statement
– Combine two or more identically sequenced files (that is, files that have already been sortedaccording to an identical set of ascending/ descending keys) on one or more keys and makesrecords available in merged order to an output procedure or output file
– May appear anywhere in the Procedure Division except in a Declarative Section
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 147/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 148/186
COBOL/400- 147 -
Coding Example:
MOVE NUM1 TO NUM2
MOVE "MISSING OR INVALID VALUE" TO WS-ERROR-MESSAGE.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 149/186
COBOL/400- 148 -
MULTIPLY Statement
– Multiplies numeric items and sets the values of data items equal to the results
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 150/186
COBOL/400- 149 -
Coding Example:
MULTIPLY NUM1 BY NUM2 GIVING RESULT.
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 151/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 152/186
COBOL/400- 151 -
Sequential files
– At least one of the phrases, INPUT, OUTPUT, I-O, or EXTEND, must be specified with theOPEN keyword
– The INPUT, OUTPUT, I-O, and EXTEND phrases may appear in any order
Indexed and Relative Files
– At least one of the phrases, INPUT, OUTPUT, or I-O, must be specified with the OPEN
keyword. The INPUT, OUTPUT, and I-O phrases may appear in any order
Transaction Files
– A TRANSACTION file must be opened in the I-O mode
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 153/186
COBOL/400- 152 -
Coding Example:
OPEN I-O FILE1.
OPEN INPUT FILE2,
FILE3.
OPEN OUTPUT FILE4.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 154/186
COBOL/400- 153 -
PERFORM Statement
– Transfer control explicitly to one or more procedures and implicitly returns control to thenext executable statement after execution of the specified procedure(s) or imperativestatements is completed
– 4 PERFORM statement formats:
1. Basic PERFORM
2. TIMES phrase PERFORM3. UNTIL phrase PERFORM
4. VARYING phrase PERFORM
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 155/186
COBOL/400- 154 -
Coding Example:
PERFORM 110-INITIALIZATION.
PERFORM 300-LOAD-PROJECTS
VARYING CNT1 FROM 1 BY 1
UNTIL CNT1 > PROJECT-COUNT
END-PERFORM.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 156/186
COBOL/400- 155 -
READ Statement
– Make a record available to the program
– Associated file must be open in INPUT or I-O mode
– For sequential access, the READ statement makes the next logical record from a file availableto the object program
– For random access, the READ statement makes a specified record from a direct-access fileavailable to the object program
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 157/186
COBOL/400- 156 -
Coding Example:
READ PROJECT-FILE
INVALID KEY SET INVALID-PROJ TO TRUE
END-READ.
READ PROJECT-FILE-L NEXT RECORD
AT END PERFORM 300-END-OF-FILE-PROCESSING
END-READ .
READ PROJECT-FILE
AT END SET END-OF-FILE TO TRUE
END-READ.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 158/186
COBOL/400- 157 -
RELEASE Statement
– Transfer records from an input/output area to the initial phase of a sorting operation
– Can only be used within the range of an input procedure associated with a SORT statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 159/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 160/186
COBOL/400- 159 -
REWRITE Statement
– Logically replace an existing record in a direct-access file
– Associated direct-access file must be open in I-O mode
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 161/186
COBOL/400- 160 -
REWRITE Statement for Sequential Files
– When the access mode is sequential, the last prior input/output statement executed for this filemust be a successfully executed READ statement. When the REWRITE statement is executed,the record retrieved by that READ statement is logically replaced
– The INVALID KEY phrase must not be specified for a file with sequential organization
– An EXCEPTION/ERROR procedure may be specified
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 162/186
COBOL/400- 161 -
REWRITE Statement for Indexed Files
– When the access mode is sequential, the record to be replaced is specified by the valuecontained in the prime RECORD KEY. When the REWRITE statement is executed, this valuemust equal the value of the prime record key data item in the last record read from this file
– The INVALID KEY phrase must be specified if an applicable USE AFTER STANDARDEXCEPTION procedure is not specified for the associated file-name
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 163/186
COBOL/400- 162 -
REWRITE Statement for Relative Files
– For relative files in sequential access mode, the INVALID KEY phrase must not be specified
– An EXCEPTION/ERROR procedure may be specified
– The INVALID KEY phrase must be specified in the REWRITE statement for relative files in therandom or dynamic access mode, and for which an appropriate USE AFTER STANDARDEXCEPTION procedure is not specified
– When the access mode is random or dynamic, the record to be replaced is specified in theRELATIVE KEY data item
– If the file does not contain the record specified, an invalid key condition exists, and, if specified,the INVALID KEY imperative-statement is executed
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 164/186
COBOL/400- 163 -
Coding Example:
REWRITE PROJECT-RCD
INVALID KEY
CONTINUE
END-REWRITE.
REWRITE SUBFILE PROJECT-RCD
FROM WS-LIST1SFL-O
FORMAT IS "LIST1SFL"
INDICATORS ARE WS-INDICATOR-TABLE
INVALID KEY CONTINUE
END-REWRITE.
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 165/186
COBOL/400- 164 -
ROLLBACK Statement
– Provide a way to cancel one or more changes to data-base records when the changes shouldnot remain permanent
– Any changes made to files under commitment control since the last commitment boundary areremoved from the database
– A commitment boundary is the previous occurrence of a ROLLBACK or COMMIT statement
– If no COMMIT or ROLLBACK has been issued, the commitment boundary is the first OPEN of afile under commitment control
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 166/186
COBOL/400- 165 -
– Removal of changes takes place for all files under commitment control in the job, and not justfor files under commitment control in the COBOL program that issues the ROLLBACK
– All record locks held by the job for files under commitment control are released and the recordsbecome available to other jobs
– Has no effect on files not under commitment control
– If a ROLLBACK is executed and there are no files under commitment control, the ROLLBACK is
ignored
– A ROLLBACK, when executed, leaves files in the same open or closed state as beforeexecution
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 167/186
COBOL/400- 166 -
SEARCH Statement
– Search a table for an element that satisfies the specified condition, and adjusts the associatedindex to indicate that element
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 168/186
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 169/186
COBOL/400- 168 -
SET Statement
– Establish reference points for table handling operations by doing one of the following:
1. Placing values associated with table elements into indexes associated with index-names
2. Incrementing or decrementing an occurrence number
3. Setting the status of an external switch to ON or OFF
4. Moving data to condition names to make conditions true
5. Setting addresses of pointer data items
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 170/186
COBOL/400- 169 -
Coding Example:
SET PARM-ERROR-FOUND TO TRUE.
READ PROJECT-RECORD
AT END SET NO-MORE-RECORDS TO TRUE
END-READ.
Procedure Division
SORT St t t
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 171/186
COBOL/400- 170 -
SORT Statement
– Accept records from one or more files, sorts them according to the specified key(s), and makesthe sorted records available either through an OUTPUT PROCEDURE or in an output file
Procedure Division
START St t t
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 172/186
COBOL/400- 171 -
START Statement
– Provide a means of positioning within an indexed or relative file for subsequent sequentialrecord retrieval
– This positioning is achieved by comparing the key values of records in the file with the value youplace in the RECORD KEY portion of a file‘s record area (for an indexed file), or in theRELATIVE KEY data item (for a relative file) prior to execution of the START statement
Procedure Division
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 173/186
COBOL/400- 172 -
Coding Example:
START PROJECT-FILE
KEY IS NOT LESS THAN EXTERNALLY-DESCRIBED-KEY
INVALID KEY
SET NO-MORE-RECORDS TO TRUE
END-START.
Procedure Division
STOP Statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 174/186
COBOL/400- 173 -
STOP Statement
– Halts execution of the object program either permanently or temporarily
Procedure Division
STRING Statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 175/186
COBOL/400- 174 -
STRING Statement
– String together the partial or complete contents of two or more data items or literals into onesingle data item
– One STRING statement can be written instead of a series of MOVE statements
Procedure Division
C di E l
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 176/186
COBOL/400- 175 -
Coding Example:
STRING LASTNAME DELIMITED BY " ""," DELIMITED BY SIZE
FIRSTNAME DELIMITED BY SIZE
INTO USERNAME.
STRING MM, "/", DD, "/", YY DELIMITED BY SIZE
INTO CURR-DATE.
Procedure Division
SUBTRACT Statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 177/186
COBOL/400- 176 -
SUBTRACT Statement
– Subtract one numeric item, or the sum of two or more numeric items, from one or more numericitems, and stores the result
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 178/186
Procedure Division
UNSTRING Statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 179/186
COBOL/400- 178 -
UNSTRING Statement
– Cause contiguous data in a sending field to be separated and placed into multiple receivingfields
– One UNSTRING statement can be written instead of a series of MOVE statements
Procedure Division
Coding Example:
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 180/186
COBOL/400- 179 -
Coding Example:
UNSTRING NAMEINTO NAME1
NAME2
NAME3.
01 NAME PIC X(60).
Procedure Division
WRITE Statement
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 181/186
COBOL/400- 180 -
WRITE Statement
– Release a logical record for an output or input/output file
– When the WRITE statement is executed
• the associated indexed or relative file must be open in OUTPUT, I-O, or EXTEND mode
• the associated sequential file must be open in OUTPUT or EXTEND mode
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 182/186
COBOL/400 Compiler Limits
Language Element COBOL/400 Limit
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 183/186
COBOL/400- 182 -
Language Element COBOL/400 Limit
• Data Division
– Length of:• Working-Storage Section
group item 3 000 000 bytes
• Linkage Section group item 3 000 000 bytes
• Elementary item 3 000 000 bytes
• Procedure Division
– Number of:• GO TO proc-name 255
• IF nesting levels 30
• CALL parameters 30
• SORT-MERGE input files 31
• SORT-MERGE keys 30
COBOL/400 Compiler Limits
Language Element COBOL/400 Limit
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 184/186
COBOL/400- 183 -
Language Element COBOL/400 Limit
• General – Number of Files 99
– Number of characters to identify:• Library-name 10
• Program-name 10
• Text-name 10
• Environment Division – Number of:• SELECT file-names 99
COBOL/400 Compiler Limits
Language Element COBOL/400 Limit
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 185/186
COBOL/400- 184 -
g g
• Data Division
– Length of:• Working-Storage Section
group item 3 000 000 bytes
• Linkage Section group item 3 000 000 bytes
• Elementary item 3 000 000 bytes
• Procedure Division
– Number of:• GO TO proc-name 255
• IF nesting levels 30
• CALL parameters 30
• SORT-MERGE input files 31
• SORT-MERGE keys 30
8/12/2019 93240449 Cobol Training New 1
http://slidepdf.com/reader/full/93240449-cobol-training-new-1 186/186
Thank You