IBM Mainframes: COBOL Training Class-4
IBM Mainframes: COBOL Training Class-4
Syntax:
1
#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.
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
%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)
&
D,T, #I-+.
'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 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.
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
,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