You are on page 1of 24

Student Notebook

UNIT 2

The Organization of a COBOL Program

Unit 2. The Organization of a COBOL Program

2.1

Student Notebook

IDENTIFIC TION DI!ISION

IDENTIFICATION DI I!ION. P+O,+A--ID. .Pgm-name/ AUT0O+. .Pgmr-name/ DATE 12+ITTEN. .Entr'/ DATE-CO-PILED. .Entr'/ !ECU+IT3. .Entr'/

+e4uire" +e4uire" O(tiona) O(tiona) O(tiona) O(tiona)

At )ea%t one %(a#e re4uire" after the (erio"


Figure 2-1 IDENTIFICATION DI I!ION

Note"# The I"entifi#ation Di$i%ion mu%t &e the fir%t "i$i%ion in e$er' COBOL %our#e (rogram. It mu%t &e #o"e" a% IDENTIFICATION DI I!ION or ID DI I!ION fo))o*e" &' a %e(arator (erio".

EN!I$ON%ENT DI!ISION

Unit 2. The Organization of a COBOL Program

2.2

Student Notebook

EN I+ON-ENT DI I!ION. CONFI,U+ATION !ECTION. !OU+CE-CO-PUTE+. .Entr'/. OB5ECT-CO-PUTE+. .Entr'/. INPUT-OUTPUT !ECTION. FILE-CONT+OL. ------------------------------------------------------I-O-CONT+OL. ---------------------------------------------------------

Figure 2-2

EN I+ON-ENT DI I!ION

Note"# The En$ironment Di$i%ion i% "i$i"e" into t*o %e#tion%6 The CONFI&U$ TION SECTION The Configuration !e#tion i% an o(tiona) %e#tion for (rogram% *hi#h "e%#ri&e the #om(uter en$ironment on *hi#h the (rogram i% #om(i)e" an" e7e#ute". The Configuration !e#tion #an &e %(e#ifie" on)' in the EN I+ON-ENT DI I!ION of the outermo%t (rogram of a COBOL %our#e (rogram. The INPUT'OUTPUT SECTION The In(ut-Out(ut !e#tion of the En$ironment Di$i%ion #ontain% t*o (aragra(h%6 FILE-CONT+OL (aragra(h I-O-CONT+OL (aragra(h

FILE'CONT$OL (aragra(h The 8e'*or" FILE-CONT+OL #an a((ear on)' on#e9 at the &eginning of the FILECONT+OL (aragra(h. It mu%t &egin in Area A9 an" &e fo))o*e" &' a %e(arator (erio". The FILE-CONT+OL (aragra(h i% o(tiona).
Unit 2. The Organization of a COBOL Program
2.:

Student Notebook

The FILE-CONT+OL (aragra(h a%%o#iate% ea#h fi)e in the COBOL (rogram *ith an e7terna) "ata %et9 an" %(e#ifie% fi)e organization9 a##e%% mo"e9 an" other information. There are three format% for the FILE-CONT+OL (aragra(h6 ; <!A-9 !A-9 an" !A- %e4uentia) fi)e entrie% ; !A- in"e7e" fi)e entrie% ; !A- re)ati$e fi)e entrie%. The FILE-CONT+OL (aragra(h &egin% *ith the *or" =FILE-CONT+OL=9 fo))o*e" &' a %e(arator (erio". It mu%t #ontain one an" on)' one entr' for ea#h fi)e "e%#ri&e" in an FD or !D entr' in the Data Di$i%ion. 2ithin ea#h entr'9 the !ELECT #)au%e mu%t a((ear fir%t9 fo))o*e" &' the A!!I,N #)au%e. The other #)au%e% #an a((ear in an' or"er.

I'O'CONT$OL (aragra(h

!(e#ifie% information nee"e" for effi#ient tran%mi%%ion of "ata &et*een the e7terna) "ata %et an" the COBOL (rogram. The %erie% of entrie% mu%t en" *ith a %e(arator (erio" The 8e'*or" I-O-CONT+OL #an a((ear on)' on#e9 at the &eginning of the (aragra(h. The *or" I-O-CONT+OL mu%t &egin in Area A9 an" mu%t &e fo))o*e" &' a %e(arator (erio". Ea#h #)au%e *ithin the (aragra(h #an &e %e(arate" from the ne7t &' a %e(arator #omma or a %e(arator %emi#o)on. The or"er in *hi#h I-O-CONT+OL (aragra(h #)au%e% are *ritten i% not %ignifi#ant

D T DI!ISION
Data "i$i%ion i% the thir" an" mo%t fre4uent)' u%e" "i$i%ion in a)) (rogram%. E$er' $aria&)e re4uire" &' the (rogram %hou)" &e "e#)are" in a((ro(riate %e#tion of the "ata "i$i%ion9 &efore u%ing in (ro#e"ure "i$i%ion
Unit 2. The Organization of a COBOL Program
2.>

Student Notebook

The Data Di$i%ion i% "i$i"e" into three %e#tion%6

Fi)e !e#tion Define% the %tru#ture of "ata fi)e% ?in#)u"ing %ort-merge fi)e%@. 2or8ing-!torage !e#tion De%#ri&e% re#or"% an" %u&or"inate "ata item% that are not (art of "ata fi)e% &ut are re4uire" &' the (rogram.

Lin8age !e#tion De%#ri&e% "ata ma"e a$ai)a&)e &' another (rogram. It u%ua))' a((ear% in the #a))e" (rogram an" "e%#ri&e% "ata item% that are referre" to &' the #a))ing an" the #a))e" (rogram%.

Ea#h %e#tion ha% a %(e#ifi# )ogi#a) fun#tion *ithin a COBOL %our#e (rogram9 an" ea#h #an &e omitte" from the %our#e (rogram *hen that )ogi#a) fun#tion i% not nee"e". If in#)u"e"9 the %e#tion% mu%t &e *ritten in the or"er %ho*n.

DATA DI I!ION. FILE !ECTION. FD . --------------------------------------------2O+AIN,-!TO+A,E !ECTION. B1 A+-1 PIC A?C@. B1 ID-1 PIC D?1B@ DATA T3PE! -A)(ha&eti# -A)(hanumeri#
2.C

Unit 2. The Organization of a COBOL Program

Student Notebook

B1 DATA-NA-E Le$e) num&er

PIC

E?C@

-Numeri#

(i#ture C)au%e LINAA,E !ECTION. re#or"-"e%#ri(tion-entr' "ata-item-"e%#ri(tion-entr'

"ata t'(e ?)ength@

Figure 2-:

DATA DI I!ION

Note"#

D T 'ITE%S
E)(*i+it*, identifie" the data being de"+ribed The data'item mu"t be the fir"t -ord fo**o-ing the *e.e*'number/ The data'item .a*ue" +an be +hanged during (rogram e)e+ution/ data'item name +annot be the "ame a" a "e+tion'name or a (aragra(h name
Unit 2. The Organization of a COBOL Program
2.F

Student Notebook

Figure 2->

DATA-ITE-!

Note"# Data item i% a u%er-"efine" *or" *hi#h i% a%%o#iate" *ith Le$e) num&er. COBOL +e%er$e" *or"% %hou)" not &e Data item%.

Le.e* Number"
$ange of *e.e* number" a.ai*ab*e are 01 to 23 and 44 *e.e* "(e+ified for $EN %IN& CL USE 55 *e.e*" "(e+ified e)+*u"i.e*, for e*ementar, item" 66 *e.e*" "(e+ified for CONDITION N %ES/ n e*ementar, item +an be de+*ared -ith *e.e* number" 01 and 55 and other *e.e* entrie" +an
2.G

01 and 55 *e.e* entrie" mu"t begin from area begin from an, -here in area or area B
Unit 2. The Organization of a COBOL Program

Student Notebook

Figure 2-C

Le$e) Num&er%

Note"# Le$e) re(re%ent% the nature of a "ata item. The )e$e)-num&er %(e#ifie% the hierar#h' of "ata *ithin a re#or"9 an" i"entifie% %(e#ia)-(ur(o%e "ata entrie%. A )e$e)-num&er &egin% a "ata "e%#ri(tion entr'9 a rename" or re"efine" item9 or a #on"ition-name entr'. A )e$e)-num&er ha% a $a)ue ta8en from the %et of integer% &et*een B1 an" >E9 or from one of the %(e#ia) )e$e)num&er%9 FF9 GG9 or HH.

Le$e)-num&er B1 an" GG mu%t &egin in Area A an" mu%t &e fo))o*e" either &' a %e(arator (erio"I or &' a %(a#e9 fo))o*e" &' it% a%%o#iate" "ata-name9 FILLE+9 or a((ro(riate "ata "e%#ri(tion #)au%e.

Le$e) num&er% B2 through >E #an &egin in Area% A or B an" mu%t &e fo))o*e" &' a %(a#e or a %e(arator (erio". Le$e) num&er FF an" HH #an &egin in Area% A or B an" mu%t &e fo))o*e" &' a %(a#e. !ing)e-"igit )e$e)-num&er% 1 through E #an &e %u&%titute" for )e$e)-num&er% B1 through BE. !u##e%%i$e "ata "e%#ri(tion entrie% #an %tart in the %ame #o)umn a% the fir%t or the' #an &e in"ente" a##or"ing to the )e$e)-num&er. In"entation "oe% not affe#t the magnitu"e of a )e$e)-num&er.
Unit 2. The Organization of a COBOL Program
2.H

Student Notebook

2hen )e$e)-num&er% are in"ente"9 ea#h ne* )e$e)-num&er #an &egin an' num&er of %(a#e% to the right of Area A. The e7ten" of in"entation to the right i% )imite" on)' &' the *i"th of Area B. 0igher num&ere" )e$e)?%@ re(re%ent %u&or"inate "efinition?%@. Le$e) num&er% nee" not &e #on%e#uti$e?&ut %hou)" &e in a%#en"ing or"er@

