0% found this document useful (0 votes)
53 views12 pages

IBM Mainframes: COBOL Training Class-4

This document provides information on data item declaration and variable naming in COBOL. It discusses the syntax for declaring variables using LEVEL-NO, VAR-NAME, PIC, DATATYPE, and VALUE clauses. It describes the different level numbers for group and elementary data items and rules for naming variables. It also explains the different data types in COBOL and examples of declaring variables with PIC, VALUE, and CONSTANT clauses.

Uploaded by

ravikiran_8p
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views12 pages

IBM Mainframes: COBOL Training Class-4

This document provides information on data item declaration and variable naming in COBOL. It discusses the syntax for declaring variables using LEVEL-NO, VAR-NAME, PIC, DATATYPE, and VALUE clauses. It describes the different level numbers for group and elementary data items and rules for naming variables. It also explains the different data types in COBOL and examples of declaring variables with PIC, VALUE, and CONSTANT clauses.

Uploaded by

ravikiran_8p
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
You are on page 1/ 12

IBM Mainframes

COBOL Training Class-4

DataItems/Variable Declaration in COBOL

Syntax:
1

Only in DATA DIVISION. 2 3 4 5 6

LEVEL-NO VAR-NAME PIC DATATYPE (SIZE) VALUE LITERAL.

Level Number Pi !ure Value lau&e

Variable Name Da!a !"#e a$% &i'e Li!eral ( )$&!a$!

Level Numbers in COBOL

There are two types of data Items.

Gro p data Item

"lementary data item

#e$el % m&er spe'ifies the type of the data item and the hierar'hi'al le$el of the data items. we ha$e (ifferent #e$el % m&ers )1* )2+to+4,* 66* -- and .. *+ // 00 11 Gro p (ata Item /nd "lementary (ata Item. 2ename 3Gro pin1 The (ifferent Gro ps4. 5 rely "lementary (ata Item. 6ondition %ame 6ondition. *, To -. Gro p (ata Item Or S &01ro p Item.

Rules to Name a Data Item

The $aria&le0name sho


'hara'ters.

ld not ex'eed more than 3)

Only the allowa&le spe'ial 'har is hyphen. 7yphen sho ld not &e present at the startin1 or else at
the endin1.

8e sho

ld not 1i$e any reser$ed words.

E.2.3 (isplay* (i$ision* Se'tion et'+

Data t !es in COBOL

%e &ave 'ive T !es But Basicall onl t&ree Data T !e In Cobol Ma" Data #i$e 9 A X ! 18 160 Cobol-85 120 Cobol-7 Combi#atio# (ith Numeric 9 %&e !9 (%&e' -&e) 9(*) + 9(2)

Numeric (0-9) Alphabetic (a-z) Alpha Numeric (a-z)/(0-9) !i"#e$ (%&e' -&e)

A))ume$ $ecimal poi#t

&

#i$e ( )ICT*R+ Clause

D,T, #I-+.

,ata )ize i) u)e$ to allocate the memor- i#ter#all-.


Numeric' Alpha#umeric a#$ Alphabetic $atat-pe) are "oi#" to ta/e 1 b-te o0 memor- i#ter#all-.

)ICT*R+ CL,*#+ /)IC.

12C i) u)e$ to i$e#ti0- the $ata t-pe a#$ $ata )ize.


3hi) clau)e al(a-) ha) to be prece$e$ be0ore )peci0-i#" t-pe a#$ )ize

NOT+. /rou! 0ata items 0oes not contain )IC Clause

'e1 e"am!les
*+ EMP-DET. *4 EMP-ID PIC .(-). *4 EMP-NAME PIC 5(+*). *4 EMP-LOC. +* CITY PIC 5(+*). +* STATE PIC 5(+*). *4 EMP-DO6 PIC 5(1). *+ STUDENT7DETAILS. *4 8S-SU6+ PIC *4 8S-SU6, PIC *4 8S-SU69 PIC *4 8S-SUM PIC *4 8S-AV: PIC .(9). .(9). .(9). .(9). .(9) V .(,).

Value Clause ( Constants

VALUE CLAUSE is sed to assi1n $al es to the $aria&le at the time of de'laration and only in DATA DIVISION. I! helps in remo$in1 1ar&a1e $al es from the $aria&le memory lo'ation. CONSTANTS are sed alon1 with the $al e 'la se to assi1n initial $al e to the data items.

Three types of 6onstants:

Numeri C)$&!a$!& N)$-Numeri C)$&!a$!& ;i2ura!ive C)$&!a$!&

Constants

Cont022

;i2ura!ive )$&!a$!& are reser$ed words that name and refer to spe'ifi' 'onstant $al es. The reser$ed words for fi1 rati$e 'onstants and their meanin1s are:

ZERO(ZEROS(ZEROES SPACE(SPACES

Numeri C)$&!a$!& are any n meri'al $al e si1ned9 nsi1ned.

1)* 01) ,,.,, et'.*


N)$-Numeri C)$&!a$!& are any $al e that are spe'ified in &etween : otes 3;4.

<=ell)> ? <+*> ? <+,9ab > e! .

,00ition )rogram I("%TI<I6/TIO% (I=ISIO%. 52OG2/>0I(. /((5G>. "%=I2O%>"%T (I=ISIO%. (/T/ (I=ISIO%. 8O2?I%G0STO2/G" S"6TIO%. )1 8S0/ 5I6 ,334 =/#@" .)). )1 8S0A 5I6 ,334 =/#@" -)). )1 8S06 5I6 ,344 =/#@" B"2OS. 52O6"(@2" (I=ISIO%. 6O>5@T" 8S06C 8S0/ D 8S0A. (IS5#/E ;8S06:F 8S06. STO5 2@%.

Run 3CL for ,00 !rogram 99<SS1,-"G HOA 123*FT"/>F*%OTI<EC!SES@I( 99ST"51 "G"6 5G>C/((5G> 99ST"5#IA (( (S%C<SS1,-.T"/>.#O/(*(IS5CS72 99SES52I%T (( SESO@TCI 99SESO@T (( SESO@TCI 99

T&an4 5ou

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy