COBOL Programming
COBOL Programming
Course Pre-requisites
Some knowledge of information processing concepts and terms.
Topics Covered
Introduction to COBOL Program Structure ata T!pes Coding "ormat Programming ivisions Programming S!nta# Input$Output Processing String %andling &eport 'eneration
O()ectives
To *nderstand T+e "eatures of COBOL COBOL Programming S!nta# Condition Statements ,odes of "ile Processing %ow to Call ot+er Programs &eport 'eneration
COBOL L-.'*-'/
CO,,O. B*SI./SS O&I/.T/ L-.'*-'/ O&I'I. CO.C/I0/ 1 2343 P&/LI,I.-&5 0/&SIO. 1 /C 2343 "I&ST ST-. -& COBOL 1 2362 ST-. -& 0/&SIO.S -PP&O0/ B5 -.SI 1 23678 239: L-T/ST COBOL 0/&SIO. 1 2374 3; 0/&SIO. /;P/CT/
5
10
COBOL =O& S
&/S/&0/ =O& S T+ese are t+e Co(ol ver(s for specific functions can not (e used as user defined data names. e.g1 T5P/8 C&8 &8 BL-.<8 SP-C/8 A/&O etc.
11
COBOL =O& S
*S/& /"I./ =O& S -T+e word$.ame can (e an!t+ing ad+ering to t+e prescri(ed standards and naming conventions. -Ot+er t+an &eserved words.
,-; BC C%-&-CT/&S --A C-3 %5P%/. w+ic+ ma! not appear as first or last c+aracter
12
13
LIT/&-LS
-LP%-.*,/&IC - enclosed wit+in quotes ma#. 26C c+aracters long .*,/&IC - C-3 ?optional sign D decimal@ ma#. 27 digits "I'*&-TI0/ CO.ST-.T E A/&O8A/&OS8A/&O/S E F*OT/8F*OT/S E SP-C/8SP-C/S E %I'%-0-L*/8LO=-0-L*/8-LL
14
16
17
COL*,.S 7 - 22 -rea ivision names8 Section names8Paragrap+ names COL*,.S 2> - 9> -rea B COBOL code is written +ere COL*,.S 9B-7C Ignored (! compiler
1!
20
21
23
I /.TI"IC-TIO. I0ISIO.
P&O'&-,-I . P&O'&-,-.-,/. J-*T%O&. Comment entr!K JI.ST-LL-TIO.. Comment entr!K J -T/-=&ITT/.. Comment entr!K -T/-CO,PIL/ . Comment entr!K S/C*&IT5. Comment entr!K
24
/.0I&O.,/.T I0ISIO.
> S/CTIO.S CO."I'*&-TIO. S/CTIO. I.P*T-O*TP*T S/CTIO. CO."I'*&-TIO. S/CTIO. SO*&C/-CO,P*T/& OBL/CT-CO,P*T/&. SP/CI-L-.-,/S.
25
I.P*T-O*TP*T S/CTIO.
CO.SISTS O" > S/CTIO.S "IL/-CO.T&OL. .ames eac+ file 1 -ll files consisting of inputs8 outputs are to (e defined +ere. Identifies file medium I-O CO.T&OL. Specifies file location on multiple file reel s+ared memor! areas
26
I.P*T-O*TP*T S/CTIO.
"IL/-CO.T&OL.
S!nta#1 Select infil assign to infile. Logical "ile .ame 1 "ile name referred t+roug+out t+e program for open8 read8 write and close. ?infil@ P+!sical "ile .ame1 "ile name referred in LCL and S+ell Scripts to link to t+e logical file name in t+e program.?infile@
27
I.P*T-O*TP*T S/CTIO.
isk Storage
Select /,P"IL/ assign to " /,P"IL/. C2 /,P&/C. C4 /,P.O C4 /,P.-,/ C4 /,P /S'CO / C4 /,PB-SIC C4 /,PP&OL
/,P"IL/
Central Storage
/,P&/C ?&/CO& @
"ield "ield "ield "ield "ield
"IL/ CO.T&OL P-&S/L/CT logical file name -SSI'. TO ddname O&'-.IA-TIO. IS S/F*/.TI-L I. /;/ &/L-TI0/ -CC/SS IS S/F*/.TI-L &-. O, 5.-,IC &/CO& </5 IS data-name-2 -LT/&.-T/ </5 IS data-name-> "IL/ ST-T*S IS file-stat
2!
"IL/ CO.T&OL P-&Important points to note for inde#ed files1 2. If t+e organiMations is inde#ed and access is random- records can (e accessed randoml! and not sequentiall!. >. If t+e organiMation is inde#ed and access is d!namic - records can (e accessed randoml! as well as sequentiall!.
30
"IL/ CO.T&OL P-&"IL/-ST-T*S *sed to c+eck t+e following1 2. To c+eck t+e e#istence of a file w+ile open8 close. >. To c+eck t+e e#istence of a record. B. To c+eck t+e invalid ke!s
31
-T- I0ISIO.
"IL/ S/CTIO. =O&<I.'-STO&-'/ S/CTIO. LI.<-'/ S/CTIO.
32
-T- I0ISIO.
L/0/L ST&*CT*&/ In+erent in t+e logical record /ac+ (asic su(division is an elementar! item /lementar! items ma! form part of one or more groups Level num(ers 1 C2 - :3 1 66 99 77
33
-T- I0ISIO.
PICT*&/ CL-*S/
Picture clause is used to specif! t+e t!pe of field8 its siMe8 and its form. PIC used in Co(ol is t+e a((reviated form of PICT*&/. PIC or PICT*&/ is a reserved word. PIC or PICT*&/ can not (e used as a user defined data name. PIC is followed (! t!pe and lengt+ of field in (rackets
34
-T- I0ISIO.
PICT*&/ CL-*S/ Specified for ever! elementar! item .umeric ata item - 3 P S 0 ? @ -lp+a(etic data item - - B ? @ -lp+anumeric data item - ; ? @
35
PICT*&/ CL-*S/S
/;-,PL/S 1 3?:@033 N numeric value wit+ decimals. ;?>C@ N alp+anumeric values -?2C@ N alip+atic values S3?:@033 N signed field B?:@ N num(er of (lanks
36
"IL/ S/CTIO.
T+e rules for defining a file structure.
"ile description is denoted (! " followed (! t+e logical file name. &ecord name will +ave to (e at C2 level. T+e name defined at C2 level represents t+e entire record. T+e segments or fields of record are defined wit+ levels w+ic+ is greater t+an C2. ?In general it will (e multiples of 4.@ 0alues can not (e assigned to an! field in t+e file la! out. /#ception is 77 level w+ic+ is e#plained in t+e su(sequent PPT.
37
"IL/ S/CTIO.
/#ample for defining file la!out. " /,P,-S. C2 /,P&/C. C4 /,P-.O PIC 3?C6@. C4 /,P-.-,/. 2C "I&ST-.-,/ PIC ;?24@. 2C ,I L/-.-,/ PIC ;?>C@. 2C L-ST-.-,/ PIC ;?>C@. ?.aming standards are not followed +ere@
3
"IL/ S/CTIO.
" /.T&5 "O& /-C% "IL/ "OLLO=/ B5 &/CO& /SC&IPTIO. ?(egins in C2 level@ "ile record naming convention 1 e#1 ;..-TTTT-&/C ;.. 1 "irst B c+aracters of file name TTTT1 .ame of record ? 2 to >> c+aracters@ &/C 1 S+ould appear as it is O2-CO.T&OL-&/C PC3-P&I.T-&/C
3!
=O&<I.'-STO&-'/ S/CTIO.
Succeeds "ile Section *sed "or Intermediate Storage /.'.8
C2 =-,/,- /T-ILS.
2C =-,/,-- &-LI./2 PIC ;?BC@. 2C =-,/,-- &-LI./> PIC ;?BC@. Please see notes (elow.
40
0-L*/ CL-*S/
-ssigns Initial 0alue To - ata Item S!nta# 1 0alue Is literal literal can (e
.*,/&IC .O.-.*,/&IC I. F*OT/S "I'*&-TI0/ CO.ST-.T
/#amples1 C4 ws-(asic pic 3?C4@ value >CCCC. C4 ws-code pic #?C4@ value OC >CCCP. C4 ws-varia(le-pa! pic 3?C4@ value Mero.
41
/ ITI.' C%-&-CT/&S
.*,/&IC / ITI.' -T A A/&O S*PP&/SSIO. G 8 Q - R C& B P/&IO BL-.< 8 A/&O8 SL-S%8BL-.< =%/. A/&O -LP%-B/TIC BL-.< I.S/&TIO. -LP%-.*,/&IC BL-.<8 A/&O 8 SL-S% I.S/&TIO.
42
&/ /"I./S
T%IS CL-*S/ -LLO=S T%/ S-,/ -&/- O" ,/,O&5 TO B/ &/"/&/.C/ B5 ,O&/ T%-. O./ -T--.-,/ =IT% I""/&/.T "O&,-TS -. SIA/S. TL/0/LS T -T--.-,/-2S &/ /"I./S T -T--.-,/->S T%IS CL-*S/ ,*ST I,,/ I-T/L5 "OLLO= T -T--.-,/-2S L/0/L .OS O" T.-,/-2S -. T.-,/->S ,*ST B/ I /.TIC-L -. .OT 66 O& 77.
45
&/ /"I./S
-. /;-,PL/1 C2 -5S-I.-=//<. C4 -5-.-,/S PIC ;?>2@ 0-L*/ US*.,O.T*/...V. C4 =-.-,/S &/ /"I./S -5-.-,/S. 2C =- -5S PIC ;?B@ OCC*&S 9 TI,/S. T+e da!s can (e accessed as =- -5S?2@8=- -5S?>@8/TC.
46
&/ /"I./S
.OT/ 21 -T C2 L/0/L8 &/ /"I./S D OCC*&S C-..OT B/ CO,BI./ . .OT/ >1 O&I'I.-L -T- .-,/ -. &/ /"I./ I""/&/.T. -T- .-,/S S%O*L B/
.OT/ B1 .// TO B/ C-*TIO*S =%IC% .-,/ IS B/I.' *S/ I. P&OC/ *&/ I0ISIO.. .OT/ :1 &/,/,B/& T%-T BOT% =ILL %-0/ S-,/ 0-L*/ *.L/SS ./= 0-L*/S -&/ -SSI'./ B/"O&/ ,O0I.' TO OT%/& /.TIT5.
47
*S-'/ CL-*S/
"O&,S O" I.T/&.-L &/P&/S/.T-TIO. ISPL-5 CO,P CO,P2 CO,P> CO,PB S5.T-;1 *S-'/ IS ISPL-5 CO,P-2
4
50
LI.<-'/ S/CTIO.
&equires onl! w+en ot+er programs are called to perform specific functions. T+is section appears in called program. It is almost like performing some Para wit+ in a program Parameters are defined in called program under t+is section -ll parameters are defined at C2 level. /nsure t+at t+e program-id in called program is same as t+at of t+e program name called from main program.
51
LI.<-'/ S/CTIO.
/#ample1 working-storage section. ----linkage section C2 # pic 33. C2 ! pic 33. C2 M pic 33. .ote1 Please see C-LL ver( for furt+er details.
52
53
COBOL 0/&BS
CL-SSI"IC-TIO. I.P*T O*TP*T -&IT%,/TIC P&OC/ *&/ B&-.C%I.' -T- ,O0/,/.T /. I.' CO. ITIO.-L T-BL/ %-. LI.' CO,PIL/& I&/CTI.' ST&I.'-%-. LI.' OT%/&S
54
55
ISPL-5
*S/ TO ISPL-5 -T S5.T-; ISPL-5 identifier-1 literal-1 ,identifier2 ,literal2
56
-&IT%,/&IC 0/&BS
OP/&-TIO.S 1 S*BT&-CT ,*LTIPL5 I0I / CO,P*T/
57
- TO B - TO B &O*. /
0/&B
- CO&& '2 TO '> ?CO&& IS T%/ S%O&T "O&, O" CO&&/SPO. I.'@
5!
B&-.C%I.'
P/&"O&, 'O TO ?*nconditional (ranc+ing@ /;IT ?to e#it from a paragrap+@
60
P/&"O&,
P/&"O&, P-&--2 T%&* P-&--. P/&"O&, P-&--2 2C TI,/S P/&"O&, P-&--2 *.TIL C-"IL/-/. P/&"O&, P-&--2 0-&5I.' I "&O, 2 B5 2 *.TIL I S 2C -"T/& P-&--> "&O, 2 B5 2 *.TIL L S4
61
I.-LI./ P/&"O&,
To sum a series for eg.8 2Q>QBQ:Q4QI.Q.
,O0/ C TO S*,-O"- I'ITS ,O0/ 2 TO CO*.T/& P/&"O&, *.TIL CO*.T/& S .
/. -P/&"O&,.
62
P/&"O&,
P/&"O&, P&OC/SS- /T-IL =IT% T/ST -"T/& *.TIL C-"IL/-/. P/&"O&, P&OC/SS- /T-IL =IT% T/ST B/"O&/ *.TIL C-"IL/-/.
63
-T- T&-.S"/&
ata transfer in Co(ol is done using O,O0/P ver( t+oug+ values in sending field remain unaffected. &eceiving field s+ould not (e smaller t+an sending field to avoid truncation. ,ove of -lip+atic or alp+anumeric value is left )ustified. ,ove of .umeric values is rig+t )ustified.
64
65
ALPHABETIC ALPHANUMERIC ALPHANUMERIC EDITED NUMERIC INTEGER NUMERIC NONINTEGER NUMERIC EDITED
NO NO YES YES NO
/. I.'
STOP &*. &/T*&.S CO.T&OLTO OP/&-TI.' S5ST/, STOP lit-1 T/,PO&-&IL5 %-LTS - P&O'&-, /;IT P&O'&-, &/T*&.S "&O, - S*B P&O'&-, TO - ,-I. P&O'&-,
67
A/&O
6!
70
71
OCC*&S S5.T-;
"O&,-T-2 OCC*&S integer-2 TI,/S W-SC/. I.'$ /SC/. I.'X </5 IS data-name-1 [data-name-2] JI. /;/ B5 index-name-1 [,index-name-2] .. "O&,-T-> OCC*&S integer-1 to integer-2 TI,/S /P/. I.' O. data-name-1 W-SC/. I.'$ /SC/. I.'X </5 IS [data-name-2] JI. /;/ B5 index-name-1 [,index-name-2] ..
72
I. /;
I. /; IS - ST-C< 0-&I-BL/ ,*ST B/ I.ITI-LIS/ B/"O&/ IT C-. B/ *S/ - B5 *SI.' S/T 0/&B /'.8 S/T I. /;-2 TO 4 S/T I. /;-2 *P B5 2 S/T I. /;-2 O=. B5 2
73
S/-&C%
To searc+ a ta(le element Two searc+ options S/-&C% 0-&5I.' S/-&C% -LL - ma! (e carried out of sorted ta(les.
74
S/-&C%
S/-&C% id-2 0-&5I.' Winde#-2$ id->X -T /. statement-2 =%/. Condition-2 stmt-> S/-&C% -LL id-2 -T /. stmt-2 =%/. Condition-2 ./;T S/.T/.C/
75
S/-&C%
99 .-,/ C2 S-0/-B.<--CCT. PIC ;?>C@
C4 -CCT-TBL OCC*&S :CC TI,/S I. /;/ B5 -2. 2C -CCT-.O PIC 3?6@ 2C -CCT-.-,/ PIC ;?>C@ 2C -CCT--,T PIC 3?6@033. S/T -2 TO 2. S/-&C% -CCT-TBL -T /. ISPL-5 U.OT "O*. V =%/. .-,/N-CCT-.-,/?-2@ ISPL-5 U.-,/ "O*. V ISPL-5 -CCT-.O U U -CCT--,T.
76
S/-&C% -LL
C2 /,P-T-BL/. C4 /-.-,/-.O OCC*&S :C TI,/S -SC/. I.' </5 IS /-.-,/ I. /;/ B5 I. ;-2. 2C /-.-,/ PIC ;?2C@. 2C /-.O PIC 3?2C@. S/-&C% -LL /-.-,/-.O -T /. P/&"O&, .O-"I. -P-&=%/. /-.-,/?I. ;-2@N/,PL-.-,/ ,O0/ /-.O?I. ;-2@ TO /,PL-.O. .OT/1 T-BL/ %-S TO B/ SO&T/ O. /-.-,/.
77
CO,PIL/& I&/CTI.'
COP5 0/&B S5.T-; 1 COP5 U"IL/V
In !t"O!t !t #ro$e%%ing
7!
"IL/ I-Os
OP/. CLOS/ &/ =&IT/ &/=&IT/ /L/T/ ST-&T
OP/.
,O /S O" OP/. I.P*T O*TP*T I-O /;T/.
OP/.
,O /S O" OP/. =+en files are opened in input mode8 records can onl! (e read =+en files are opened in output mode8 records can onl! (e written =+en files are opened in input-output ?I-O@ mode8 records can read and write =+en files are opened in /#tend mode8 records can onl! (e appended to t+e e#isting file
SEQUENTIAL
INPUT, I/O
INDEXED
INPUT,I/O
WRITE
OUTPUT,EXTEND
I/O,OUTPUT
REWRITE
I/O
I/O
&/ "O&,-T-2 &/- file-name -T /. imperative statement "O&,-T-> &/- file-name I.0-LI </5 imperative statement "O&,-T-B &/- file-name ./;T &/CO& I.TO identifier -T /. imperative statement
&/ "O&,-T-2 &/- EMPFILE -T /. M !E "#$ % E F. E F to &e defined in 'or(ing-storage se)tion assigning val*e "+$. -T /. clause is determined (! t+e s!stem and 5 is moved to /O" and no furt+er process takes place.
&/ "O&,-T-2 &/- EMPFILE -T /. M !E "#$ % E F. E F to &e defined in 'or(ing-storage se)tion assigning val*e "+$. "O&,-T-> &/- EMPM,- I.0-LI </5 . % P,/,-E0I% "O&,-T-B &/- file-name ./;T &/CO& I.TO identifier -T /. imperative statement
=&IT/
"O&,-T-2 =&IT/ re)ord-name J"&O, id-1K WB/"O&/$-"T/&X - 0-.CI.' Wint-28 LI./8P-'/X "O&,-T-> =&IT/ re)ord-name I.0-LI </5 imperative-statement
&/=&IT/
&/=&IT/ re)ord-name I.0-LI </5 imperative statement
/L/T/
/L/T/ file-name &/CO& I.0-LI </5 imperative statement +ote 11 2ELE%E )an not &e *sed for a se3*ential file. +ote 21 2ELE%E is *sed for Indexed files onl4 '5en t5e file is opened in I- mode.
!0
ST-&T
/.-BL/S POSITIO.I.' O" POI.T/& -T - SP/CI"I/ POI.T I. -. I. /;/ "IL/ "IL/ S%O*L B/ OP/./ I. I.P*T O& I-O ,O / -CC/SS S%O*L B/ S/F*/.TI-L O& 5.-,IC ST-&T O/S .OT &/- T%/ &/CO&
!1
!2
I.SP/CT Icontd
,5-ST&I.' ;?>C@ C%-. &- B-B* .-I * T-LL5-CO*.T 3?>@ 0-L*/ C7 I.SP/CT ,5-ST&I.' T-LL5I.' T-LL5-CO*.T "O& -LL U-V. 2> I.SP/CT ,5-ST&I.' T-LL5I.' T-LL5-CO*.T "O& L/- I.' UCV C3 I.SP/CT ,5-ST&I.' T-LL5I.' T-LL5-CO*.T "O& -LL U-. V B/"O&/ I.ITI-L U&V -"T/& I.ITI-L U%V. C3 I.SP/CT FT5 &/PL-CI.' L/- I.' SP-C/S B5 A/&OS I.SP/CT 5 T-LL5I.' C.T "O& -LL ULV &/PL-CI.' L/- I.' U-V B5 U/V -"T/& I.ITI-L ULV 5?B/"O&/@ L-TT/& 5?-"T/&@ L/TT/& C.T 2
!3
ST&I.'
C2 .-,/. C4 "-.-,/ PIC ;?2C@. C4 ,-.-,/ PIC ;?2C@. C4 S-.-,/ PIC ;?>C@. C2 O*T-&/C PIC ;?6C@. C2 PIC ; 0-L*/ SP-C/S. ST&I.' S-.-,/ /LI,IT/ B5 SP-C/S - /LI,IT/ B5 SIA/ "-.-,/ /LI,IT/ B5 SP-C/S - /LI,IT/ B5 SIA/ ,-.-,/ /LI,IT/ B5 SP-C/S I.TO O*T-&/C.
!4
*.ST&I.'
C2 "I/L -2 PIC ;?24@. C2 "I/L -> PIC ;?24@. C2 "I/L -B PIC ;?24@. C2 C,P-.-,/ PIC ;?>4@ 0-L*/ IS UT-T- CO.S*LT-.C5 S/&0IC/SV. *.ST&I.' C,P-.-,/ /LI,IT/ B5 U U I.TO "I/L -2 "I/L -> "I/L -B. "I/L CO.T/.TS "I/L -2 T-T"I/L -> CO.S*LT-.C5 "I/L -B S/&0IC/S
!5
OT%/& 0/&BS
SO&T &/L/-S/ &/T*&. C-LL I" -. ./ST/ I" /0-L*-T/
!6
SO&T 0/&B
S5.T-;
SO&T SO&T-"IL/ W-SC/. I.'$ /SC/. I.'X </5 data-name-1 J*SI.' inp*t-file$I.P*T P&OC/ *&/ IS se)tion-1 t5r* se)tion-2] J'I0I.' o*tp*t-file$O*TP*T P&OC/ *&/ IS se)tion-6 t5r* se)tion-7]
!7
&/L/-S/
Transfers records to t+e initial p+ase of a sort operation &/CO& .-,/ ,*ST B/ -. S /.T&5 ,-5 .OT B/ *S/ O*TSI / -. I.P*T P&OC/ *&/ O.L5 &/L/-S/ &/CO& S -&/ SO&T/ S5.T-; &/L/-S/ re)ord-name J"&O, identifierK
&/T*&.
O(tains sorted records from t+e final p+ase of sort /#ecution causes t+e ne#t record to (e made availa(le S5.T-; &/T*&. file-name &/CO& JI.TO identifier K -T /. imperative statement
!!
C-LL
S5.T-; C-LL Wid-2$lit-2X J*SI.' data-name-2 J8data-name->KIK J ZO. O0/&"LO= imp-stmtK P&OC/ *&/ I0ISIO. J*SI.' data-name-2 J8data-name->KIK LI.<-'/ S/CTIO. C2 level entries /;IT P&O'&-,
100
C-LL
Calling Program1
I /.TI"IC-TIO. I0ISIO.. P&O'&-,-I . T&.'2. -----------------------------------------------------------T- I0ISIO.. ---C2 PIC 33. C2 B PIC 33. C2 --PL*S-B PIC 333. C2 ST-T*S-CO / PIC ;?:@. ---P&OC/ *&/ I0ISIO.. CALL &TRNG'( USING A) B) A-#LUS-B) STATUS-CODE* I" ST-T*S-CO / N OO.<P P/&"O&, --P-&/LS/ P/&"O&, B-P-&/. -I".
101
C-LL
Called Program1
I /.TI"IC-TIO. I0ISIO.. P&O'&-,-I . T&.'>. -----------------------------------------------------------T- I0ISIO.. ---LI.<-'/ S/CTIO. C2 PIC 33. C2 B PIC 33. C2 --PL*S-B PIC 333. C2 ST-T*S-CO / PIC ;?:@. P&OC/ *&/ I0ISIO. USING A) B) A-#LUS-B) STATUS-CODE* CO,P*T/-P-&-. I" - IS .*,/&IC -. B IS .*,/&IC CO,P*T/ --PL*S-B N - Q B ,O0/ OO.<P TO ST-T*S-CO / /LS/ ,O0/ SP-C/S TO ST-T*S-CO / /. -I". C-LL-/. -P-&-. /;IT P&O'&-,.
102
I" -. /LS/
T+e most important ver( in an! language. *sed for conditional c+ecks /#ample1 if designation-code S C6 perform process-para2 t+ru process-para2-e#it else perform process-para> t+ru process-para>-e#it end-if
103
I" -. /LS/
.ote21 /ver! I+ e#pression ma! +ave e,%e to provide alternate action for false condition. .ote>1 Period at t+e end of statement containing OifP passes t+e control to t+e ne#t statement after period.? see notes@ .oteB1 /nd-if ?scope terminator@ at t+e end of statement nullifies current if statement.
104
Conditional statement-flow
false true
condition
Statement-2
Statement-1
Next sentence
105
./ST/ I"
Points to .ote1 Com(ination of several OI" and /LS/P statements. *sed for c+ecking several conditions to pass t+e control to respective modules. *sed for (ranc+ing complicated calculations. "irst /LS/ pertains to t+e preceding if and ne#t else pertains to t+e I" )ust preceding t+e inner I".
106
./ST/ I"
I"---I"---I"---/LS/---/LS/---/LS/---
107
/0-L*-T/
T+is ver( is added in t+e modified Co(ol version 74. &eplace I" wit+ /0-L*-T/ to avoid complications of ./ST/ I" /. -/0-L*-T/ is t+e scope terminator. Powerful and fast as compared to I".
10
/0-L*-T/
/#ample 21 /0-L*-T/ /S'-CO / =%/. C2 P/&"O&, C2-P-&=%/. C> P/&"O&, C>-P-&=%/. CB P/&"O&, CB-P-&=%/. OT%/& P/&"O&, /&&O&-P-&/. -/0-L*-T/
10!
/0-L*-T/
/#ample >1 /0-L*-T/ T&*/ =%/. C2-- P/&"O&, C2-P-&=%/. C>-- P/&"O&, C>-P-&=%/. CB-- P/&"O&, CB-P-&=%/. OT%/& P/&"O&, /&&O&-P-&/. --0-L*-T/ .ote1 C2-- 8 C>-- and CB-- are 77 level condition names.
110
/0-L*-T/
/#ample B1 /0-L*-T/ /S'-CO / -. B-SIC-P-5 =%/. C2 T%&* CB -LSO 2CCCC T%&* 24CCC P/&"O&, C2CB-P-&=%/. C: T%&* C6 -LSO 24CC2 T%&* >CCCC P/&"O&, C:C6-P-&=%/. OT%/& P/&"O&, /&&O&-P-&/. --0-L*-T/
111
&/PO&T '/./&-TIO.
&equirements 2. input data. >. formatting t+e report. Input is +owever o(tained from input files. "ormatting a print report in Co(ol needs special attention.
112
&/PO&T '/./&-TIO.
CentraliMe %eadings on 7C columnar stationar! C2 +eading-2. C4 filler pic #?>4@ value spaces. C4 filler pic #?>4@ value OTraining Co(ol Batc+ .o 1 O. C4 (atc+-no pic M?C:@(. spacing (etween two data items need to (e defined wit+ num(er of fillers required.
113
Summar!
Introduction to COBOL "eatures Coding "ormat D Programming S!nta# Programming ivisions "ile processing
114
&eferences
OCOBOL *nleas+edP (! Lon =essler and et.al8 ,acmillan$Pearson Tec+nolog! COBOL (ooks and courses in Skillport ?+ttp1$$tcs.skillport.com@ OStructured COBOL ProgrammingP (! Stern D Stern8 Lo+n =ile!8 .ew 5ork OCOBOL Programming including ,S COBOL D COBOL 74P (! &o! D as+tidar8 II edition8 Tata ,c'raw-%ill
115