S(e+ia* Le.e* Number"

LE!EL'44 +ontain" a $EN %ES +*au"e/ It regrou(" (re.iou"*, defined name" LE!EL'55 define" ELE%ENT $7 item" -ith no "ubdi.i"ion and are uni8ue LE!EL'66 e"tab*i"he" +ondition'name entrie"9 a""o+iated -ith a ! LUE +*au"e

FF "ata-name-1 rename%-#)au%e. HH #on"ition-name-1 $a)ue-#)au%e.


Unit 2. The Organization of a COBOL Program

2.E

Student Notebook

Figure 2-F

!(e#ia) Le$e) Num&er%

Note"# LE!EL'44 regrou(% (re$iou%)' "efine" item%. A )e$e)-FF entr' #annot rename another )e$e)-FF entr'9 nor #an it rename a )e$e)-B19 )e$e)-GG9 or )e$e)-HH entr'. A)) )e$e)-FF entrie% a%%o#iate" *ith one re#or" mu%t imme"iate)' fo))o* the )a%t "ata "e%#ri(tion entr' in that re#or". LE!EL'55 item% are ELE-ENATA+3 item% *ith no %u&"i$i%ion. LE EL-GG name% are uni4ue &e#au%e the' #an not &e 4ua)ifie". LE!EL'66 "e%#ri&e% #on"ition-name%. LE EL-HH #an &e u%e" to "e%#ri&e &oth e)ementar' an" grou( item%.

Pi+ture C*au"e
De"+ribe" the +hara+teri"ti+" of the data CODE A B , or N D P meaning a)(ha&eti# or %(a#e B)an8% or %(a#e% ,ra(hi#a) "ata In"i#ate% a Numeri# In"i#ate% an A)(ha Numeri# In"i#ate% the (o%ition of the a%%ume" "e#ima) (oint *hen the (oint )ie% out%i"e the "ata item. In"i#ate% the (o%ition of a%%ume" "e#ima) (oint of numeri# fie)". In"i#ate% *hether the "ata item %igne".

Unit 2. The Organization of a COBOL Program

2.1B

Student Notebook

Figure 2-E

Pi#ture C)au%e

Note"# Pi#ture #)au%e %(e#ifie% the "ata t'(e of an i"entifier. I"entifier *ith PIC #)au%e JEK im()ie% that it i% numeri+ data t,(e9 *hi#h #an ta8e art in arithmeti# #om(utation%. J K an" J!K #)au%e% are a))o*e" *ith numeri# "ata t'(e% on)'. JDK #)au%e re(re%ent% an a*(hanumeri+ data t,(e *hi#h #an ho)" an' #hara#ter in#)u"ing num&er% a)%o. JAK #)au%e in"i#ate% an a*(habeti+ data t,(e. ,rou( item% are a)*a'% #on%i"ere" a% a)(hanumeri# on)'. Therefore ,+O!!-PA39 DEDUCTION! #an not &e u%e" for #om(utation%.

:'S De+*aration"
2OAIN,-!TO+A,E !ECTION. B1 PA3. BC ,+O!!-PA3. 1B BA!IC PIC E?>@ EE. 1B DA PIC E?>@ EE. 1B 0+A PIC E?>@ EE BC DEDUCTION!. BG PF-DED PIC BG IT-DED PIC BC NET-PA3 PIC BC NA-E PIC BC E-CODE PIC E?:@ EE. E?:@ EE. E?>@ EE. A?C@. D?F@. A)ternati$e)' E?>@ E?2@ EEEE EE

