Chapter 2
-
Upload
man2sandsce17 -
Category
Education
-
view
88 -
download
2
description
Transcript of Chapter 2
![Page 1: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/1.jpg)
COBOL COMMON BUSINESS ORIENTED LANGUAGE
![Page 2: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/2.jpg)
Contents
Divisions—General Formats.
Level structure.
Data Description Entries.—PITURE and VALUE Clause.
Editing Characters.
Special–names Paragraph, Classes and categories of Data.
![Page 3: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/3.jpg)
IDENTIFICATION DIVISION
Provides identifying information about program.
Divided into paragraphs.
PROGRAM-ID is only required paragraph . The entry in the PROGRAM-ID paragraph contains the program name to be used to identify the object program.
Other paragraphs are optional.
Used mainly for documentation purpose.
The division heading and paragraph names should be coded as area A entries.
![Page 4: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/4.jpg)
IDENTIFICATION DIVISION
Format
IDENTIFICATION DIVISION.
PROGRAM-ID. entry.
[AUTHOR. entry.]
[INSTALLATION. entry.]
[DATE-WRITTEN. entry.]
[DATE-COMPILED. entry.]
[SECURITY. entry.]
![Page 5: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/5.jpg)
IDENTIFICATION DIVISION.PROGRAM-ID. PROG1.AUTHOR. R.R.
BHATT.INSTALLATION. ABC CORP.DATE-WRITTEN. 01-JAN-2005.DATE-COMPILED. 01-JAN-
2005.SECURITY. HIGH.
IDENTIFICATION DIVISION.PROGRAM-ID. PROG1.AUTHOR. R.R.
BHATT.INSTALLATION. ABC CORP.DATE-WRITTEN. 01-JAN-2005.DATE-COMPILED. 01-JAN-
2005.SECURITY. HIGH.
OPTIONAL
Compiler takes this as Program Identifier.
PROGRAM-ID comes immediately after ID
Division.
IDENTIFICATION DIVISION …
![Page 6: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/6.jpg)
ENVIRONMENT DIVISION
The computer and all peripheral devices required by the program are described in this division.
This division is machine-dependent since devices differ from computer to computer.
It consists of 2 sections.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. entry.
OBJECT-COMPUTER. entry.
[SPECIAL NAMES. Entry].
[INPUT-OUTPUT SECTION.
FILE-CONTROL. {entry}.
[I-O-CONTROL. entry].]
![Page 7: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/7.jpg)
ENVIRONMENT DIVISION
CONFIGURATION SECTION INPUT-OUTPUT SECTION
Identifies the computer used for
compiling of programs
Identifies the resources used for
executing the program
ENVIRONMENT DIVISION
![Page 8: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/8.jpg)
1.CONFIGURATION SECTION
This section contains an overall specification of the computer used for the purpose of compilation and execution of the program.
The SOURCE-COMPUTER paragraph specifies the name of the computer used to compile the COBOL program.
The OBJECT-COMPUTER paragraph describes the computer on which the program is to be executed. It consist of MEMORY SIZE, SEGMENT LIMIT etc.
The SPECIAL_NAMES is used to relate some hardware names to user-specified mnemonic names. This is optional in all computers.
SOURCE-COMPUTER. ICL-1901.
OBJECT-COMPUTER. ICL-1900.
SPECIAL NAMES. DECIMAL-POINT IS COMMA.
![Page 9: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/9.jpg)
2.INPUT-OUTPUT SECTION
INPUT-OUTPUT SECTION
This section contains information regarding files to be used in the program.
The INPUT-OUTPUT SECTION consists of two paragraphs namely FILE CONTROL paragraph and I-O CONTROL paragraph.
In the FILE CONTROL paragraph a file name is selected for each file to be used in the program and assigned to a device. The simplified format of a file control entry is given below:
SELECT file-name ASSIGN TO hardware-name.
This section as a whole is optional in many computers.
![Page 10: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/10.jpg)
The DATA DIVISION is used to describe the data structures used in the program.
There are sections in the DATA DIVISION
1. FILE SECTION
2. WORKING-STORAGE SECTION
3. LOCAL STORAGE SECTION
4. LINKAGE SECTION
5. COMMUNICATION SECTION
6. REPORT SECTION
7. SCREEN SECTION
DATA DIVISION
![Page 11: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/11.jpg)
The two most commonly used components (sections) are
a) WORKING-STORAGE SECTION
Internal data structures are defined here.
b) FILE SECTION
File I/O buffer areas are defined here.
General Format
DATA DIVISION.
[ FILE SECTION.
file section entries. ………….. ]
[ WORKING-STORAGE SECTION.
working-storage entries. ……….. ]
![Page 12: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/12.jpg)
DATA DIVISION
The DATA DIVISION is used to declare the data items that will be processed in the PROCEDURE DIVISION of the source program. Though there are seven different SECTIONs in DATA DIVISION, which appear in the order :
1) FILE SECTION
The FILE SECTION is used to declare the FD (File descriptor) and SD (Sort descriptor) entries for files and sort files used in the program.
2) WORKING-STORAGE SECTION
The WORKING-STORAGE SECTION is used to declare all the temporary variables and record structures used in the program.
![Page 13: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/13.jpg)
3) LOCAL STORAGE SECTION
1) The LOCAL-STORAGE SECTION defines storage that is allocated and freed on a per requirement basis.
2) On each requirement, data items defined in the Local-Storage Section are reallocated and initialized to the value assigned in their VALUE clauses.
4) LINKAGE SECTION
1) The LINKAGE SECTION is used to describe data items made available from another program.
2) Storage is not allocated to the data structures defined in the LINKAGE SECTION as the data exists elsewhere.
![Page 14: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/14.jpg)
5) COMMUNICATION SECTION
1) The COMMUNICATION SECTION is used to create a control block required for communication, which is release dependent.
6) REPORT SECTION
1) The REPORT SECTION is used to describe RD (Report Descriptor) entries, which will be required for Report Writer Module.
![Page 15: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/15.jpg)
7) SCREEN SECTION
1) The SCREEN SECTION is used to describe labels and data items, which will be required for formatted input/output in case of application programs developed for Personal computers.
Of these the sections which are most commonly used are –
a) WORKING-STORAGE SECTION
b) FILE SECTION
![Page 16: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/16.jpg)
The PROCEDURE DIVISION consists of the following
1. Sections
2. Paragraphs
3. Sentences
4. Statements
General Format
PROCEDURE DIVISION.
[ section-name SECTION.
[paragraph-name. [sentence] …. ] …. ]
PROCEDURE DIVISION
![Page 17: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/17.jpg)
PROCEDURE DIVISION
PROCEDURE DIVISION.
0001-ACCOUNT SECTION.
001-ACCOUNT-READ-PARA. READ ACC-FILE AT END MOVE ‘Y’ TO EOF. MOVE TAX-REDUCT TO TAX-AMOUNT
001-ACCOUNT-VALIDATE-PARA. ADD AMOUNT TO TOT-AMOUNT. IF AMOUNT IS GREATER THAN 1000 GO-TO ACCOUNT-READ-PARA.
ACCEPT EMPLOYEE-SALARY. DISPLAY “Current Employee Salary “
EMPLOYEE-SALARY.001-EXIT-PARA. STOP RUN.
Section
Paragraph
Sentences
statement
Section contain one or more Paragraphs.
A PARAGRAPH comprises of one or
more sentences
A SENTENCE is a combination of one or more statements and is terminated by a full stop.
A STATEMENT is a combination of a COBOL verb and one or more operands.
![Page 18: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/18.jpg)
IDENTIFICATION DIVISION.
PROGRAM-ID. FIRSTPG.
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY ‘-------------------------------’.
DISPLAY ‘ WELCOME TO COBOL’.
DISPLAY ‘--------------------------------’.
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID. FIRSTPG.
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY ‘-------------------------------’.
DISPLAY ‘ WELCOME TO COBOL’.
DISPLAY ‘--------------------------------’.
STOP RUN.
First COBOL program
![Page 19: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/19.jpg)
DATA Description Entries
A data description entry describes a data item.
A component in this context is a level number, a data name or a clause.
Except for the level number, no other component can appear in area A.
There must be at least one space between any two consecutive components of an entry.
![Page 20: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/20.jpg)
All the data names used in the PROCEDURE DIVISION must be described in the DATA DIVISION.
The description of a data name is done with the aid of the following –
(1) Level number(2) PICTURE clause(3) VALUE clause
Description of data names
DATA DIVISION.01 EMP-NO PIC X(10) VALUE 1001.
LEVEL NO Data Name Picture Clause VALUE Clause
![Page 21: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/21.jpg)
It is a two-digit number starting from 01. Is used to specify the data hierarchy.
Level number
Level Number Purpose
01 Record description and independent items
02 to 49 Fields within records and sub items
66 RENAMES clause
77 Independent items
88 Condition names
DATA NAME LEVEL NO
![Page 22: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/22.jpg)
Picture Clause
The PICTURE Clause describes the general characteristics of an elementary data item. The characteristics are
1. CLASS—A data item may be one of the 3 classes.
NUMERIC---Digits 0 to 9.
ALPHABETIC---A to Z & Space (Blank) Character.
ALPHANUMERIC---Digits, Letters, Special Characters.
2. SIGN---A numeric data item can be signed or unsigned. Implicitly, unsigned, ie Positive.
Sign can be specified in the PICTURE clause to describe a signed data item.
![Page 23: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/23.jpg)
Picture Clause
3.POINT LOCATION---The position of the decimal point is another characteristic that can be specified in the case of numeric data items.
4.SIZE---Which specify the number of characters or digits required to store the data item in the memory.
General format for PICTURE clause
PICTURE [PIC] IS character-string.
The PICTURE clause is only to be specified for elementary items. It can’t be used for a group item.
The size of a group item is equal to the total of the sizes of all subordinate elementary items.
The class of a group item is alphanumeric.
![Page 24: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/24.jpg)
Code Characters Meaning 9 Numeric
A Alphabetic
X Alphanumeric
S (Signed) Sign bit
V position of Assumed Decimal point
P position of Assumed Decimal point when the point lies outside the data item
Picture Clause
![Page 25: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/25.jpg)
Rules
1. In Alphabetic item the picture may contain only A.
2. In Numeric item the picture may contain only 9,V,P,S.These are called operational characters. It must contain at least one 9 and V & S can appear only once.
S, if it is included, must be the leftmost character of the picture string.
The Symbol P can be repeated as many times as is required to indicate the position of the assumed decimal point.
3. In Alphanumeric item, the picture may contain all Xs or a combination of 9, A and X (except all 9 or all A).
![Page 26: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/26.jpg)
Example
1.PIC IS S999V99
Means data is signed numeric with size 5 characters. The position of decimal point is before 2 places from the rightmost end.
2. PIC IS PPP999
Means data is of 3 characters in size & 6 positions after the assumed decimal point.
Data is 234, the value will be taken as .000234.
3. PIC IS 999PP
Data is 234, the value will be taken as 23400.
![Page 27: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/27.jpg)
COBOL ‘PICTURE’ Clauses
Some examples
PICTURE 999 a three digit (+ive only) integer
PICTURE S999 a three digit (+ive/-ive) integer
PICTURE XXXX a four character text item or string
PICTURE 99V99 a +ive ‘real’ in the range 0 to 99.99
PICTURE S9V9 a +ive/-ive ‘real’ in the range ?
If you wish you can use the abbreviation PIC.
Numeric values can have a maximum of 18 (eighteen) digits (i.e. 9’s).
The limit on string values is usually system-dependent.
![Page 28: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/28.jpg)
Abbreviating recurring symbols
Instead of repeating 9, X, A or P in the picture string, it is possible to write the number of occurrences of a character enclosed within parentheses immediately after the said character.
Recurring symbols can be specified using a ‘repeat’ factor inside round brackets
PIC A(6) is equivalent to PICTURE AAAAAA.
PIC 9(6)V99 is equivalent to PIC 999999V99
PICTURE X(10) is equivalent to PIC XXXXXXXXXX
PIC S9(4)V9(4) is equivalent to PIC S9999V9999
PIC 9(18) is equivalent to PIC 999999999999999999
![Page 29: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/29.jpg)
Declaring DATA in COBOL
In COBOL a variable declaration consists of a line containing the following items;
ŒA level number.
A data-name or identifier.
ŽA PICTURE clause.
DATA DIVISION.WORKING-STORAGE SECTION.01 Num1 PIC 999 VALUE ZEROS.01 VatRate PIC V99 VALUE .18.01 StudentName PIC X(10) VALUE SPACES.
Num1 VatRate StudentNameNum1 VatRate StudentName
000000 .18.18
DDATAATA
![Page 30: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/30.jpg)
VALUE clause
Is used to assign an initial value to a elementary data item. Syntax: VALUE IS literal.
The initial value can be numeric literal, non- numeric literal or figurative constant.
We can give a starting value to variables by means of an extension to the picture clause called the value clause.
It is an optional clause.
Examples: 1)VALUE IS 23.5.
2)VALUE IS “ Apples”. Or VALUE IS “My Data”.
3) VALUE ZERO.
![Page 31: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/31.jpg)
VALUE clause
If a VALUE clause is used at a group level , it should not be used for any item within the group. Only nonnumeric literals and figurative constants can be used to specify the value of a group item.
Example—1) 03 num1 PIC S9(3)V99 VALUE -2.34.
Here data item is level 3 elementary item belonging to a group.
2) 01 num2 VALUE IS “234567”.
02 data-1 PIC 9(2). ----- 23
02 data-2 PIC 9(3). ----- 456 Values Stored
02 data-3 PIC 9(1). ----- 7
![Page 32: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/32.jpg)
In COBOL the term “group item” is used to describe a data item which has been further subdivided.
A Group item is declared using a level number and a data name. It cannot have a picture clause.
Where a group item is the highest item in a data hierarchy it is referred to as a record and uses the level number 01.
Picture clauses are NOT specified for ‘group’ data items because the size of a group item is the sum of the sizes of its subordinate, elementary items and its type is always assumed to be PIC X.
Group and elementary items
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).
01 EMPLOYEE-DETAILS. 05 EMP-NUM PIC 9(4). 05 EMP-NAME PIC X(10). 05 EMP-DEPT PIC X(4). 05 EMP-LOC PIC X(12).
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).
01 EMPLOYEE-DETAILS. 05 EMP-NUM PIC 9(4). 05 EMP-NAME PIC X(10). 05 EMP-DEPT PIC X(4). 05 EMP-LOC PIC X(12).
![Page 33: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/33.jpg)
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(20).
01 EMPLOYEE-DETAILS. 05 EMP-NUM PIC 9(4). 05 EMP-NAME PIC X(10). 05 EMP-DEPT PIC X(4). 05 EMP-LOC PIC X(12).
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(20).
01 EMPLOYEE-DETAILS. 05 EMP-NUM PIC 9(4). 05 EMP-NAME PIC X(10). 05 EMP-DEPT PIC X(4). 05 EMP-LOC PIC X(12).
Group item
Sub-Items
Group Items/Records - Example
![Page 34: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/34.jpg)
123456789012345678901234567890 (cols)1234JyothiS E&R Bangalore2234Archana E&R Marathi9999Bhushan E&R C++
Data in input file
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).
1234JyothiS E&R Bangalore1234JyothiS E&R Bangalore
Variable for file read Value
Group Items/Records - Example
![Page 35: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/35.jpg)
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).
01 EMPLOYEE-DETAILS. 05 EMP-NUM PIC 9(4). 05 EMP-NAME PIC X(10). 05 EMP-DEPT PIC X(4). 05 EMP-LOC PIC X(12).
WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).
01 EMPLOYEE-DETAILS. 05 EMP-NUM PIC 9(4). 05 EMP-NAME PIC X(10). 05 EMP-DEPT PIC X(4). 05 EMP-LOC PIC X(12).
1234JyothiS E&R Bangalore
1234JyothiSE&RBangalore
1234JyothiS E&R Bangalore
1234JyothiSE&RBangalore
Variable for file read Value
123456789012345678901234567890 (cols)1234JyothiS E&R Bangalore2234Archana E&R Mysore9999Bhushan E&R Chennai
Data in input file
Group Items/Records - Example
![Page 36: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/36.jpg)
In COBOL, Level numbers are used to express data hierarchy. The higher the level number, the lower the item is in the hierarchy.
So Group items contain sets of elementary items with lower level numbers. At the lowest level the data is completely atomic.
LEVEL Numbers & DATA hierarchy
WORKING-STORAGE SECTION.01 POLICY-DETAILS. 05 POLICY-NO. 10 POLICY-TYP PIC X(4). 10 POLICY-LOC PIC X(2). 10 POLICY-ID PIC X(5). 05 POLICY-TYPE PIC X(10). 05 POLICY-EXPDT PIC X(10).
WORKING-STORAGE SECTION.01 POLICY-DETAILS. 05 POLICY-NO. 10 POLICY-TYP PIC X(4). 10 POLICY-LOC PIC X(2). 10 POLICY-ID PIC X(5). 05 POLICY-TYPE PIC X(10). 05 POLICY-EXPDT PIC X(10).
![Page 37: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/37.jpg)
DATA DIVISION.WORKING-STORAGE SECTION.01 REGNO PIC X(5).01 NAME.
05 FIRST-NAME PIC A(15).05 MID-NAME PIC A(15).05 LAST-NAME PIC A(10).
01 AGE PIC 99V99. 01 SCHOLARSHIP PIC 9(4) VALUE 1000.
DATA DIVISION.WORKING-STORAGE SECTION.01 REGNO PIC X(5).01 NAME.
05 FIRST-NAME PIC A(15).05 MID-NAME PIC A(15).05 LAST-NAME PIC A(10).
01 AGE PIC 99V99. 01 SCHOLARSHIP PIC 9(4) VALUE 1000.
Description of data names
![Page 38: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/38.jpg)
H E N N E S S Y R M 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 F
Group Items/Records
StudentDetails
WORKING-STORAGE SECTION.01 StudentDetails PIC X(26).
WORKING-STORAGE SECTION.01 StudentDetails PIC X(26).
![Page 39: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/39.jpg)
H E N N E S S Y R M 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 F
StudentDetails
StudentName StudentId CourseCode Grant Gender
Group Items/Records
WORKING-STORAGE SECTION.01 StudentDetails.
0202 StudentNameStudentName PIC X(10).PIC X(10).0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.
WORKING-STORAGE SECTION.01 StudentDetails.
0202 StudentNameStudentName PIC X(10).PIC X(10).0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.
![Page 40: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/40.jpg)
H E N N E S S Y R M 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 F
StudentDetails
Surname Initials
WORKING-STORAGE SECTION.01 StudentDetails.
0202 StudentName.StudentName.03 Surname03 Surname PIC X(8).PIC X(8).03 Initials03 Initials PIC XX.PIC XX.
0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.
WORKING-STORAGE SECTION.01 StudentDetails.
0202 StudentName.StudentName.03 Surname03 Surname PIC X(8).PIC X(8).03 Initials03 Initials PIC XX.PIC XX.
0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.
StudentName StudentId CourseCode Grant Gender
Group Items/Records
![Page 41: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/41.jpg)
FILE SECTION
This contain a file description entry followed by one or more record description entries for each of the files used in a program.
Format for file description entry is
FD file-name LABEL RECORDS ARE STANDARD
RECORD IS OMITTED
The label indicator FD must begin in Area A and rest of the file description entry must appear only in Area B.
The file-name must be identical with the file name specified in the select clause of the ENVIRONMENT section.
STANDARD option should be specified for disk files, OMITTED option should be specified for card reader and printer files.
LABEL RECORD clause---it is mandatory in ANSI 74. Many compilers treat it as optional.
![Page 42: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/42.jpg)
FILE SECTION
The coding rule for an FD entry is similar to that of level 01 entry.
The description entries that follow the file description entry, should describe the record types in the file. There should be one record description entry for each type of record.
A record description entry is a 01 level group item along with all its subdivisions.
Example
FD card-file.
01 card-records.
02 num pic 9(3).
02 price pic 9(2)v9(2)
02 amount pic 9(2)v9(2)
![Page 43: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/43.jpg)
WORKING-STORAGE SECTION
The data in the working storage can be group item, containing all its subdivisions same as record description.
There may also be elementary data item which do not belong to a group. Such data items should be defined at a special level number 77. Level number 77 must begin in Area A.
Elementary item in this section need not always be defined at the level 77. It can as well be defined at the level 01.Example----
WORKING-STIRAGE SECTION.
77 num PIC X(7).
01 date.
05 day pic 99.
05 month pic 99.
05 year pic 9999.
01 address pic x(10).
![Page 44: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/44.jpg)
EDITING PICTURE CLAUSE
![Page 45: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/45.jpg)
EDITING
The data to be printed in a report requires some editing.
Example—To print a numeric data item ,by suppressing the leading zeros.
Editing is normally performed by moving a numeric data item to a field containing special editing characters in its picture clause.
Following characters can be used in the PICTURE clause to indicate editing
Z * $ - + CR DB . , B 0 /
![Page 46: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/46.jpg)
Edit symbol Meaning
Z Zero suppression
* Check protection
, Comma insertion
- Minus sign insertion
+ Plus or minus sign insertion
Edited picture symbols
![Page 47: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/47.jpg)
Edited picture symbols
Edit symbol Meaning
$ Dollar sign insertion
CR Credit symbol
DB Debit symbol
B Blank insertion
/ Slash insertion
. Decimal point insertion
BLANK WHEN ZERO
Blank insertion when the value is zero
![Page 48: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/48.jpg)
Z-Zero suppression
The Z has the same meaning as that of 9 in the picture except that the leading zeros in the source data.
If any, in the digit positions indicated by Z will be suppressed—Replaced by space characters.
It is obvious that Z cannot appear to the right of any 9.
After the decimal point either the digit positions are indicated by all Z or none at all.
In the below examples
The character b ---is used to indicate a space character.
The character ^ ---is used to indicate the position of the decimal point.
![Page 49: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/49.jpg)
ZZ999 01234 b1234 ZZ999 00034 bb034 ZZ999 1^23 bb001 ZZZV99 12^3 b1230 ZZZV99 0^12 bbb12 ZZZZVZZ 0^01 bbbb01 ZZZZVZZ 0 bbbbbb
Edit symbol Value Edited value
Z (Zero Suppression)---Example
![Page 50: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/50.jpg)
*(Asterisk) Example
This is same as Z except that the leading zeros are replaced by * instead of space.
Edit symbol Value Edited value
**999 01234 *1234 **999 00012 **012 **999 1^23 **001
![Page 51: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/51.jpg)
$(Currency Sign) Example
A single currency sign can appear at the leftmost position of a picture. In that case the $ character is inserted.Edit symbol Value Edited value
$99999 123 $00123 $99999 12345 $12345 $ZZ999 123 $bb123 $ZZ999 12345 $12345 $**999 123 $**123
![Page 52: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/52.jpg)
-(Minus Sign) Example
It can appear at leftmost or rightmost position of the picture. If the value of an item is –ve, a - sign will be inserted, If value is +ve, a space character will be inserted.
Edit symbol Value Edited value
-9999 -123 -0123 -9999 123 b0123 9999- -123 0123- 9999- 123 0123b -ZZZV99 -12^34 -b1234 -ZZZV99 12^34 bb1234
![Page 53: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/53.jpg)
+(Plus Sign) Example
It is same as minus sign except that when the item is +ve, + sign will be inserted. If value is –ve, - sign will be inserted,.
Edit symbol Value Edited value
+9999 -123 -0123 +9999 123 +0123 9999+ -123 0123- 9999+ 123 0123+ +ZZZV99 -12^34 -b1234 +ZZZV99 12^34 +b1234
![Page 54: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/54.jpg)
CR and DB (Credit and Debit Sign) Example
CR or DB symbol appear only at the rightmost position of the picture. These symbols appear in the rightmost position only if the item is negative, otherwise they will be replaced by 2 spaces.
Edit symbol Value Edited value
9999CR -1234 1234CR 9999CR 1234 1234bb ZZZCR -12 b12CR ZZZ9V99DB -123^45 b12345DB ZZZ9V99DB 123^45 b12345bb
![Page 55: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/55.jpg)
Period or Decimal Point-Example
It is used to insert a decimal point and may not appear more than once.
Both period & V cannot appear in the same picture.
A period must not also appear as the rightmost character in the picture.
If all the digits before and after the period happen to be zeros, the period does not stop zero suppression and the entire field including the period is space-filled (the period is not filled with space when an asterisk(*) is used as a zero-suppression character.
![Page 56: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/56.jpg)
Period or Decimal Point-Example
Edit symbol Value Edited value
9999.99 123^45 0123.45 ZZ99.99 12^34 bb12.34 ZZ99.99 123 b123.00 ZZZZ.ZZ 0^01 bbbb.01 ZZZZ.ZZ 0 bbbbbbb ****.** 0 ****.** $ZZZ9.99 0123 $b123.00
![Page 57: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/57.jpg)
, (Comma)-- Example
It is treated as an insertion character and inserted wherever it appears.
If zero suppression takes place to the right of any comma, the said comma will also be suppressed and a space character will take its position .
It cannot appear either as the rightmost or leftmost character in a picture.
There can be more than one comma in a picture.
![Page 58: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/58.jpg)
, (Comma)-- Example
Edit symbol Value Edited value
99,999 1234 01,234 99,999 12 00,012 ZZ,Z99 1234 b1,234 **,*** 12 ****12 *,***,** 123 ****1,23 *,***,** 123456 1,234,56 ZZ,Z9.99 123^45 b1,23.45
![Page 59: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/59.jpg)
B (Blank Insertion)-- Example
The appearance of a B anywhere in the picture will insert a space character in the edited data. There can be more than one B in a picture.
Edit symbol Value Edited value
99B99B99 123456 12b34b56 99B99B99 12 00b00b12
![Page 60: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/60.jpg)
Z (Zero Insertion)-- Example
It is same as B except that 0 will be inserted instead of a space character.
Edit symbol Value Edited value
9900 12 1200 09990 123 01230
![Page 61: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/61.jpg)
/ (Slash Insertion)-- Example
It may appear anywhere in the picture. If used, it will be inserted. It is also called as stroke.
Edit symbol Value Edited value
99/99/99 123456 12/34/56 999/999/99 1234 000/012/34
![Page 62: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/62.jpg)
BLANK WHEN ZERO-- Example
BLANK WHEN ZERO is an editing clause which may be used along with a picture.
This will set the entire data item to blanks if its value is equal to 0.
Edit symbol Value Edited value
ZZZ.99 BLANK WHEN ZERO 1^2 bb1.20ZZZ.99 BLANK WHEN ZERO 0 bbbbbb999.99 BLANK WHEN ZERO 0 bbbbbb
![Page 63: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/63.jpg)
SPECIAL-NAMES Paragraph
If a currency symbol other than $ is required for editing, a one character symbol may be specified in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION.
This character may not be a digit or letters A to D, L, P, R, S, V, X, Z or special characters blank * - , . ; ( ) + ‘ ‘ / =.
Syntax
SPECIAL-NAMES.
CURRENCY SIGN IS “ character”.
Specifies a substitute character for the currency sign
DECIMAL-POINT IS COMMA.
![Page 64: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/64.jpg)
CLASSES AND CATEGORIES OF DATA
All elementary data items are classified into the following 5 categories.
1.Alphabetic ( A)
2.Numeric( 9)
3.Alphanumeric (X)
4.Edited numeric ( Z, $)
5.Edited alphanumeric(/,-)
The characters in the picture string determines the category of an elementary data item.
![Page 65: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/65.jpg)
Categories and the corresponding symbols used in the PICTURE character string
1.Alphabetic A
2.Numeric 9 P S V
3.Edited Numeric 9 P V and at least one of the
editing symbols B / Z 0 + - * , . CR DB
4.Alphanumeric X 9 A (at least one X or a
combination of 9 and A)
5.Edited Alphanumeric X 9 A B 0 / ( must contain at least one X with at least one of B 0 / or at least one A with at least one 0 or /)
![Page 66: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/66.jpg)
CLASS & CATEGORY
These five categories of data are grouped into 3 classes. The class of a data item indicates how the data is treated during execution.
Level of Data Item Class category
Elementary Alphabetic Alphabetic
Numeric Numeric
Alphanumeric Numeric edited
Alphanumeric
Alphanumeric Edited
Group Alphanumeric Elementary data
within the group may
belong to any category.
![Page 67: Chapter 2](https://reader033.fdocuments.us/reader033/viewer/2022052903/5577e3a8d8b42a7b7b8b4ddd/html5/thumbnails/67.jpg)
Questions ?