Upload
sharathraj
View
14
Download
0
Embed Size (px)
DESCRIPTION
EDS COBOL
Citation preview
7/18/2019 7078941 Eds Cobol Training
1/120
03-23-05
30 Sept 2005
page 1 EDS Internal
COMMON BUSINESS ORIENDTED LANGUAGE
E D S India A D U.
7/18/2019 7078941 Eds Cobol Training
2/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 2 EDS Internal
OBJECTIVES
Understand the standard format of the COBOL program.
Write COBOL programs using modular design techniques
Compile, Link edit and Execute the soure code.
7/18/2019 7078941 Eds Cobol Training
3/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 3 EDS Internal
INTRODUCTIONBE
COBOL stands for COMMON BUSINESS ORIENTED LANGUAGE.
COBOL can be referred as
High-level programming language oriented towards businessapplications
Procedural language
Problem oriented and Machine independent
7/18/2019 7078941 Eds Cobol Training
4/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 4 EDS Internal
HISTORY
Developed in 1959 as standard language to meet businessneed.
Committee was formed to maintain the COBOL.
Included representatives from academia, business,computer manufacturers.`
7/18/2019 7078941 Eds Cobol Training
5/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 5 EDS Internal
STANDARD VERSIONS OF COBOL
1960s Versions of COBOL compilers
1968 First COBOL standard set by American nationalStandards Institute (ANSI) known as COBOL-68
1974 Second COBOL known as COBOL-74 was approvedby ANSI.
1985 ANSI approved the COBOL-85 in which structured
programming techniques were incorporated.
7/18/2019 7078941 Eds Cobol Training
6/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 6 EDS Internal
CHARACTERSTICS
COBOL self documenting.
COBOL is simple
COBOL is non proprietary (Portable)
COBOL is maintainable
7/18/2019 7078941 Eds Cobol Training
7/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 7 EDS Internal
LANGUAGE CONSTRUCTION
COBOL is like English language
Character is the lowest component
Word is made up of one or more characters.
Clause consists of word and characters.
Statement is syntactically valid combination of words andclauses.
7/18/2019 7078941 Eds Cobol Training
8/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 8 EDS Internal
LANGUAGE CONSTRUCTION
Statement is syntactically valid combination of words andclauses.
Sentence is a sequence of one or more statements
terminated by period.
Paragraph consists of one or more statements
Section consists of one or more paragraphs.
7/18/2019 7078941 Eds Cobol Training
9/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 9 EDS Internal
LANGUAGE CONSTRUCTION
Division consists of one or more paragraphs.
Program is made up of divisions.
7/18/2019 7078941 Eds Cobol Training
10/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 10 EDS Internal
CHARACTER SET
Set of 51 characters
0,. 9
A,.Z
b+, -, *, /, (,), =, $, ., ,
DIGITS
LETTERS
SPACE/BALNK CHARACTERSPECIAL SYMBOLS
7/18/2019 7078941 Eds Cobol Training
11/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 11 EDS Internal
WORDS
User defined words
Words declared by programmer like paragraphnames, identifiers etc.
Reserved words Words that are having specific meaning to the
compiler
7/18/2019 7078941 Eds Cobol Training
12/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 12 EDS Internal
CODING FORMAT
Columns
16 Sequence numbers identifying pages or lines of aprogram
7 Continuation, comment or starting of a new page
872 Program statements
73-80 Remarks.
in column 7
* designates the entire line is as a comment
/ forces page break when printing source listing
- to indicate a continuation of non numeric literalcolumns 8 72 divided into two areas.
7/18/2019 7078941 Eds Cobol Training
13/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 13 EDS Internal
CODING FORMAT
AREA A - Columns 8 to 11
AREA B - Columns 12 to 72
Division, Section and Paragraph names must all begin inArea A and end with a period.
7/18/2019 7078941 Eds Cobol Training
14/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 14 EDS Internal
DIVISIONS
COBOL program contains up to 4 separate divisions in thefollowing order
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
15/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 15 EDS Internal
IDENTIFICATION DIVISION
First division of a COBOL program
Identifies the program name to the Operating system
Provides documentation about program
Should begin in Area A.
7/18/2019 7078941 Eds Cobol Training
16/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 16 EDS Internal
IDENTIFICATION DIVISION
Syntax
IDENTIFICATION DIVISION.PROGRAM-ID. PROGRAM NAME.AUTHOR.COMMENT ENTRY.
INSTALLATION.COMMENT ENTRY.DATE-WRITTEN.COMMENT ENTRY.DATE-COMPILED.COMMENT ENTRY.SECURITY.COMMENT ENTRY.
7/18/2019 7078941 Eds Cobol Training
17/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 17 EDS Internal
IDENTIFICATION DIVISION
Paragraph PROGRAM-ID followed by user defined name ismandatory. Other paragraphs are optional
Security here does not pertian to the operating system
security, but the information that is passed to the user ofthe program about the Security features of the program.
7/18/2019 7078941 Eds Cobol Training
18/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 18 EDS Internal
ENVIRONMENT DIVISION
Machine dependent division
The division is optional but for file handling it is essential
Should begin in Area A.
Division is terminated by a period.
Describes the computers used, devices, peripherals etc.
Contains two sections namely, CONFIGURATION andINPUT-OUTPUT
7/18/2019 7078941 Eds Cobol Training
19/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 19 EDS Internal
CONFIGURATION SECTION
Describes the computer to be used for compiling andexecuting the program.
Consists of the following paragraphs
SOURCE COMPUTER
OBJECT COMPUTER
SPECIAL NAMES.
7/18/2019 7078941 Eds Cobol Training
20/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 20 EDS Internal
SOURCE COMPUTER
Used to specify the name of computer for compiling theCOBOL program.
The With Debugging Mode option can be mentioned
enabling the compiler to include D in the 7thcolumn for alllines as syntax.
Syntax
SOURCE COMPUTER. XYZ-2901
7/18/2019 7078941 Eds Cobol Training
21/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 21 EDS Internal
OBJECT COMPUTER
Used to specify the name of the computer for executingthe program
Syntax
OBJECT-COMPUTER. Computer-name
MEMORY SIZE integer-1 CHARACTERS/WORDS
PROGRAM COLLATING SEQUENCE IS alphabet-name
SEGMENT-LIMIT IS integer-2.
7/18/2019 7078941 Eds Cobol Training
22/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 22 EDS Internal
OBJECT COMPUTER
Memory Size used to indicate the amount of storageavailable to Object computer.
The Program Collating Sequence clause specifies the
collating sequence that is to be used to compare non- numeric data items. The alphabet-name is to be defined in
Special names paragraph.
The Segment-Limit clause is used to indicate that the
section having segment number less than the specifiedshould be held in Permanent area of storage.
7/18/2019 7078941 Eds Cobol Training
23/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 23 EDS Internal
SPECIAL NAMES
Is used to relate some IBM specified environment names touser defined names.
Regardless of number of entries in this paragraph thereshould be only one period in the end.
Syntax
SPECIAL-NAMES. CURRENCY SIGN IS literal-1
DECIMAL-POINT IS COMMA
CHANNEL integer IS mnemonic-namesALPHABET alphabet-name IS
STANDARD/NATIVE/implementer name
Implementer-name IS mnemonic-name.
7/18/2019 7078941 Eds Cobol Training
24/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 24 EDS Internal
SPECIAL NAMES
CURRENCY SIGN literal-1
used to change the currency sign other than $ with onecharacter symbol (literal-1).
DECIMAL-POINT IS COMMA
Used to interchange the roles of . and , as editcharacters.
CHANNEL integer IS mnemonic-name
Used to control the line spacing of line printers.
The mnemonic-name can only be used in a WRITEstatement.
7/18/2019 7078941 Eds Cobol Training
25/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 25 EDS Internal
SPECIAL NAMES
ALPHABET alphabet-name ISSTANDARD/NATIVE/implementer name
Implementer-name is mnemonic-name
Used to indicate the collating sequence
Standard stands for the ASCII collating sequenceNATIVE stands for the computers own collatingsequence
7/18/2019 7078941 Eds Cobol Training
26/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 26 EDS Internal
INPUT-OUTPUT SECTION
Contains information regarding files to be used in theprogram
Consists FILE-CONTROL and I-O-CONTROL (INPUT-
OUTPUT-CONTROL) paragraphs.
7/18/2019 7078941 Eds Cobol Training
27/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 27 EDS Internal
FILE-CONTROL
Associates each file used in program with an external DDname. The DD name is associated to a physical file in JCL.
The simplified format of file association is done using
SELECT clause.
Coding rules
SELECT clause must appear first
Other clauses can appear in any order
Each clause must start in Area B.
7/18/2019 7078941 Eds Cobol Training
28/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 28 EDS Internal
I-O-CONTROL
Optional paragraph.
Must begin in Area A.
Specifies when check points are to be taken
Specifies the storage areas to be shared by different files
7/18/2019 7078941 Eds Cobol Training
29/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 29 EDS Internal
DATA DIVISION
Used to define data needed to be accessed by program
Describes input and output format of data files
Defines any constants and work areas
Consists of three sections namely
FILE SECTION
WORKING STORAGE SECTION
LINKAGE SECTION
7/18/2019 7078941 Eds Cobol Training
30/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 30 EDS Internal
FILE SECTION
Includes the description of all the files.
SYNTAX of file description
FD file-name
RECORD IS OMITTED
LABEL
RECORDS ARE STANDARD
RECORD CONTAINS integer-1 CHARACTERS
BLOCK CONTAINS integer-2 RECORDS
7/18/2019 7078941 Eds Cobol Training
31/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 31 EDS Internal
FILE SECTION
LABEL RECORDS clause used if labels stored in file
BLOCK CONTAINS clause indicates blocking factor for diskfiles.
RECORD CONTAINS clause indicates size of each record.
Defining a Record
Each FD followed by record description entries for the file.
Record name is defined at 01 level considered highestlevel of data
Fields within a record are defined at subordinate levelwith level numbers from 02 to 49.
7/18/2019 7078941 Eds Cobol Training
32/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 32 EDS Internal
WORKING-STORAGE SECTION
Must start in Area A and end with Period.
All items must be defined at 01 level or at subordinate to01 level
Rules for user-defined entry names apply
Elementary items :
Must include PICTURE (PIC) clause
May be assigned initial value with VALUE clause
7/18/2019 7078941 Eds Cobol Training
33/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 33 EDS Internal
LITERALS AND FIGURATIVE CONSTANTS
Literal is a constant representing a number or non-number
(Alpha numeric) like 33.3 or TEACHER
Literals are storable in a memory location having a userdefined name called Data name or identifier or Variable orField
Figurative constant is a COBOL reserved word representingfrequently used constants like ZEROS or SPACES
Figurative constants are used in program for better
readability.
Ex: MOVE SPACES TO WS-RECORD.
Literals are classified into Numeric and Non-numeric literals
7/18/2019 7078941 Eds Cobol Training
34/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 34 EDS Internal
NUMERIC LITERAL
Must contain at least one digit.
+ or sign, if used must be the left most character
Not more than one decimal point
Decimal may not be the right most character
Maximum of 18 digits
TOTAL-COUNT PIC 9(3) VALUE 100.
NON NUMERIC LITERAL
7/18/2019 7078941 Eds Cobol Training
35/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 35 EDS Internal
NON-NUMERIC LITERAL
May consist of any character in the character set
Must be enclosed in quotes
A numeric literal in quotes is non-numeric literal
Maximum length of 120 characters
COMPANY-NAME PIC X(3) VALUE EDS.
FIGURATIVE CONSTANTS
7/18/2019 7078941 Eds Cobol Training
36/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 36 EDS Internal
FIGURATIVE CONSTANTS
List of Figurative constants
ZERO/ZEROS/ZEROES
Quote/Quotes
Space/Spaces
HIGH VALUE/HIGH VALUES
LOW VALUE/LOW VALUES
ALL
One or more zeros
One or more
One or more spaces
Value in collating sequence
Value in collating sequence
One or more string vlaues
DATA DESCRIPTION
7/18/2019 7078941 Eds Cobol Training
37/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 37 EDS Internal
DATA DESCRIPTION
The general format of data description is
Level Number
Data name
Filler clause
LEVEL NUMBERS
7/18/2019 7078941 Eds Cobol Training
38/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 38 EDS Internal
LEVEL NUMBERS
Specifies the hierarchical structure of data item
Is a two digit number starting from 01.
Single digit numbers must be written in a two-digit form
with a 0 or space preceding them.
Are values taken from set of integers between 1 and 40, orone from 66, 77 and 88 which are called Special levelnumbers
LEVEL NUMBERS
7/18/2019 7078941 Eds Cobol Training
39/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 39 EDS Internal
LEVEL NUMBERS
01 level
Specifies a group of data items called record or anelementary data item
Must begin in Area A
02 49 levels
Specifies group items or elementary item within a record.
Group level data items will not have Picture Clause
SPECIAL LEVEL NUMBERS
7/18/2019 7078941 Eds Cobol Training
40/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 40 EDS Internal
SPECIAL LEVEL NUMBERS
66 identifies items that contain RENAME clause
77 identifies independent elementary data item
77 has to appear only as elementary data item
88 identifies any condition name that is associated with aparticular value of conditional variable
DATA NAMES
7/18/2019 7078941 Eds Cobol Training
41/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 41 EDS Internal
DATA NAMES
Identifier name or Data name should not exceed 30characters
There should be at least one alphabet anywhere in thename.
Only special character allowed is (Hyphen) but shouldnot be at the beginning or at the End.
Should be unique within a record
If Data name is duplicated across records then it should bequalified as identifier-name of Record name
DATA NAMES
7/18/2019 7078941 Eds Cobol Training
42/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 42 EDS Internal
DATA NAMES
Examples
CURRENT-DATE
EMPLOYEE
11RAIL
99-DETAIL-LINE
MOVE BALANCE OF BILLING-RECORD TO TOTAL-AMOUNT
FILLER
7/18/2019 7078941 Eds Cobol Training
43/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 43 EDS Internal
FILLER
Used whenever there is no specific reference to fields in a
record.
Used wherever there is fixed information like SPACES orHeadings are stored.
Example
01 DETAIL-RECORD
05 FILLER PIC X(05) VALUE SPACES.
05 NAME PIC X(20).
05 PIC X(02) VALUE SPACES.
05 FILLER PIC X(05) VALUE BASIC.
05 AMT PIC 9(9)V99.
PICTURE CLAUSE
7/18/2019 7078941 Eds Cobol Training
44/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 44 EDS Internal
PICTURE CLAUSE
Describes the class (numeric, alphabetic, alphanumeric),
sign(signed/unsigned), decimal point location and size of adata item.
Specified for every elementary data item
Type Character String Remark
Numeric 9 Used for arithmeticoperations
V Assumed decimal point
S Signed data item
P Position of assumeddecimal point when thepoint lies outside dataitem
PICTURE CLAUSE
7/18/2019 7078941 Eds Cobol Training
45/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 45 EDS Internal
PICTURE CLAUSE
Type Character String Remark
Alphabetic A Data item contains only aletter or space
B Blank insertion character
Alpha numeric X Data item contains onlyallowable character from
the COBOL character set
Examples
01 COMPANY PIC X(10). - Defines 10characters of Alphanumeric.
01 BASIC-AMOUNT PIC 9(9)V99. Defines9 digits before decimaland two digits afterdecimal. The decimalwill not be displayed.
EDITED PICTURE CLAUSE
7/18/2019 7078941 Eds Cobol Training
46/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 46 EDS Internal
EDITED PICTURE CLAUSE
Edited Picture Clause
Used to display Numeric and other data in the userreadable format
Edited types
Numeric data
Alphabetic
Alphanumeric
EDITED PICTURE CLAUSE
7/18/2019 7078941 Eds Cobol Training
47/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 47 EDS Internal
EDITED PICTURE CLAUSE
PIC OF THE FIELD NUMERIC VALUE EDITED VALUE
ZZZV99* * 999$ * *999-ZZZV99+999+9999999+ZZ,Z99
ZZZZ.ZZ$$$$9.9999B99B9909990999/999/99
38^
400052985-46^52-382382-3822456
5342464563254
b3840* * 052$**985-b4652-382+3820382-b2,456
bbbb.05b$342.0000b00b4604560000/032/54
ZZZ.99 BLANK WHEN ZERO
999.99 BLANK WHEN ZERO
2 5
0
bb2.50
bbbbbb
VALUE CLAUSE
7/18/2019 7078941 Eds Cobol Training
48/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 48 EDS Internal
VALUE CLAUSE
Assigns initial value to a data item.
Should not exceed the picture clause
Should be consistent with the picture clause
Not used for for items whose size is variable
Example01 WS-RECORD
05 WS-COMPANY PIC X(03) VLAUE EDS.
05 FILLER PIC X(15) VALUE ALL -.
USAGE CLAUSE
7/18/2019 7078941 Eds Cobol Training
49/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 49 EDS Internal
USAGE CLAUSE
Specifies how data item is represented internally
Types
DISPLAY number of bytes required is equal to the size ofdata item. This is default type.
COMPUTATIONAL Maintained in Binary and only forintegers. Stored either in half or full word.
Syntax
USAGE IS DISPLAYCOMPUTATIONAL OR COMP , COMP -1, COMP-2, COMP-3
SIGN CLAUSE
7/18/2019 7078941 Eds Cobol Training
50/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 50 EDS Internal
SIGN CLAUSE
Indicates the data item is Signed.
Only for numeric fields
Picture clause should contain S
Usage should be display
To represent the position either LEDING or TRAILING can beused.
OCCURS CLAUSE
7/18/2019 7078941 Eds Cobol Training
51/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 51 EDS Internal
OCCURS CLAUSE
Used to represent and store table of values
When used allocates physically contiguous memorylocations to store table values
Values are accessed either by using index or subscript
Example
01 WS-TABLE.
05 WS-NAME OCCURS 10 TIMES PIC X(20).
01 WS-TABLE.
05 WS-RECORD OCCURS 15 TIMES.
10 WS-DEPT PIC X(10).
10 WS-DIV PIC 9(05).
REDEFINES CLAUSE
7/18/2019 7078941 Eds Cobol Training
52/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 52 EDS Internal
REDEFINES CLAUSE
Allows to reference same memory area for more than one
data-name with different formats and sizes.
Syntax
Level-number data-name-1 REDEFINES data-name-2
Rules
Level-number of data-name-1 and data-name-2 must beidentical and not 66 or 88
Redefines clause must follow immediately after data-name-2
data-name-1 cannot have value clause
data-name-1 size should not exceed data-name-2 size
REDEFINES CLAUSE
7/18/2019 7078941 Eds Cobol Training
53/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 53 EDS Internal
REDEFINES CLAUSE
Rules
Multiple Redefinitions are allowed provided no newstorage areas defined in between
At 01 level, OCCURS and REDEFINES cannot becombined
RENAMES CLAUSE
7/18/2019 7078941 Eds Cobol Training
54/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 54 EDS Internal
RENAMES CLAUSE
Regrouping of elementary data items in a Record.
Example
01 WS-RESPONSE.
05 W-CHAR-123 PIC XXX.
05 W-CHAR-4 PIC X.
05 W-CHAR-56 PIC XX.
66 ADD-RESPONSE RENAMES W-CHAR-123.
66 VIEW-RESPONSE RENAMES W-CHAR-123 THRUW-CHAR-4.
66 DELETE-RESPONSE RENAMES W-CHAR-123 THRUW-CHAR-56.
JUSTIFIED CLAUSE
7/18/2019 7078941 Eds Cobol Training
55/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 55 EDS Internal
JUSTIFIED CLAUSE
Overrides standard positioning rules for a receiving stem
of the alphabetic or alphanumeric categories
Default is Left Justified
Does not alter initial settings as determined by the valueclause
May not be specified at 66 and 88 level.
Example01 WS-CHAR PIC X(05) JUSTIFIED RIGHT.
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
56/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 56 EDS Internal
PROCEDURE DIVISION
Contains statements which specify the operations to be
performed
Last division in a COBOL program
Contains following structure
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
57/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 57 EDS Internal
PROCEDURE DIVISION
DIVISION
Is a block of code, usually containing one or moresections
Starts with a Division name and ends where a newDivision starts or program text ends
SECTION
Is a block code usually containing one or moreparagraphs.
Starts with a Section name and ends where next sectionstarts or program text ends
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
58/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 58 EDS Internal
PROCEDURE DIVISION
PARAGRAPH
A block of code made up of one or more sentences
Starts with a paragraph name and ends where nextparagraph or next section starts or program text ends
Sentences and Statements
Sentence consists of one or more statements and isterminated by a period
Example
MOVE 0.12 TO TAX-RATECOMPUTE PRICEA = PROD-COST * TAX-RATE
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
59/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 59 EDS Internal
PROCEDURE DIVISION
Statement consists of a COBOL verb and an operand or
operands
Example
SUBTRACT TAX FROM GROSS-PAY GIVING NETPAY.
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
60/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 60 EDS Internal
PROCEDURE DIVISION
Guidelines
Paragraph names section names should start in Area A
Statements and Sentences should start in Area B
Section names and Paragraph names are user defined
Section names must be unique and must be different fromparagraph names
Paragraph names must be unique in a section
If paragraph name is duplicated across sections then it shouldbe qualified as paragraph-name of/in section name
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
61/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 61 EDS Internal
PROCEDURE DIVISION
Statements in Procedure division
Can be broadly classified as
Imperative statementswhich directs the program to take aspecific action during execution
Examples: MOVE , ADD, GOTO , EXIT
Conditional statements- Specified that the truth of acondition is to be determined and that the subsequent action ofthe object program is dependent on this truth value
Examples: IF, EVALUATE, ADDON SIZE ERROR
Compiler Directive statementis beginning with a compilerverb, that causes compiler to take specific action duringcompilation
Examples: USE, COPY
PROCEDURE DIVISION
7/18/2019 7078941 Eds Cobol Training
62/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 62 EDS Internal
OC U V S ON
Explicit Scope Terminator Terminates the scope of the
conditional statementsExamples : END-IF, END-READ, END-EVALUATE,
END-CALL, END-SORT
Implicit Scope Terminator is a period that terminates thescope of all previous statements not yet terminated
DATA MOVEMENT
7/18/2019 7078941 Eds Cobol Training
63/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 63 EDS Internal
MOVE
To move data into a place in a memory
Format
MOVE {IDENTIFIER-1/LITERAL-1} TO IDENTIFIER-2,[,IDENTIFIER-3],
RULES
Only one sending field, one or more receiving fields
Value of the sending field remains unaltered after thestatement execution
DATA MOVEMENT
7/18/2019 7078941 Eds Cobol Training
64/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 64 EDS Internal
Numeric Data Transfer Rules
When sending field is numeric or numeric-edited, thedata movement is called Numeric data transfer
Dominant factor is the decimal points alignment in twothe fields
If the receiving field is not large enough then truncationoccurs either ends or both the ends
If the receiving field is large then the unused positionswill be filled with spaces.
DATA MOVEMENT
7/18/2019 7078941 Eds Cobol Training
65/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 65 EDS Internal
Alphanumeric Data Transfer Rules
When both the sending and receiving fields arealphabetic, alphanumeric or alphanumeric edited the datamovement is called Alphanumeric
Receiving field is filled from left to right
When receiving field is smaller then truncation occursfrom the right, compiler will give warning
DATA MOVEMENT
7/18/2019 7078941 Eds Cobol Training
66/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 66 EDS Internal
Group Moves
When at least one of the fields is a group item, it iscalled Group Move
Example
01 RECORD-1.
05 A1 PIC 9(3).05 A2 PIC A(2).
05 A3 PIC XXXX.
01 RECORD-2.05 A1 PIC 9(3).05 A2 PIC A(2).05 A3 PIC XXXX.
MOVE RECORD-1 TO RECORD-2.
DATA MOVEMENT
7/18/2019 7078941 Eds Cobol Training
67/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 67 EDS Internal
Move Corresponding
When the names of the corresponding data item of twogroups are same, this statement can be used forsubstitute for a set of move statements
Example
01 PAY-REC.
05 EMP-NO PIC 9(05).
05 EMP-NAME PIC X(20).
01 PRINT-REC.
05 FILLER PIC X(05).
05 EMP-NO PIC 9(05).05 FILLER PIC X(05).
05 EMP-NAME PIC X(20).
MOVE CORRESPONDING PAY-REC TO PRINT-REC.
ARITHMETIC VERBS
7/18/2019 7078941 Eds Cobol Training
68/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 68 EDS Internal
ADD
To sum two or more numbers and store the resultADD [CORRESPONDING] [Identifier-1/Literal-1] [Identfier-2/Literal-2] [TO /GIVING] Identifier-3, Identifier-4..
Example
ADD A TO B.
ADD A , B GIVING C.
ADD CORR OLD-REC TO NEW-REC.
ARITHMETIC VERBS
7/18/2019 7078941 Eds Cobol Training
69/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 69 EDS Internal
SUBTRACT
Used to subtract one or the sum of two or more fromone or more numbers
SUBTRACT [CORR] [Identifier-1/Literal-1] [Identifier-2/Literal-2] [FROM/GIVING] Identifier-3 Identifier-4.
Example
SUBTRACT A FROM B.
SUBTRACT A B FROM C.
ARITHMETIC VERBS
7/18/2019 7078941 Eds Cobol Training
70/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 70 EDS Internal
MULTIPLY
Used to multiply one or more multiplicands by multiplier
MULTIPLY {IDENTIFIER-1 BY IDENTIFIER-2[ ,IDENTIFIER-3]...LITERAL - 1}[GIVING IDENTIFIER-4 [ , IDENTIFIER-5]...]
Example
MULTIPLY A BY B.
MUYLTIPLY A BY B GIVING C.
MULTIPLY 2 BY A.
7/18/2019 7078941 Eds Cobol Training
71/120
ARITHMETIC VERBS
7/18/2019 7078941 Eds Cobol Training
72/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 72 EDS Internal
COMPUTE
Used as a substitute for any other arithmetic verbs likeADD, SUBTRACT, MULTIPLY and DIVIDE.
COMPUTE IDENTIFIER-1 [ROUNDED][ , IDENTIFIER-2 [ ROUNDED ] ]= ARITHMETIC-EXPRESSION
[ : ON SIZE ERROR]IMPERATIVE STATEMENT.
ARITHMETIC OPERATORS
7/18/2019 7078941 Eds Cobol Training
73/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 73 EDS Internal
Permitted operators
** Exponentiation
/ Division
* Multiplication
- Subtraction
+ Addition
ARITHMETIC OPERATION
7/18/2019 7078941 Eds Cobol Training
74/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 74 EDS Internal
ROUNDED OPERATION
It will round the number to the picture clause duringarithmetic operations.
Cant be specified for the identifier that receives theremainder in a Divide operation
ADD WS-A WS-B GIVING WS-C ROUNDED
ON SIZE ERROR
If the result after an arithmetic operation exceeds thelargest value that can be accommodated in the result field
the error occurs is called ON SIZE ERROR Used to continue the process instead of terminatingbecause of error.
ADD A TO B ON SIZE ERROR PERFORM ERROR-PARA.
COBOL DEFINED VERBS
7/18/2019 7078941 Eds Cobol Training
75/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 75 EDS Internal
ACCEPT
To transfer data from an input/output device, or systeminformation contained in the specified data items likeDATE, TIME etc.
ACCEPT Identifier [FROM mnemonic name
DATE / DAY/ TIME / DAY-OF-WEEK]
DISPLAY
Used to display data on to a terminal
DISPLAY {identifier-1 identifier-2 literal-1} ,literal-2
UPON [mnemonic name]
Example: DISPLAY TOTAL STRENGTH = TOTAL-ST
COBOL DEFINED VERBS
7/18/2019 7078941 Eds Cobol Training
76/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 76 EDS Internal
INITIALIZE
Used to initialize value of either a group item or anelementary item
INITIALIZE {identifier-1 } . . .REPLACING { ALPHABETIC
ALPHANUMERICNUMERICALPHA-NUMERIC-EDITED.NUMERIC-EDITED }
DATA BY { identifier-2literal-2 }
CONDITIONAL AND UNCONDITIONAL TRANSFER
7/18/2019 7078941 Eds Cobol Training
77/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 77 EDS Internal
Simple IF statement
IF condition
statement-1
statement-2
ELSEstatement-3
statement-4
END-IF.
CONDITIONAL AND UNCONDITIONAL TRANSFER
7/18/2019 7078941 Eds Cobol Training
78/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 78 EDS Internal
Nested IF statement
IF condition-1
IF condition-2
statement-1
ELSEIF condition-3
statement-3
END-IF
END-IFEND-IF.
CONDITIONAL AND UNCONDITIONAL TRANSFER
7/18/2019 7078941 Eds Cobol Training
79/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 79 EDS Internal
EVALUATE Statement
EVALUATE SUBJECT-1 [ALSO SUBJECT-2]...
{WHEN OBJECT-1 [ALSO OBJECT-2}...}
[WHEN OTHER {IMPERATIVE-STATEMENT-2}...]
[END-EVALUATE].
Can be used instead of nested IF statements
CONDITIONAL AND UNCONDITIONAL TRANSFER
7/18/2019 7078941 Eds Cobol Training
80/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005page 80 EDS Internal
GO TO statement
Is an unconditional transferring of control to thespecified paragraph
Advised to avoid GO TO as the structured programmingtechnique doesnt support unconditional transferstatements
Example : GO TO REPORT-PARA.
ALTER
Used to modify the targets of GO TO statements writtenelsewhere in the procedure division.
ALTER PROCEDURE-NAME-1 TO[PROCEED TO ] PROCEDURE-NAME-2[PROCEDURE-NAME-3 TO {PROCEED TO }
PROCEDURE-NAME-4 ]....
PERFORM STATEMENT
7/18/2019 7078941 Eds Cobol Training
81/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005page 81 EDS Internal
A PERFORM statement is used to execute a group of
consecutive statements elsewhere in the program, under aparagraph
Types of PERFORM
PERFORM Para-name-1.
Para-name-1 specifies the range, which contains
statements to be executed
PERFORM para-name-1 thru para-name-2.
This statement executes all the statements
beginning in para-name-1 till the last statement inpara-name-2 including the paragraphs in betweenboth the paragraphs
PERFORM STATEMENT
7/18/2019 7078941 Eds Cobol Training
82/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal30 Sept 2005
page 82 EDS Internal
Types of PERFORM
PERFORM para-name-1 [THRU para-name-2] {identifier-1/ integer} TIMES
This is a looping statement which executes thespecified range of statements a fixed number of times.
PERFORM para-name-1 [THRU para-name-2] UNTILcondition.
This statement executes the specified range ofstatements repeatedly until the condition becomesTRUE.
The condition is to be made TRUE within theparagraph performed
PERFORM STATEMENT
7/18/2019 7078941 Eds Cobol Training
83/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 83 EDS Internal
Types of PERFORM
PERFORM VARYING {identifier-1 FROM {identifier-2/integer-1} BY {identifier-3 / integer-2}UNTIL Condition-1 AFTER identifier-1FROM {identifier-2/integer-1}BY {identifier-3/integer-2} UNTIL Condition-2
[imperative statement]
END-PERFORM.
Example
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3AFTER J FROM 1 BY 1 UNTIL J > 4
Display SALE ( I , J )END-PERFORM.
PERFORM STATEMENT
7/18/2019 7078941 Eds Cobol Training
84/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 84 EDS Internal
RELATIONAL CONDITION
Compares two operands either of which can beidentifier literal, arithmetic expression or index-name
A non-numeric literal can be enclosed in parentheseswithin a relational condition
Relational operators are: < , , >=
NOT GREATER THAN / LESS THAN/ EQUAL TO
SIGN CONDITION
Determines whether or not the algebraic value of a
numeric operand is greater than or less than or equal toZero
Possible conditions are
POSITIVE, NEGATIVE OR ZERO
CONDITIONAL EXPRESSIONS
7/18/2019 7078941 Eds Cobol Training
85/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 85 EDS Internal
CLASS CONDITION
Determines whether the content of data item isalphabetic, numeric or contains only characters in theset of characters specified by the CLASS clause in theSPECIAL NAMES paragraph
CONDITION-NAME CONDITION
Tests a conditional variable to determine its value isequal to any value(s) associated with the conditionname
Are declared at 88 level
NEGATED CONDITION
A condition is negated by using use of operator NOT
CONDITIONAL EXPRESSIONS
7/18/2019 7078941 Eds Cobol Training
86/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 86 EDS Internal
COMPOUND CONDITION
Two or more conditions can be logically connectedto form a compound condition
Possible values are: AND, OR
FILE HANDLING
7/18/2019 7078941 Eds Cobol Training
87/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 87 EDS Internal
RECORD : is a collection of relevant fields pertaining to anitem/case/account/transaction
FILE
Is a collection of relevant records of an application
Is organized in storage media either in SEQUENTIALor INDEXED or RELATIVE way.
SEQUENTIAL FILES
Records can be accessed in the order in which theyappear in the file
Records can be appended at the end of the file butcannot be inserted
Records cannot be deleted
FILE HANDLING
7/18/2019 7078941 Eds Cobol Training
88/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 88 EDS Internal
INDEXED FILES
Records can be accessed Randomly or Sequentiallyusing key called Primary-key
There can be more than one key called Alternatekeys to access records
Records can be inserted and deleted
FILE HANDLING STEPS
7/18/2019 7078941 Eds Cobol Training
89/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 89 EDS Internal
STEP 1:
All files handled in a program should be assigned tological name
The DDNAME assigned, Organization of the file, itsprimary key and alternate keys to be specified in File-control paragraph.
STEP-2:
Describe the details like record-name, record structurein File section including number of records grouped asBLOCK for input output operation
STEP-3
Open the files to do read/write operations in Proceduredivision.
FILE HANDLING STEPS
7/18/2019 7078941 Eds Cobol Training
90/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 90 EDS Internal
STEP 4:
If we have to read records then READ statement shouldbe used
Syntax: READ file-name
STEP 5:
If we have to write record then WRITE statement shouldbe used
Syntax: WRITE record-name
STEP 6:
After all operations are completed the file has to beCLOSED to disconnect file from COBOL program
Syntax: CLOSE file-name
SELECT STATEMENT
7/18/2019 7078941 Eds Cobol Training
91/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 91 EDS Internal
Syntax:
SELECT file-name ASSIGN TO DD NameORGANIZATION IS[SEQUENTIAL/INDEXED/RELATIVE]
ACESS MODE IS[SEQUENTIAL/DYNAMIC/RANDOM]
[RECORD KEY data-name-1 ]
[ALTERNATE KEY IS data-name-2. WITHDUPLICATE]
FILE-STATUS IS data-name-2.
SELECT STATEMENT
7/18/2019 7078941 Eds Cobol Training
92/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 92 EDS Internal
ORGANIZATION CLAUSE
Following file organizations can be chosen
oSEQUENTIAL
This option is used for PS data set or VSAM ESDS.
The records are places in first come first servedbasis
oINDEXED
This option is used to handle a VSAM KSDS
Key field called Primary key should be defined
oRELATIVE
This option is used to handle a VSAM RRDS
Record number is used to access records
SELECT STATEMENT
7/18/2019 7078941 Eds Cobol Training
93/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 93 EDS Internal
ACCESS MODE CLAUSE
Based on Organization file can be accessed in differentmodes
oSEQUENTIAL Access mode To access records insequential order
oRANDOM Access mode To access particular recordof an indexed / relative file provided key value is setprior to read / write operation
oDYNAMIC Access mode To access a particular
record or in sequential order from an indexed / relativefile
SELECT STATEMENT
7/18/2019 7078941 Eds Cobol Training
94/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 94 EDS Internal
RECORD KEY PHRASE
To be defined for indexed files
To be unique and is to be part of indexed record
ALTERNATE KEY PHRASE
To be defined if records are to be read by using keyother than Primary key
Need not be unique but need to be part of the record
7/18/2019 7078941 Eds Cobol Training
95/120
FD ENTRY
7/18/2019 7078941 Eds Cobol Training
96/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 96 EDS Internal
BLOCK CONTAINS / RECORD CONTAINS PHRASE
Length of the record can be specified in terms ofcharacters
Number of characters / records for a Block can bespecified
RECORDING MODE CLAUSE
Specifies as that all the records in a file are of samelength (FIXED) or different (Variable )
FD ENTRY
7/18/2019 7078941 Eds Cobol Training
97/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 97 EDS Internal
BLOCK CONTAINS / RECORD CONTAINS PHRASE
Length of the record can be specified in terms ofcharacters
Number of characters / records for a Block canbe specified
RECORDING MODE CLAUSE
Specifies as that all the records in a file are ofsame length (FIXED) or different (Variable )
INPUT AND OUTPUT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
98/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 98 EDS Internal
OPEN Statement
OPEN INPUT file-name - Connects data set to programto records from the first enabling to read records
OPEN OUTPUT file-name Connects data set toprogram though file is empty enabling to write records
OPEN I-O file-name Connects data set to program toRead/ Write / Rewrite the records to file
OPEN EXTEND file-name Connects the existing data setto program to append new records at the end of theexisting records in the file
WRITE
Adds records to the file
Key to be used for indexed file
INPUT AND OUTPUT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
99/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 99 EDS Internal
START
Establishes the current location in the cluster for aREAD NEXT statement
This doesnt retrieve record
It only sorts the current record pointer described underFile position indicator
READ
Used to read record from the file
Reads next record for sequential file
Reads the corresponding key specified
INPUT AND OUTPUT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
100/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 100 EDS Internal
REWRITE
Updates record
DELETE
Logically removes the records from theIndexed/relative files
CLOSE
Disconnects file from the program
SUBPROGRAMS
7/18/2019 7078941 Eds Cobol Training
101/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 101 EDS Internal
Programs compiled and stored in library to be calledwhen needed
The program that calls another program is referred ascallingprogram, and the program it calls is referred ascalled program
Called program itself can call another program
During execution, called program can either transfer
control back to the calling program or end the run unit
SUBPROGRAMS
7/18/2019 7078941 Eds Cobol Training
102/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 102 EDS Internal
ADVANTAGES
Avoids duplication effort
Improves programmer productivity
Provides greater flexibility
Changes to the called program can be made withoutchanging the calling program
Results in greater standardization
SUBPROGRAMS
7/18/2019 7078941 Eds Cobol Training
103/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 103 EDS Internal
SUBPROGRAMS
7/18/2019 7078941 Eds Cobol Training
104/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 104 EDS Internal
LINKAGE SECTION
Describes data made available for another
programStorage for data items within the program is notreserved because the area exists elsewhere
Value clause may not be specified for items otherthan 88 level items
STATIC CALL
The compiler treats the CALL literal statementwhere the literal is program name, as a static call
when NODYNUM compiler option is in effect
DYNAMIC CALL
Loads the subprogram at the run time
SUBPROGRAMS
7/18/2019 7078941 Eds Cobol Training
105/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 105 EDS Internal
CALL by Reference or by Content
To pass an identifiers value only then use CALLBY REFERENCE
To pass literals value then use CALL BY CONTENT
STRING, UNSTRING AND INSPECT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
106/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 106 EDS Internal
STRING Statement
Strings together the partial or complete contents oftwo or more DATA ITESM or LITERALS into single dataitem
STRING IDENTIFIER1 DELIMITED BY
IDENTIFIER 2LITERAL1 LITERALSSIZEINTO IDENTIFIER3 WITH POINTERIDENTIFIER4ON OVERFLOW IMPERATIVE STATEMENT1
NOT ON OVERFLOW IMPERATIVESTATEMENT2
END-STRING
STRING, UNSTRING AND INSPECT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
107/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 107 EDS Internal
UNSTRING Statement
Causes contiguous data in a sending field to beseparated and placed into multiple receiving fields
UNSTRING IDENTIFIER1 DELIMITED BYALL IDENTIFIER 2 LITERAL1
OR ALL IDENTIFIER-3 LITERAL2INTO IDENTIFIER4 DELIMITER INIDENTIFIER5 COUNT IN
IDENTIFIER6WITH POINTER IDENTIFIER7
TALLYING IN IDENTIFIER8
ON OVERFLOW IMPERATIVESTATEMENT1
NOT ON OVERFLOW IMPERATIVESTATEMENT2
END-UNSTRING
STRING, UNSTRING AND INSPECT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
108/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 108 EDS Internal
INSPECT
Specifies that characters or group of characters in adata item are to be countered or (tallied) or replacesor both
Counts all the occurrences of a specific character
Will fill all portions of data item with specifiedcharacters such as spaces or zeros
Will convert all occurrences of specific characters ina data item to user supplied replacement character
INSPECT IDENTIFIER1 TALLYING
IDENTIFIER2FOR [ALL/LEADING]
[IDENTIFIER3/LITERAL1] [PHRASE][PHRASE] here is AFTER / BEFORE
[INITIAL] IDENTIFIER4/LITERAL2.
STRING, UNSTRING AND INSPECT STATEMENTS
7/18/2019 7078941 Eds Cobol Training
109/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 109 EDS Internal
INSPECT
INSPECT IDENTIFIER1 REPLACINGCHARACTERS
BY [IDENTIFIER2/LITERAL1]BEFORE/AFTER INITIAL [IDENTIFIER3 /LITERAL 2] AFTER / LEADING/FIRST
[IDENTIFIER/LITERAL.]By IDENTIFIER/LITERAL [PHRASE]PHRASE] here is AFTER / BEFORE
[INITIAL] IDENTIFIER4/LITERAL2.
DECLARATIVES
7/18/2019 7078941 Eds Cobol Training
110/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 110 EDS Internal
Used for tracing the paragraph or procedure executed
by the program as per the instruction given by theprogrammer
WITH DEBUGGING MODE option has to be specifiedin the OBJECT-C0MPUTER paragraph
Has to be first section in PROCEDURE DIVISION
PROCEDURE DIVISION.
DECLARATIVES.DEBUG -DECLARATIVES SECTION.USE FOR DEBUGGING ALL PROCEDURE .
DEBUG -DECLARATIVES -PARA.DISPLAY TRACING DEBUG-NAME
END DECLARATIVES.
SORT STATEMENT
7/18/2019 7078941 Eds Cobol Training
111/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 111 EDS Internal
Accepts records from on or more files and arranges the recordsin the ascending/descending order and makes sorted recordsavailable either through an OUTPUT-PROCEDURE or in anoutput file.
Can be appeared anywhere in PROCEDURE DIVISION
SORT file-name-1 ON[ASCENDING/DESCENDING KEY]data-name-1[WITH DUPLICATES ] [IN ORDERCOLLATING SEQUENCE ISAlphabet- name-1]
INPUT PROCEDURE IS procedure-name-1THRU procedure-name-2OUTPUT-PROCEDURE IS procedure-name- 3THRU procedure-name-4
END-SORT.
SORT STATEMENT
7/18/2019 7078941 Eds Cobol Training
112/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 112 EDS Internal
File-name -1 is the name given in the SD entry that describesthe records to be sorted
data-name-1 specifies a KEY data item on which the SORTstatement will be based
Each data name must identify a data item in a recordassociated with file-name -1
Alphabet-name1 must be specified in the alphabet clause ofSPECIAL-NAMES para
USING and INPUT-PROCEDURE are mutually exclusive
Input-Procedure is specified to Select or Modify the InputRecord before Sort
This Procedure can do any modifications in the record and copyUsing RELEASE Statement
GIVING and OUTPUT-PROCEDURE are mutually exclusive
SORT STATEMENT
7/18/2019 7078941 Eds Cobol Training
113/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 113 EDS Internal
Output-Procedure is specified to Select or Modify the outputRecord After Sort
This Procedure can do any modifications in the record and copyUsing RETURN Statement
MERGE STATEMENT
7/18/2019 7078941 Eds Cobol Training
114/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 114 EDS Internal
Merges two or more input files based on common key.
The merged records are made available to an output file or toan output procedure
MERGE file-name-1 ON [ASCENDING/DESCENDING KEY]data-name-1 USING file-name-2 file-name-3[COLLATING SEQUENCE IS Alphabet-name-1]GIVING file-name-4 /OUTPUT-PROCEDURE IS procedure-name-3 THRUprocedure-name-4
File-name -1 is the name given in the SD entry that describes
the records to be merged
GIVING and OUTPUT-PROCEDURE are mutually exclusive
INTRINSIC FUNTIONS
7/18/2019 7078941 Eds Cobol Training
115/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 115 EDS Internal
NUMBER HANDLING
LENGTH Returns the length of the Picture clauseFUNCTION LENGTH(NAME)
MAX Returns the content of the argument that containsthe maximum value
FUNCTION MAX(MARKS)
MIN Returns the content of the argument that containsthe minimum value
FUNCTION MIN(MARKS)
NUMVAL Returns the numeric value represented by the
alphanumeric character string specified in the argument
DATE - TIME
7/18/2019 7078941 Eds Cobol Training
116/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 116 EDS Internal
CURRENT DATE
Returns 21 characters alphanumeric value1..4 Year in the Gregorian calendar
5,6 Month of the year
7,8 Day of the Month
9..14 HHMMSS and so on
DATE-OF-INTERGER
Converts a date in the Gregorian calendar from integerdate form to standard date form yyyymmdd
DAY-OF-INTEGERConverts a date in the Gregorian calendar from integerdate form to Julian date form yyyymmdd
COMPILER OPTIONS
7/18/2019 7078941 Eds Cobol Training
117/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 117 EDS Internal
NOC
Specified to do only Syntax checkNOC (W), NOC (E), NOC (S)
W is warning, E is for error and S for severe. When anerror level of specified or of a more severe level occurs,compilation stops.
Default is S
DYNAM
Causes subprograms that are invoked through the CALLliteral statement to load dynamically
NODYNAM
Causes the text files of subprograms called with a CALLliteral statement to be included with the calling program intoa single module file
7/18/2019 7078941 Eds Cobol Training
118/120
ERROR CODES
7/18/2019 7078941 Eds Cobol Training
119/120
Presentation Title Here, Place on Slide Master, Trebuchet Font, 9 Pt., Normal 30 Sept 2005 page 119 EDS Internal
00 - Successful completion
02 - Duplicate key detected10 - Sequential READ was attempted on an optional file that
was not present or after end of file is reached
21 A sequence error exists for a sequentially accessedindexed file
39 - An OPEN statement was unsuccessful because of aconflict between the fixed file attributes and theattributes specified for the file in the program
7/18/2019 7078941 Eds Cobol Training
120/120