AAAAA DDDDDD

Unit 2. The Organization of a COBOL Program

2.11

Student Notebook

Figure 2-G

2-! De#)aration%

Note"# Pa'9 gro%%-(a'9 "e"u#tion% are #a))e" grou( item% an" the' "onKt ha$e PICTU+E #)au%e. Other e)ement% *ith (i#ture #)au%e are #a))e" e)ementar' item%9 *hi#h #annot &e &ro8en further. Pa' i% a ,rou( item i% "i$i"e" into ,ro%%-(a'9 De"u#tion%9 net-(a'9 name9 e-#o"e further ,ro%%-(a' %u&-"i$i"e" into Ba%i#9 DA9 0+A an" DEDUCTION! %u&"i$i"e" into PF-DED an" IT-DED.

FILLE$
FILLE$ i" a COBOL $e"er.ed :ord u"ed to de"+ribe data fie*d" that -i** not be referen+ed in the P$OCEDU$E DI!ISION/ If the data'name of FILLE$ +*au"e i" omitted9 the data item being de"+ribed i" treated a" though it -a" FILLE$ B1 E-PLO3EE-+ECO+D. BC E-PLO3EE-T3PE BC E-PLO3EE-!E+IAL BC E-PLO3EE-NA-E C BC E-PLO3EE-ADD+E!! BC FILLE+ PIC D. PIC D?F@. PIC D?:B@. PIC D?2@. PIC D?FB@. PIC D?:>@.

Figure 2-H

FILLE+

Note"#

Unit 2. The Organization of a COBOL Program

2.12

Student Notebook

FILLE+ i% a "ata item that i% not e7()i#it)' referre" to in a (rogram. The 8e' *or" FILLE+ i% o(tiona). If %(e#ifie"9 FILLE+ mu%t &e the fir%t *or" fo))o*ing the )e$e)num&er. IF "ata-name or FILLE+ #)au%e i% omitte"9 the "ata item &eing "e%#ri&e" i% treate" a% though FILLE+ ha" &een %(e#ifie". The ALUE #)au%e ma' &e u%e" on FILLE+ item%9 e.g. to a%%ure BLANA! in hea"er )ine% &et*een fie)"%. In a -O E CO++E!PONDIN, %tatement 9or in an ADD CO++E!PONDIN, or !UBT+ACT CO++E!PONDIN, %tatement 9FILLE+ item% are ignore". In an INITIALILE %tatement9 e)ementar' FILLE+ item% are ignore".

