Professional Documents
Culture Documents
Cobol: How Many Divisions in COBOL?
Cobol: How Many Divisions in COBOL?
Type E against the Dataset name. Enclose the member name next to
the Dataset name
Shown below. Press Enter 2 times. Save.
Enter again.
12-72
73-80
Purpose
Page/Line number
Continuity (-), Comment (*), Starting a new
page (/), Debugging lines
Margin A
Division, Section ,paragraph,
01,77 Level numbers
Margin B
All other declarations/statements begin here
Identification field. It will be ignored by the
compiler but visible in the source listing.
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
Environment Contains 2 sections.
Configuration Section
Input-Output section
Configuration section contains the following paragraphs.
SOURCE-COMPUTER
OBJECT-COMPUTER
FILE-CONTROL
I-O CONTROL
ENVIRONMENT DIVISION
Machine dependant division of COBOL program. This division gives
information about the source computers on which programs are executed
and the results on which results are viewed. When the programs are
moved from 3270 terminal to another terminal, the only division that is
affected is environment division.
Input-Output section: This section contains information about the files to
be used in the program (FILE-CONTROL).
10
DATA DIVISION
It contains 3 sections (Important sections)
FILE SECTION
WORKING-STORAGE SECTION
LINKAGE SECTION
FILE SECTION:
Describes the record structure of the files..
WORKING-STORAGE SECTION.
Declare temporary (working) variables. They will extinct as the
program execution
gets completed.
LINKAGE SECTION.
Receive data from the JCL OR from another program
11
PROCEDURE DIVISION
Program execution starts from this division.
Last statement in the COBOL program is STOP RUN.
STOP RUN returns the control to the operating system.
12
13
Declaration of Variable.
Level #
Clause
Variable
PIC clause
Value Clause
Usage Clause
Sync
Example
01
WS-NAME
PIC X(30)
Level Number: 01
Variable: WS-NAME
PIC Clause: X(10)
Value Clause: IBM MAINFRAME (Literal Data).
What is LEVEL Number?
It specifies the hierarchy of data within a record. It can take a value from
the set of integers between 01-49 OR from the special level numbers
from 66, 77, 88.
14
LEVE
L#
Meaning
01
02-49
66
RENAMES clause.
77
Independent data item.
Examples:
88
Condition names.
01
WS-DATE.
05 WS-CCYY
PIC X(04).
05 FILLER
PIC X(01).
05 WS-MM
PIC X(02).
05 FILLER
PIC X(01).
05 WS-DD
PIC X(02).
WS-DATE is group item. Doesnt have PIC clause as the elementary
items under it have PIC clause.
WS-CCYY, WS-MM & WS-DD are elementary data items dependent on 01
level.
15
Example 2:
01 WS-ARRAY.
02 WS-STD-ID PIC 9(3).
02 WS-STD-MARKS.
05 WS-MATHS PIC 9(3) .
05 WS-CHEM
PIC 9(3) .
WS-ARRAY is Group item. ( NO PIC clause).
Rules for the Variable name:
Length = 30 chars; First letter should be alphabet. Hyphen is the
only special character allowed and it cannot be first or last letter of the
name.
Examples #1:
WS-STD-MARKS
COBOL Data types:
Numeric
9
Alphanumeric
X
Alphabetic
A
01 C1 PIC X(10).
01 C2 PIC 9(10)
77 C3 PIC A(10)
16
Memory units:
Bit
Nibble: 4 bits
Byte: 8 Bits
Half Word: 2 Bytes
Full Word: 4 Bytes
Double word: 8 Bytes
A,X,9 will take one Byte.
X(10) How many bytes? : 10 Bytes.
9(10) How many bytes? : 10 Bytes.
A
How many bytes? : 1 Byte.
17
DAY 2
COMPILE &
EXECUTION
18
EDIT
SHRDV04.SOURCE(PGM01) - 01.02
Command ===>
****** ***************************** Top of Data *********
000001
IDENTIFICATION DIVISION.
000002
PROGRAM-ID. PGM01.
000003
PROCEDURE DIVISION.
000004
DISPLAY 'WELCOME TO COBOL'
000005
STOP RUN.
****** **************************** Bottom of Data *******
19
EDIT
SHRDV04.SOURCE(COBCOMP) - 01.04
Columns 00001 00072
Command ===>
Scroll ===> CSR
****** ***************************** Top of Data ******************************
000310 //SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X,
000320 //
CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
000400 //JOBPROC JCLLIB ORDER=IBMUSER.ALL1
000500 //COBCL EXEC IGYWCL,
000600 //
PGMLIB=SHRDV04.LOADLIB,
--> LOADLIB NAME
000610 //
COPYLIB=SHRDV04.COPYLIB,
--> COPYLIB NAME
000700 //
GOPGM=PGM01
--> MEMBER NAME
000800 //COBOL.SYSIN DD DSN=SHRDV04.SOURCE(PGM01),DISP=SHR
****** **************************** Bottom of Data ****************************
20
COMPILE JCL
//SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X,
//
CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID
The first two lines are known as JOBCARD statements.
What is a JCL:
JCL: JOB CONTROL LANGUAGE. JCL statements are recognized by // in
the first two columns.
JCL Coding Sheet:
1-2: // 3-10: Name 11-15: Operation 16: Operands
Continuation character: 16th column
3rd column: * indicates that JCL statement is comment.
Syntax.
//JOBNAME JOB (ACCOUNTING INFO), (PROGRAMMER NAME), Key word
parameters
Two types of parameters.
1. Positional parameter
2. Keyword parameter
Positional Parameters: JOBNAME, ACCOUTING INFO, PROGRAMMER
21
25
26
27
28
29
30
31
32
SHRDV04.SOURCE(COBRUN) - 01.02
33
34
35
36
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM03.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-A PIC 9(2) VALUE 20.
01 WS-B PIC 9(2) VALUE 80.
01 WS-C PIC 9(2) VALUE 0.
PROCEDURE DIVISION.
COMPUTE WS-C = WS-A + WS-B
ON SIZE ERROR DISPLAY 'SIZE ERROR'.
DISPLAY 'WS-A:' WS-A 'WS-B:' WS-B
DISPLAY 'WS-C:' WS-C
STOP RUN.
**************************** Bottom of Data *******************
Result looks like below:
37
38
39
Two active panels are available. They are ID# 2 & ID # 1. Here 2* says
40
that it is the active panel. To swap among the active screens/panels.
41
42