[go: up one dir, main page]

0% found this document useful (0 votes)
39 views4 pages

COBOL Lesson 4a

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

COBOL Lesson 4a

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Lesson 4a

DATA DIVISION

I. TYPES OF DATA
Variable Data 9 - numeric 9, V – numeric float
X - alphanumeric & special characters
Constant Data A - alphabetic

int sctr=0; 05 SCTR PICTURE 99 VALUE 00.


const int sctr=0;
05 FILLER PICTURE X(18) VALUE “TOTAL SALESMEN: “.
05 FILLER PICTURE X(18) VALUE “TOTAL ACC. SALES: “.

II. DATA ORGANIZATION


1. File
2. Record
3. Data Field
Subdivisions of Data Field
a. group data field – can be further subdivided into smaller unit of data
b. elementary data field – cannot be further subdivided into smaller unit of data
 all elementary data field must have a PIC clause

01 REC-IN.
05 AC-IN PIC A.
05 SNO-IN PIC X(3).
05 SNAME-IN.
10 FN PIC X(10).
10 MN PIC X(10).
10 LN PIC X(10).
05 SALES-IN PIC 9(5)V99.

Level Number – signifies the hierarchy of the data or which data belongs to other data

/*Example:

PHILS.

LUZON VISAYAS MINDANAO

REG REG REG REG REG12


1 2 7 8

PROV1 PROV2 PROV3 PROV4 PROV5 PROV6


ON ON ON

C1 C2 C3 C4 C5

B1 B2 B4 B5
01 PHILS.
05 LUZON.
10 REG1.
15 PROV1.
20 C1 PIC.
20 C2 PIC.
15 PROV2.
20 C3.
25 B1 PIC.
25 B2 PIC.
10 REG2.
15 PROV3.
20 C4 PIC.
15 PROV4.
20 C5.
25 B4 PIC.
25 B5 PIC.
05 VISAYAS.
10 REG7 PIC.
10 REG8.
15 PROV5 PIC.
15 PROV6 PIC.
05 MINDANAO.
10 REG12 PIC.

III. DATA DIVISION’S CLAUSES

A. The PICTURE Clause

Character Data Types


 9 numeric 9, V – numeric float
 X alphanumeric with special characters
 A alphabetic

05 SCTR PIC 99.


05 AVE PIC 9V99.
05 SNAME1 PIC X(30).
05 SNAME2 PIC A(30).

Other Picture Characters

Input / Temporary storage variables (variables for computation)


 V denotes an assumed decimal point – (P position of decimal point)
05 SALES-IN PIC 9(5)V99. 1234575 --- 12,345.75
1000050
0500025
0010075
0000100
 S denotes a positive / negative sign
05 SCTR PIC S999. -999 to 999
Output variables
 Decimal (.) and Comma (,)
05 SALES-IN PIC 9(5)V99.
MOVE SALES-IN TO SALES-OUT.

05 SALES-OUT PIC 99,999.99. 12,345.75


10,000.50
05,000.25
00,100.75
00,001.00

 Z - zero-suppression – used to replace zeros by blanks (Z numeric output data type)


05 SALES-OUT PIC ZZ,ZZ9.99. 12,345.75
10,000.50
5,000.25
100.75
1.00
0.00
05 ASCTR PIC 9(8)V99 VALUE 0.

05 ASCTR-OUT PICTURE 99,999,999.99. or 99,9(3),9(3).99 --- 00,000,001.00


OR 05 ASCTR-OUT PICTURE ZZ,ZZZ,ZZ9.99. --- 1.00
--- 0.00

 0 - zero insertion – used to insert zeroes


05 SALES-OUT PIC ZZ,ZZ9.00. 12,345.00
10,000.00
5,000.00
100.00
1.00
0.00

 B used to indicate/insert blanks (string only)


05 NAME-IN PIC X(6) VALUE “RACHEL”.
MOVE NAME-IN TO NAME-OUT.
05 NAME-OUT PIC XXBBBX(4)B. “RA CHEL ”

 / used to insert slash


05 DATE-IN PIC X(8) VALUE “09211978”.
MOVE DATE-IN TO DATE-OUT.
05 DATE-OUT PIC XX/XX/XXXX. “09/21/1978”

B. The VALUE Clause


- used to assign a value or an initial value to a data field

Format:
VALUE _initial-value
place immediately after the PICTURE clause

05 NAME-IN PIC X(6) VALUE “RACHEL”.


05 ASCTR PIC 9(7)V99 VALUE 0. ASCTR=0
05 TAC PIC A VALUE ‘_’. TAC = ‘ ‘
05 EOFSW PIC X(3) VALUE “NO ”. EOFSW = ‘NO ‘
C. The FILLER Clause
- generic data name used in DATA DIVISION with respect to data items especially constant strings

05 FILLER PICTURE X(18) VALUE “TOTAL SALESMEN: “.


05 FILLER PICTURE X(18) VALUE “TOTAL ACC. SALES: “.

You might also like