US &E C*au"e
;*e.e* number< data'name =PIC >?n@A =US &EA CO%P CO%P'1 CO%P'2 CO%P'B

CO%P CO%P'1 CO%P'2 CO%P'B

' ' ' '

Binar, $e(re"entation Size# Ca*fDFu**DDoub*e -ord Ce)a De+ima* $e(re"entation Size# Fu** -ord for F*oat Ce)a De+ima* $e(re"entation Size# Doub*e -ord for F*oat Pa+ked De+ima* $e(re"entation Size# :here n i" number of digit"/ round?nD2@E1

Unit 2. The Organization of a COBOL Program

2.1:

Student Notebook Figure 2-1B U!A,E C)au%e

Note"# The U!A,E #)au%e #an &e %(e#ifie" for a "ata "e%#ri(tion entr' *ith a )e$e)-num&er other than FF or HH. 0o*e$er9 if it i% %(e#ifie" at the grou( )e$e)9 it a(()ie% to ea#h E)ementar' item in the grou(. The u%age of an e)ementar' item mu%t not #ontra"i#t the u%age of a grou( to *hi#h the e)ementar' item &e)ong%. The U!A,E #)au%e %(e#ifie% the format in *hi#h "ata i% re(re%ente" in %torage. The format #an &e re%tri#te" if #ertain Pro#e"ure Di$i%ion %tatement% are u%e". 2hen the U!A,E #)au%e i% not %(e#ifie" at either the grou( or e)ementar' )e$e)9 it a%%ume" that the u%age i% DI!PLA3.

