Download presentation
Presentation is loading. Please wait.
Published byEarl Walker Modified over 9 years ago
1
Module 2 Defining Data Revised 2011
2
Defining Data All definitions of data for COBOL takes place in the DATA DIVISION. All data defined are visible to all routines in the PROCEDURE DIVISION. Data Definitions fall into one of the following: Alphabetic Alphanumeric Numeric
3
COBOL ‘PICTURE’ Clause To create the required ‘picture’ the programmer uses a set of symbols. The following symbols are used in picture clauses: 9 ( the digit nine) is used to indicate the occurrence of a digit at the corresponding position in the picture. X (the character X) is used to indicate the occurrence of any character at the corresponding position in the picture. V (the character V) is used to indicate the position of the decimal point in a numeric value. S (the character S) indicates the presence of a sign.
4
Group & Elementary Items In COBOL the term “group item” is used to describe a data item which can be further divided: - A Group item is declared using a level number and a data name. It cannot have 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. “elementary item” is the lowest item in a data hierarchy. It cannot be further divided. An “elementary item” declaration consists of a level number, a data name and a picture clause.
5
Level Numbers Express Data Hierarchy 01Student Details. 02 Student Name. 03 SurnamePIC X (8). 03 InitialsPIC XX. 02StudentIdPIC 9(7). 02CourseCodePIC X(4). 02GenderPIC X.
6
Level Numbers Express Data Hierarchy 01Student Details. 03 Student Name. 05 SurnamePIC X(8). 05 InitialsPIC X(2). 03StudentIdPIC 9(7). 03CourseCodePIC X(4). 03GenderPIC X.
7
Abbreviating Recurring Symbols Recurring symbols can be specified using a ‘repeat’ factor inside the round brackets. PIC 9(6) is equivalent to PICTURE 999999 PIC 9(6)V99 is equivalent to PIC 999999V99 PICTURE X(10) is equivalent to PIC XXXXXXXXXX
8
Group Items/Records 01StudentDetailsPIC X(20). LEWISTT79866CSEB112M
9
Group Items/Records 01StudentDetails. 02StudentNamePIC X(5). 02StudentIDPIC X(7). 02 CourseCodePIC X(7). 02 GenderPIC X. LEWISTT79866CSEB112M StudentName StudentID CourseCode Gender
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.