Com(utationa* ? CO%P@ U"age


2hen u%age i% %(e#ifie" a% CO-P9 the numeri# "ata item i% re(re%ente" in (ure &inar'. The item mu%t &e an integer? no a%%ume" "e#ima) (oint i% a))o*e"@. !u#h that "ata item% are often u%e" a% %u&%#ri(t%.The PICTU+E of a CO-P item %hou)" not #ontain an' #hara#ter other than E9 !. CO%PUT TION L'1 ?CO%P'1@ U"age If the u%age of a numeri# "ata item i% %(e#ifie" a% CO-P-19 it *i)) &e re(re%ente" in one *or" in the f)oating 1(oint form. The num&er i% a#tua))' re(re%ente" in 0e7a "e#ima) ?&a%e 1F@. !u#h re(re%entation i% %uita&)e for arithmeti# o(eration%. The PICTU+E #)au%e #annot &e %(e#ifie" for CO-P-1 item%. CO%PUT TION L'2?CO%P'2@U"age Thi% u%age i% %ame a% CO-P-19 e7#e(t that the "ata i% re(re%ente" interna))' in t*o *or"%. The a"$antage% i% that thi% in#rea%e% the (re#i%ion of the "ata *hi#h mean% that more %ignifi#ant "igit% #an &e a$ai)a&)e for the item. The PICTU+E #)au%e #annot &e %(e#ifie" for CO-P-2 item%. CO%PUT TION L'B?CO%P'B@U"age In thi% form of interna) re(re%entation the numeri# "ata i% the "e#ima) form9 &ut one "igit ta8e% ha)f-a-&'te. The %ign i% %tore" %e(arate)' a% the right mo%t ha)f 1a-&'te
Unit 2. The Organization of a COBOL Program
2.1>

Student Notebook

regar")e%% of *hether ! i% %(e#ifie" in the PICTU+E or not. The he7a "e#ima) num&er C or F "enote% a (o%iti$e %ign an" the 0e7a 1"e#ima) num&er D "enote% a negati$e %ign. Inor"er that "ata fie)"% #an %tart an" en" on &'te &oun"arie%9 num&er% *ith an e$en num&er of "igit% are %tore" *ith an e7tra ha)f-&'te of zeroe% on the )eft han" %i"e. Thu% an item *ith PICTU$E S3?F@!3?B@ US &E IS CO%P'B *i)) re4uire C &'te% to &e %tore" interna))'. On)' the #hara#ter% E9!9 u%e" in the PICTU+E of a CO-P-: item. an" P #an &e

!a*ue C*au"e
!a*ue C*au"e define" the initia* .a*ue of a data item %u"t not be u"ed for item" de+*ared in FILE SECTION/ Can a*"o "(e+if, FI&U$ TI!E CONST NTS/ If defined at the grou( *e.e* +an be u"ed for arra, de+*aration a*"o EDA-PLE!. B1 NU--1 PIC E?:@ B1 E-CODE PIC D?F@ At grou( )e$e) B1 ,+OUP-ITEBC E-ITE--1 BC E-ITE--2 BC E-ITE--: ALUE I! JE+:>1CCK PIC D?2@. PIC DDD PIC D?:@ ALUE 2>C. ALUE ME1BA:N. #ontent% JE+K J:>1K JCCK

&rou( item i" +on"idered a" a*(hanumeri+/

Figure 2-11

ALUE C)au%e

Unit 2. The Organization of a COBOL Program

2.1C

Student Notebook

Note"# A%%igning $a)ue% to i"entifier% i% #a))e" initia)ization. If $aria&)e% are not initia)ize"9 then the' ma' #ontain an' $a)ue9 *hi#h *a% %tore" at the time of )a%t e7e#ution of (rogram. It i% a"$i%e" to a)*a'% initia)ize *or8ing-%torage $aria&)e%.

$EDEFINES C*au"e
T*o or more "ata item% #an %hare the %ame *or8ing %torage area &' $EDEFININ& a %torage area. Le.e* number "ata name-1 +EDEFINE! "ata-name-2 Le$e) num&er% of "ata-name-1 an" "ata-name-2 mu%t &e i"enti#a) The re"efine% #)au%e mu%t imme"iate)' fo))o* "ata-name-I mu%t not &e u%e" for )e$e) num&er FF or HH item%. Data-name-1 %hou)" not #ontain ALUE #)au%e -u)ti()e re"efinition i% a))o*e"

Figure 2-12 +EDEFINE! C)au%e

Note"# T*o or more %torage area% "efine" in the "ata %ometime% ma' not &e u%e" %imu)taneou%)'9 in %u#h #a%e%9 on)' one %torage area #an %er$e the (ur(o%e of t*o or more area% if the area i% "efine". The +EDEFINE! #)au%e u%e" a))o*% the %ai" area to &e referre" to &' more than one "ata name *ith "ifferent %ize% an" (i#ture%.

ILLUST$ TES $EDEFINES CL USE


Unit 2. The Organization of a COBOL Program
2.1F

Student Notebook

DATA DI I!ION. 2O+AIN,-!TO+A,E !ECTION. B1 B1 D1 B2 B2 D: B2 B2 B2 D> B2 B2 DC B2 3 31 PIC EE. +EDEFINE! 3

PIC

DD.

B1 B1

L PIC D LL PIC D ?2C@ LLL PIC D ?>C@ +EDEFINE! D:. FILL1 PIC D. FILL2 PIC D ?GB@. +EDEFINE! D>. BUFFE+ PIC D ?G1@.

ALUE M-N. ALUE ALL MON. ALUE ALL M- M.

P+OCEDU+E DI I!ION PA+A 1. -O E 2B TO 3. DI!PLA3 D1. -O E MA1N TO 31. DI!PLA3 D1 DI!PLA3 D:. DI!PLA3 D>. DI!PLA3 DC. !TOP +UN.

Du(*i+ate Data Name"


Are a))o*e"9 (ro$i"e" the' &e)ong to a grou( item
Unit 2. The Organization of a COBOL Program
2.1G

Student Notebook

B1 Pa'-+e#. B2 I"-num&er% B2 Name B2 De(t B1 Print-+e#. B2 Fi))er B2 I"-num&er% B2 Fi))er B2 Name B2 De(t

PIC E?C@. PIC D ?2C@. PIC D ?2B@. PIC D ?C@. PIC D ?C@ PIC D ?C@. PIC D ?2C@. PIC D ?E2B@.

-O E I"-Num&er% ?OF P IN@ Pa'-+e# TO I"-Num&er% ?OF P IN@Print-+e#.


Figure 2-1> DUPLICATE "ata name%

G OF and IN are +a**ed Hua*ifier"/ To mo$e the "ata %tore" in the four fie)"% of Pa'-+e#. the four -O E %tatement% %er$e the (ur(o%e. U%ing the -O E CO++E!PONDIN, %tatement the %ame #an &e a##om()i%he".

$EN %ES C*au"e

Unit 2. The Organization of a COBOL Program

2.1H

Student Notebook

S,nta)# 44 data'name'1 $EN %ES data'name'2 TC$U data'name'B E.g. 6 B1 PA3 1 +EC. B2 FIDED-PA3. BC BA!IC PIC E?F@ EE. BC DA PIC E?F@ EE. B2 ADDITIONAL-PA3. BC 0+D PIC E?>@ EE. BC INCENT PIC E?:@ EE. B2 DEDUCTION!. BC PF PIC E?:@ EE. BC IT PIC E?>@ EE. BC OT0E+ PIC E?:@ EE. FF PA3-OT0E+-T0AN-BA!IC +ENA-E! DA T0+U INCENT. FF IT-AND-PF-DEDUCTION! +ENA-E! PF T0+U IT.

Figure 2-1C +ENA-E! C)au%e

Note"# In or"er to re-grou( e)ementar' "ata item% in a re#or"9 %o that the' #an &e)ong to the origina) a% *e)) a% to the ne* grou(9 the +ENA-E! #)au%e i% u%e". LE!EL'44 regrou(% (re$iou%)' "efine" item%. A )e$e)-FF entr' #annot rename another )e$e)-FF entr'9 nor #an it rename a )e$e)-B19 )e$e)-GG9 or )e$e)-HH entr'. A)) )e$e)-FF entrie% a%%o#iate" *ith one re#or" mu%t imme"iate)' fo))o* the )a%t "ata "e%#ri(tion entr' in that re#or".

ILLUST$ TES $EN %ES CL USE


DATE DI I!ION. 2O+AIN,-!TO+A,E !ECTION. B1 PA3
Unit 2. The Organization of a COBOL Program
2.1E

Student Notebook

B2 BC BC

FF FF

FIDED-PA3 1B E-BA!IC PIC E?F@. EE 1B E-DA PIC E?F@. EE. ADDL-PA3. 1B 0+A PIC E?>@. EE. 1B INCENTI E PIC E?:@. EE. DEDUCTION!. 1B E-PF PIC E?:@. EE. 1B E-IT PIC E?>@. EE. 1B OT0E+! PIC E?:@. EE. PA3-LE!!-BA!IC +ENA-E! E-DA T0+U INCENTI E. IT-AND-PF +ENA-E! E-PF T0+U E-IT.

P+OCEDU+E DI I!ION. -AIN-PA+A -O E-12:>CF.GH TO E-BA!IC. -O E 2:>CFG.HE TO E-DA. -O E 12:>.CF TO 0+A. -O E 12:.>C TO INCENTI E. -O E 12:.>C TO E-PF. -O E 12:>.CF TO E-IT. -O E 12:.>C TO OT0E+!. DI!PLA3 PA3. DI!PLA3 FIDED-PA3. DI!PLA3 Con%tant% fre4uent)' u%e" &' mo%t (rogram% ADDL-PA3. DI!PLA3 DEDUCTION!. Figurati.e Con"tant" %eaning DI!PLA3 PA3-LE!!-BA!IC. DI!PLA3 IT-AND-PF. 0I,0ALUE?!@ +e(re%ent% the highe%t an" )o*e%t !TOP +UN. LO2- ALUE! ?!@ $a)ue in the #o))ating %e4uen#e. One or more Leroe% One or more &)an8%

Figurati.e Con"tant"
!PACE ?!@

LE+O9 LE+O!9 LE+OE!

E7am()e

B1 ID-1 PIC D?:@ ALUE !PACE!.


2.2B

Co))ating %e4uen#e i% the or"er in *hi#h the #hara#ter% are #om(are" &' the %'%tem.

Unit 2. The Organization of a COBOL Program

Student Notebook

Figure 2-1F Figurati$e Con%tant% %o.e B2F/24 to a

Note"# Chara+ter" mu"t be edited before re(ort i" taken to "u((re"" *eading Figurati$e #on%tant% are re%er$e" *or"% that name an" refer to "e(arator"/ %(e#ifi# #on%tant zero"9 to in+*ude +urren+, "ign" or to in+*ude date $a)ue%. Editing Code" Effe+t L O Q Lea"ing Lero% if an' *i)) &e %u((re%%e" Lea"ing Lero% are re()a#e" &' a%teri%8%?O@ Curren#' %ign a((ear% in the )eft mo%t of the fie)". A((ear% at )eft or right of the fie)" a% %(e#ifie" in the (i#ture #)au%e if $a)ue i% negati$e A((ear% if $a)ue i% (o%iti$e9 e)%e minu% %ign a((ear%
Unit 2. The Organization of a COBOL Program

fie*d of (i+ture 3?B@.33 I di"(*a, or (rint 7ou ma, "ee different number in re"u*t

Edited Fie*d"
R

E"iting Co"e% are %(e#ifie" in the (i#ture #)au%e for $aria&)e% inten"e" for re(ort (ur(o%e. The"e .ariab*e" +annot be u"ed for arithmeti+ +a*+u*ation"/

2.21

Student Notebook

EDIT CODE!

-EANIN,

C+ or DB
Figure 2-1G / EDITED Fie)"%

To &e %(e#ifie" in the right mo%t (o%ition of the (i# #)au%e. A((ear% on)' if the $a)ue i% negati$e 9if $a)ue i% (o%iti$e it re()a#e" &' t*o #hara#ter%. !tan"% for "e#ima) (oint. Cannot &e %(e#ifie" *ith #)au%e In%erte" in the (o%ition *here %(e#ifie" B)an8 i% a((eare" Lero i% a((eare". To &e %(e#ifie" )eft mo%t (o%ition of (i# #)au%e.

B B %ore Editing Chara+ter" -?h'(hen@ S ?%)a%h@

U%e" a% "ate %e(arator%. A((ear% *here %(e#ifie". Unit 2. The Organization of a COBOL Program BLANA 20EN LE+O !et% a)) nu)) $a)ue% to &)an8%

2.22

Student Notebook

Figure 2-1H

EDITED Fie)"%

E> %PLES
DATA PIC CLAU!E UNEDITED PIC CLAU!E EDITED EDITED ALUE
2.2:

Unit 2. The Organization of a COBOL Program

Student Notebook

B2:>F BBBC B:.>2 B.BBG BCF:> BB1>: >C: -B>C: -B>C: >C: ->C: GB.>F 1CFGCH BB HFC> 2>

E?C@ E?>@ EE EE E EEE E?C@ E?C@ E?:@ E?>@ E?>@ E?:@ E?:@ EE EE E?F@ EE E E?>@ EE

LLEEE LLEE LEEE L EEE OOEEE QE?C@ QOOEEE -LLE?2@ EEEEEEEEEER EE.EEEESEESEE EE.E B)an8 *hen zero EE&E&E EEBB

2:>F BC BB: BBG OCF:> QBB1>: QOO>C: ->C: B>C:>C: >C:GB.>F 1CSFGSCH HFC> 12BB

Figure 2-1E

EDA-PLE!

Note"# The a&o$e ta&)e %ho*% #ontent% of une"ite" fie)"% in the fir%t #o)umn. Content% of e"ite" fie)"% after mo$ing the "ata-1 %ho*n in )a%t #o)umn. E"ite" fie)"% ?Fie)"% *ith e"iting #o"e%@ #annot ta8e (art in arithmeti# #om(utation%. -o$ing of numeri# e"ite" fie)"% to une"ite" fie)"% i% i))ega).

Unit 2. The Organization of a COBOL Program

2.2>

You might also like