+ All Categories
Home > Documents > COBOL 1.0.doc

COBOL 1.0.doc

Date post: 13-Apr-2018
Category:
Upload: sanganithi
View: 244 times
Download: 1 times
Share this document with a friend

of 48

Transcript
  • 7/24/2019 COBOL 1.0.doc

    1/48

    COBOL (COmmon Business Oriented Language)

    History.Developed in 1959 by a group called COnerence on D!ta "ystems Language

    (COD!"#L). $irst COBOL compiler %as released in 19&'.

    $irst !" approved version * 19&+,odiied !" approved version * 19- (O"/0" COBOL)

    ,odiied !" approved version * 19+5 (0" COBOL )

    23is boo4 is %ritten based on B, COBOL or O"/9' 06.

    "peciality.1. $irst language developed or commercial application development7 %3ic3 can

    eiciently 3andle millions o data.

    . 8rocedure Oriented Language 8roblem is segmented into several tas4s.:ac3 tas4 is %ritten as a 8aragrap3 in 8rocedure Division and e;ecuted in alogical se

  • 7/24/2019 COBOL 1.0.doc

    2/48

    Divisions in COBOL.

    23ere are our divisions in a COBOL program and t3e data division is an optional one.

    1.dentiication Division..:nvironment Division.

    .Data Division..8rocedure Division.

    dentiication Division.

    23is is t3e irst division and t3e program is identiied 3ere. 8aragrap3 86O6!,Dollo%ed by userdeined name is mandatory. 23oug3 ' c3aracters can be entered

    or t3e program D7 compiler %ill consider only t3e irst :H2 c3aracters and t3eremaining c3aracters %ill be ignored. !ll ot3er paragrap3s are optional and used or

    documentation.

    D:2$C!2O D0"O.86O6!,D. 86O6!, !,:.

    !=2HO6. CO,,:2 :26#."2!LL!2O. CO,,:2 :26#.

    D!2:G622:. CO,,:2 :26#.D!2:CO,8L:D. CO,,:2 :26#.

    ":C=62#. CO,,:2 :26#.

    "ecurity does not pertain to t3e operating system security7 but t3e

    inormation t3at is passed to t3e user o t3e program about t3e security eatures ot3e program.

    :nvironment Division.

    23is is t3e only mac3ine dependant division o COBOL program. t supplies

    inormation about t3e 3ard%are or computer e

  • 7/24/2019 COBOL 1.0.doc

    3/48

    "8:C!L!,:". 23is paragrap3 is used to relate 3ard%are names to userspeciied

    mnemonic names.1. "ubstitute c3aracter or currency sign. (C=66:C# " " litearal1)

    . Comma can be used as decimal point. (D:C,!L8O2 " CO,,!). Deault collating se

  • 7/24/2019 COBOL 1.0.doc

    4/48

    '9 levels. "peciy group or elementary items %it3in a record. roup level itemsmust not 3ave picture clause.

    && level. dentiy t3e items t3at contain t3e 6:!,:" clause.-- level. dentiy independent data item.

    ++ level. Condition names.

    0ariable name and Qualiier0ariable name can 3ave 1' c3aracters %it3 at least one alp3abet in it.

    Hyp3en is t3e only allo%ed special c3aracter but it cannot be irst or last letter o t3ename. ame s3ould be uni

  • 7/24/2019 COBOL 1.0.doc

    5/48

    " Clause"ynta; " " (L:!D) ":8!6!2: CH!6!C2:6 (26!L).

    t is applicable %3en t3e picture string contain K". Deault is 26!L G2H O":8!6!2: CH!6!C2:6. "o K" doesnt ta4e any space. t is stored along %it3 last

    digit.

    @1A! @AB @AC @AD @5A: @&A$ @-A @+AH @9A'AU7 1A I7 A 7 AL7 A,7 5A7 &AO7 -A87 +AQ7 9A6

    umber 26!L "

    (Deault)

    L:!D " L:!D

    ":8!6!2:.

    15 1 I5 15

    @15 1: !5 @15

    COBOL Page: 5

  • 7/24/2019 COBOL 1.0.doc

    6/48

    6eres3ing Basicsibble. ' Bits is one nibble. n pac4ed decimal7 eac3 nibble stores one digit.

    Byte. '+ Bits is one byte. By deault7 every c3aracter is stored in one byte.Hal %ord. 1& Bits or bytes is one 3al %ord. (,0")

    $ull %ord. Bits or bytes is one ull %ord. (,0")Double %ord. & Bits or + bytes is one double %ord. (,0")

    =sage Clause

    D"8L!# Deault. umber o bytes re

  • 7/24/2019 COBOL 1.0.doc

    7/48

    "#C Clause and "lac4 Bytes"#C clause is speciied %it3 CO,87 CO,81 and CO,8 items. 23ese items are

    e;pected to start at 3al/ull/double %ord boundaries or aster address resolution."#C clause does t3is but it may introduce slac4 bytes (unused bytes) beore t3e

    binary item.

    Consider t3e ollo%ing declaration in t3e GO6"2O6!: ":C2OP'1 ,#D!2!.

    '5 D!2!O: 8C R(&).'5 D!2!2GO 8C 9(&) CO,8 "#C.

    '5 D!2!2H6:: 8C "9()099 CO,8.

    23e "tarting address o $ull%ord s3ould end %it3 '77+ or C and t3at o 3al%ords3ould end %it3 '777&7+7!7C7:. D!2!O: starts at '7 it %ill occupy '5 bytes in

    memory. D!2!2GO a sync item o ull %ord cannot start at &. "o by "#C rule7 it

    starts at +t3position. &t3N -t3bytes are unused. "o ,#D!2! occupies 1& bytes.

    6:D:$:"

    23e 6:D:$:" clause allo%s you to use dierent data description entries to

    describe t3e same computer storage area. 6edeining declaration s3ould immediatelyollo% t3e redeined item and s3ould be done at t3e same level. ,ultiple redeinitions

    are possible. "iSe o redeined and redeining need not be t3e same. t cannot be

    done at && and ++ levels.

    :;ampleP'1 G"D!2: 8C 9('&).

    '1 G"6:D:$D!2: 6:D:$:" G"D!2:.

    '5 G"#:!6 8C 9(').'5 G",O 8C 9(').'5 G"D!# 8C 9(').

    6:!,:"

    t is used or regrouping o elementary data items in a record. t s3ould be declaredat && level. t need not immediately ollo%s t3e data item7 %3ic3 is being renamed.

    But all 6:!,:" entries associated %it3 one logical record must immediately ollo%t3at recordVs last data description entry. 6:!,:" cannot be done or a '17 --7 ++

    or anot3er && entry. t cannot be done or occurrences o an array.'1 G"6:8"O":.

    '5 G"CH!61 8C R(').'5 G"CH!6 8C R(').

    && !DD6:8"O": 6:!,:" G"CH!61.

    COD2O namet is identiied %it3 special level K++. ! condition name speciies t3e value t3at a ield

    can contain and used as abbreviation in condition c3ec4ing.'1 ":R 8C R.

    ++ ,!L: 0!L=: K1

    ++ $:,!L: 0!L=: K K.$ ":RA1 can also be veriied as $ ,!L: in 8rocedure division.

    COBOL Page: 7

  • 7/24/2019 COBOL 1.0.doc

    8/48

    K":2 $:,!L: 2O 26=: K moves value to ":R. multiple values are coded on0!L=: clause7 t3e irst value %ill be moved %3en it is set to true.

    I="2$:D 6H2

    23is clause can be speciied %it3 alp3anumeric and alp3abetic items or rig3tWustiication. t cannot be used %it3 && and ++ level items.

    OCC=6" Clause

    OCC=6" Clause is used to allocate p3ysically contiguous memory locations tostore t3e table values and access t3em %it3 subscript or inde;. Detail e;planation is

    given in 2able Handling section.

    L!: ":C2Ot is used to access t3e data t3at are e;ternal to t3e program. ICL can send

    ma;imum 1'' c3aracters to a program t3ru 8!6,. Lin4age section ,="2 be coded

    %it3 a 3al %ord binary ield7 prior to actual ield. lengt3 ield is not coded7 t3e irstt%o bytes o t3e ield coded in t3e lin4age section %ill be illed %it3 lengt3 and sot3ere %ill be last bytes data truncation in t3e actual ield.

    '1 LD!2!.

    '5 LL:2H 8C "9(') CO,8. '5 L0!6!BL: 8C R('+).

    L!: section o subprograms %ill be e;plained later.

    COBOL Page: 8

  • 7/24/2019 COBOL 1.0.doc

    9/48

    8rocedure Division.

    23is is t3e last division and business logic is coded 3ere. t 3as userdeined sectionsand paragrap3s. "ection name s3ould be uni

  • 7/24/2019 COBOL 1.0.doc

    10/48

    G3en t3e lengt3 o receiving ield is s3orter t3an t3at o sending ield7 t3enreceiving ield accepts c3aracters rom let to rig3t until it is illed. 23e

    unaccomodated c3aracters on t3e rig3t o t3e sending ield are truncated.G3en an alp3anumeric ield is moved to a numeric or numericedited ield7

    t3e item is moved as i it %ere in an unsigned numeric integer mode.CO66:"8OD can be used to transer data bet%een items o t3e same

    names belonging to dierent groupitems by speciying t3e names o groupitems to%3ic3 t3ey belong.

    ,O0: CO66:"8OD group1 2O group

    Group Move rule

    G3en ,O0: statement is used to move inormation at group level7 t3emovement o data ta4es place as i bot3 sending and receiving ields are speciied as

    alp3anumeric items. 23is is regardless o t3e description o t3e elementary itemsconstituting t3e group item.

    "amples or understanding ,O0: statement (,O0: ! 2O B)

    8icture o ! 0alue o ! 8icture o B 0alue o B ater

    ,ove

    8C 99099 1.5 8C 999099 '1.5

    8C 99099 1.5 8C 999909999 ''1.5''

    8C 990999 1.5 8C 9099 .

    8C9('5)09(') 51.5 8C 9(')09(') 1.5

    8C 9(')09(') . 8C ???99.9 .

    8C 99099 ''. 8C .99 .8C R(') ,="! RBRBRB , = "

    !62H,:2C 0:6B"!ll t3e possible arit3metic operations in COBOL using !DD7 "=B26!C27

    ,=L28L# and D0D: are given belo%P

    !rit3metic Operation ! B C D

    !DD ! 2O B ! !@B

    !DD ! B C 2O D ! B C !@B@C@D

    !DD ! B C 0 D ! B C !@B@C

    !DD ! 2O B C ! !@B !@C

    "=B26!C2 ! $6O, B ! B!"=B26!C2 ! B $6O,

    C

    ! B C(!@B)

    "=B26!C2 ! B $6O,C 0 D

    ! B C C(!@B)

    ,=L28L# ! B# B ! !>B

    ,=L28L# ! B# B

    0 C

    ! B !>B

    D0D: ! 2O B ! B/!

    COBOL Page:

    10

  • 7/24/2019 COBOL 1.0.doc

    11/48

    D0D: ! 2O B

    0 C

    ! B B/!

    D0D: ! B# B0 C

    ! B !/B

    D0D: ! 2O B0 C

    6:,!D:6 D

    ! B nteger (B/!) ntegerremainder

    0 is used in t3e ollo%ing casesP1.2o retain t3e values o operands participating in t3e operation.

    .23e resultant value o operation e;ceeds any o t3e operand siSe.

    6O=D:D optionGit3 6O=D:D option7 t3e computer %ill al%ays round t3e result to t3e

    8C2=6: clause speciication o t3e receiving ield. t is usually coded ater t3e ield

    to be rounded. t is prei;ed %it3 6:,!D:6 4ey%ord OL# in D0D: operation.!DD ! B 0 C 6O=D:D.

    D0D:..6O=D:D 6:,!D:6CautionP Dont use or intermediate computation.

    O "?: :66O6 !A' (8C 9(')) and BA9' (8C 9('))7 !DD ! 2O B %ill result 1' in B

    %3ere t3e e;pected value in B is 11'. O "?: :66O6 clause is coded to trap suc3siSe errors in arit3metic operation.

    t3is is coded %it3 arit3metic statement7 any operation t3at ended %it3 "?:

    error %ill not be carried out but t3e statement ollo%s O "?: :66O6 %ill bee;ecuted.

    !DD ! 2O B O "?: :66O6 D"8L!# K:66O6X.

    CO,8=2:

    CO,8=2: statement assigns t3e value o an arit3metic operation (on t3e rig3t3and side) to a data item (on t3e let 3and side).

    6uleP Let to rig3t * 1.8arent3eses (K(K K)).:;ponentiation (>>)

    .,ultiplication and Division (> and /).!ddition and "ubtraction (@ and )

    CautionP G3en 6O=D:D is coded %it3 CO,8=2:7 some compiler %ill do rounding

    or every arit3metic operation and so t3e inal result %ould not be precise.

    !ll arit3metic operators 3ave t3eir o%n e;plicit scope terminators. (:D!DD7:D"=B26!C27 :D,=L28L#7 :DD0D:7 :DCO,8=2:). t is suggested to use

    t3em.

    CO66:"8OD is available or !DD and "=B26!C2 only.

    COBOL Page:

    11

  • 7/24/2019 COBOL 1.0.doc

    12/48

    2!L?:

    0!L=: clause is used to initialiSe t3e data items in t3e %or4ing storagesection %3ereas 2!L?: is used to initialiSe t3e data items in t3e procedure

    division.2!L?: sets t3e alp3abetic7 alp3anumeric and alp3anumericedited items

    to "8!C:" and numeric and numericedited items to ?:6O. 23is can be overriddenby 6:8L!C option o 2!L?:. $LL:67 OCC=6" D:8:D O items are not

    aected."ynta;P 2!L?: identiier1

    6:8L!C (!L8H!B:2C/!L8H!=,:6C/!L8H!=,:6C:D2:D=,:6C/=,:6C:D2:D)

    D!2! B# (identiier /Literal)

    :;ampleP '1 !.

    '5 !1 8C 9(5).'5 ! 8C R().

    2!L?: ! 6:8L!C =,:6C D!2! B# 5'. %ill initialiSe only !1 by 5'.

    !CC:82!CC:82 can transer data rom input device or system inormation contain in

    t3e reserved data items li4e D!2:7 2,:7 D!#.

    !CC:82 G"0!61 ($6O, D!2:/2,:/D!#/O2H:6 "#"2:, 0!6"). $6O, Clause is not coded7 t3en t3e data is read rom terminal. !t t3e time

    o e;ecution7 batc3 program %ill !B:D i t3ere is no instream data rom ICL andt3ere is no $6O, clause in t3e !CC:82 clause.

    D!2: option returns si; digit current date in ##,,DDD!# returns 5 digit current date in ##DDD2,: returns + digit 6= 2,: in HH,,""22

    D!#O$G:: returns single digit %3ose value can be 1- (,onday"undayrespectively)

    D"8L!#

    t is used to display data. By deault display messages are routed to "#"O=2."ynta;P D"8L!# identiier1T literal1 (=8O mnemonic name)

    "2O8 6=7 :R2 86O6!, N O B!C

    "2O8 6= is t3e last e;ecutable statement o t3e main program. t returnscontrol bac4 to O".

    :R2 86O6!, is t3e last e;ecutable statement o subprogram. t returnscontrol bac4 to main program.

    OB!C can be coded in main program as %ell as subprogram as t3e laststatement. t Wust gives t3e control bac4 rom %3ere it received t3e control.

    !L2:6 statement

    23e alter statement is used to modiy t3e targets o O 2O statements

    %ritten else%3ere in t3e procedure division.

    COBOL Page:

    12

  • 7/24/2019 COBOL 1.0.doc

    13/48

    !L2:6 86OC:D=6:!,:1 2O Y86OC::D 2OZ 86OC:D=6:!,:Y86OC:D=6:!,: 2O [86OC::D 2OU 86OC:D=6:!,: Z....

    :ac3 o t3e 86OC:D=6:!,:17 86OC:D=6:!,: is t3e name o t3e

    paragrap3 t3at contains only one sentence. 23is sentence must consist o a singleO 2O statement %it3out t3e depending clause.

    During t3e e;ecution eac3 o t3e 86OC:D=6:!,:17 86OC:D=6:!,:7. . . %ill be replaced by 86OC:D=6:!,:7 86OC:D=6:!,: ...respectively.

    Collating "e

  • 7/24/2019 COBOL 1.0.doc

    14/48

    $ condition 2H:CO2=:

    :L":$ condition 2H:

    "tatementBloc4 :L":

    :R2 ":2:C::D$

    :D$:D$

    "tatementBloc4 %ill be e;ecuted only %3en condition 17 and are 26=:

    and condition is $!L":.

    mplied operandP n compound conditions7 it is not al%ays necessary to

    speciy bot3 operands or eac3 condition. $ 2O2!LA- or + is acceptable. Here2O2!LA+ is implied operation.

    " test and CL!"" test

    " test is used to c3ec4 t3e sign o a data item. t can be done as ollo%s *$ identiier is 8O"20:/:!20:/?:6O

    CL!"" test is used to c3ec4 t3e content o data item against predeined range ovalues. t can be done as ollo%s

    $ identiier is =,:6C/!L8H!B:2C/!L8H!B:2CHH:6/ !L8H!B:2CLOG:6

    Ge can deine our o%n classes in t3e special names paragrap3. Ge 3ave deined a

    class D2 in our special names paragrap3. t can be used in t3e ollo%ing %ay.$ identiier is D2

    egated conditions.!ny simple7 relational7 class7 sign test can be negated using O2.

    But it is not al%ays true t3at O2 :!20: is e

  • 7/24/2019 COBOL 1.0.doc

    15/48

    ."ubWect can be variable7 e;pression or t3e 4ey%ord 26=:/ $L!": andrespectively obWects can be values7 26=:/$!L": or any condition.

    . none o t3e GH: condition is satisied7 t3en GH: O2H:6 pat3 %ill bee;ecuted.

    Sample:0!L=!2: "QLCOD: !L"O 26=:

    GH: 1'' !L"O !ABGH: '5 !L"O (!/CA)

    D"8L!# K!LLOG:D "QLCOD:..86OC::D..GH: O2H:6 imperative statement

    :D:0!L=!2:

    n t3e above e;ample7 display %ill be t3ro%n %3en one o t3e irst t%o GH: clausesare true.

    8:6$O6, "2!2:,:2"8:6$O6, %ill be useul %3en you %ant to e;ecute a set o statements in

    multiple places o t3e program. Grite all t3e statements in one paragrap3 and invo4eit using 8:6$O6, %3erever needed. Once t3e paragrap3 is e;ecuted7 t3e control

    comes bac4 to ne;t statement ollo%ing t3e 8:6$O6,.

    1.",8L: 8:6$O6,.8:6$O6, 8!6!1.

    D"8L!# K8!6!1 e;ecuted"2O8 6=.

    8!6!1."tatement1

    "tatement.t e;ecutes all t3e instructions coded in 8!6!1 and t3en transers t3e control

    to t3e ne;t instruction in se

  • 7/24/2019 COBOL 1.0.doc

    16/48

    23is is e

  • 7/24/2019 COBOL 1.0.doc

    17/48

    ..1''"2:81.

    !DD ! 2O B 0 C.$ D A ?:6O D"8L!# K,=L28LC!2O O2 DO:

    O 2O ''"2:8:D$.

    ''"2:8.,=L28L# C B# D.

    ''"2:8.D"8L!# K0!L=: O$ CP C.

    Here O 2O used %it3in t3e range o 8:6$O6,. 23is 4ind o Controlled O 2O is ine%it3 structured programming alsoX

    2!BL:"

    !n OCC=6" clause is used to indicate t3e repeated occurrences o items ot3e same ormat in a structure. OCC=6" clause is not valid or '17 --7 ++ levels.

    t can be deined as elementary or group item. nitialiSation o large tableoccurrences %it3 speciic values are usually done using perorm loops in procedure

    division. "imple tables can be initialiSed in t3e ollo%ing %ay.'1 G::!66!# 0!L=: K,O2=:G:D2H=$6"!2"=.

    '5 G"G::D!#" OCC=6" - 2,:" 8C R(').

    Dynamic array is t3e array %3ose siSe is decided during runtime Wust beore t3e

    access o irst element o t3e array.

    COBOL Page:

    17

  • 7/24/2019 COBOL 1.0.doc

    18/48

    '1 G",O2HD!#C!L. '5 G"D!#" OCC=6" 1 2,:" D:8:D O G"OCC=6:C:.

    $ ,O2H A K$:B ,O0: K+ to G"OCC=66:C:.

    !rray tems can be accessed using D:R or subscript and t3e dierence

    bet%een t3em are listed in t3e table. 6elative subscripts and relative inde;es aresupported only in COBOL+5. Literals used in relative subscripting/inde;ing must be

    an unsigned integer.!DD G""!L("=B) G""!L("=B @ 1) 2O G""!L("=B @ ).

    "l J "ubscript nde;

    1 Gor4ing "torage item nternal tem * o need to declare it.

    t means occurrence t means displacement

    Occurrence7 in turn translated to

    displacement to access elementsand so slo%er t3an D:R access.

    $aster and eicient.

    t can be used in any arit3metic

    operations or or display.

    t cannot be used or arit3metic

    operation or or display purpose.

    5 "ubscripts can be modiied by any

    arit3metic statement.

    D:R can only be modiied %it3 ":27

    ":!6CH and 8:6$O6, statements.

    ":!6CH

    G3en t3e re

  • 7/24/2019 COBOL 1.0.doc

    19/48

    Dierence bet%een ":!6CH and ":!6CH !LL

    "l J "e

  • 7/24/2019 COBOL 1.0.doc

    20/48

    ,ulti Dimensional !rrays

    COBOL- supports array o ma;imum o t3ree dimensions %3ereas COBOL+5supports up to seven dimensions. 23e lo%est level OCC=6" dataname or an item

    subordinate to it is used to access an entry in t3e array or t3e table.

    %e use ":!6CH or accessing multidimension table7 t3en D:R:D B#must be used on all OCC=6" levels. :;panded nested perorm is available or

    processing multi level tables. 23e synta; o t3is perorm is given belo%P

    8:6$O6, para1 t3ru paran0!6# inde;1 rom 1 B# 1 =2L inde;1 E siSe o outeroccurs

    !$2:6 0!6# inde; rom 1 by 1 until inde; E siSe o inner occurs.

    ":!6CH e;ample or multi level tablesP'1 :,82!BL:.

    '5 D:82=,B:6 OCC=6" 1' 2,:" D:R:D B# 1.1' :,8D:2!L OCC=6" 5' 2,:" D:R:D B# .

    15 :,8=,B:6 8C 9(').15 :,8"!L!6# 8C 9('5).

    -- :,8=,B:6 8C 9(') 0!L=: K'5.8:6$O6, 1''":!6CH:,8"!L 0!6# 1 $6O, 1 B# 1

    =2L 1 E 1' O6 G"$O=D1''":!6CH:,8"!L.

    ":2 2O 1.":!6CH :,8D:2!L !2 :D D"8L!# KO2 $O=D AA E Lo%est Occurs

    GH: :,8=,B:6 A :,8=,B:6(17)D"8L!# K"!L!6# "P :,8"!L!6#(17)

    ":2 G"$O=D 2O 26=: AA E "earc3 ends:D":!6CH.

    :"2:D 86O6!,"7 LOB!L7 :R2:6!L

    One program may contain ot3er program(s). 23e contained program(s) may

    t3emselves contain yet ot3er program(s). !ll t3e contained and containing programss3ould end %it3 :D 86O6!, statement. 8,B is nested a program in t3e

    e;ample belo%P:;ampleP D:2$C!2O D0"O.

    86O6!,D. 8,! \

    D:2$C!2O D0"O.

    86O6!,D. 8,B\:D 86O6!, 8,B.

    \:D 86O6!, 8,!.

    you %ant access any %or4ing storage variable o 8,! in 8,B7 t3en

    declare t3em %it3 t3e clause K" LOB!L in 8,!. you %ant to access any

    COBOL Page:

    20

  • 7/24/2019 COBOL 1.0.doc

    21/48

    %or4ing storage variable o 8,B in 8,!7 declare t3em %it3 t3e clause K":R2:6!L in 8,B. ested 8rograms are supported only in COBOL+5.

    t3ere is a program 8,C inside 8,B7 it cannot be called rom 8,!unless its program id is

  • 7/24/2019 COBOL 1.0.doc

    22/48

    =" ile1 ile0 ile / O=28=2 86OC:D=6: is section1

    :D,:6:

    8rogram sort registers (and its e

  • 7/24/2019 COBOL 1.0.doc

    23/48

    "26 ,!8=L!2O! string reers to a se

  • 7/24/2019 COBOL 1.0.doc

    24/48

    "26

    "26 command is used to concatenate one or more strings."ynta;P

    "26 identiier1 / literal17 identiier/ literal D:L,2:D B# (identiier/literal/"?:)

    2O identiier:D"26.

    '1 0!61 8C R(1') 0!L=: K,=2H= K

    '1 0!6 8C R(1') 0!L=: K"!6! K'1 0!6 8C R(').

    2o get display K,=2H=7"!6!"26 0!61 D:L,2:D B# K K

    K7 D:L,2:D B# "?:

    0!6 D:L,2:D B# K K

    2O 0!6:D"26.

    23e receiving ield must be an elementary data item %it3 no editing symbols

    and I="2 6H2 clause.Git3 "26 statement7 speciic c3aracters o a string can be replaced

    %3ereas ,O0: replaces t3e ull string.'1 !:O=2 8C R(1) 0!L=: 1 #:!6" OLD.

    "26 K1+ D:L,2:D B# "?: 2O !:O=2. AE 1+ #:!6" OLD.

    6eerence ,odiication * e

  • 7/24/2019 COBOL 1.0.doc

    25/48

    G"$LD D:L,2:6 G"D CO=2 G"C:D="26.

    6esultPG"$LD1 A 1' G"$LD A'' G"$LDA''

    G"C1 A G"CA G"CA G"D1 A K/ G"DA/ G"D K/O O0:6$LOG can be coded %it3 "26 and ="26. t3ere is "26

    truncation t3en t3e imperative statements ollo%ed O O0:6$LOG %ill be e;ecuted.CO8# "tatement

    ! CO8# statement is used to bring a series o pre%ritten COBOL entries t3at3ave been stored in library7 into a program.

    1.Common routines li4e error routine7 date validation routine are coded in a library

    and bring into t3e program by CO8#.

    . ,aster iles are used in multiple programs. 23eir layout can be placed in one

    copyboo4 and be placed %3erever t3e iles are used. t promotes programstandardiSation since all t3e programs s3are t3e same layout and t3e same datanames.

    23is reduces coding and debugging time. C3ange in layout needs c3ange in

    copyboo4 only. t is enoug3 i %e Wust recompile t3e program or ma4ing t3e ne%copy eective.

    "ynta;PCO8# copyboo4name Y(O$/) library nameZ

    Y6:8L!C stringtobereplaced B# replacingstringZ

    Copyboo4s are stored as members in 8D" library and during compilation time7 t3ey

    are included into t3e program. By deault7 t3e copyboo4 library is "#"LB and it canbe c3anged using or O$ o CO8# statement.

    Copyboo4s can be used in t3e ollo%ing paragrap3s."O=6C:CO,8=2:67 OBI:C2CO,8=2:67 "8:C!L!,:"7 $L:CO26OL7

    OCO26OL7 $D ":C2O7 8!6!6!8H" 86OC:D=6: D0"O.

    t3e same copyboo4 is used more t3an once in t3e program7 t3en t3ere %illbe duplicate data declarationM error during compilation7 as all t3e ields are declared

    t%ice. n t3is case7 one copyboo4 can be used %it3 6:8L!C verb to replace 3ig3level

  • 7/24/2019 COBOL 1.0.doc

    26/48

    a language best suited to t3e speciic tas4 re

  • 7/24/2019 COBOL 1.0.doc

    27/48

    "l J 8assl By 6eerence 8ass By Content

    1 C!LL Ksub1 =" B#6:$:6:C: G"0!61

    C!LL Ksub1 =" B# CO2:2 G"0!61(B# CO2:2 4ey%ord is needed)

    t is deault in COBOL. B#6:$:6:C: is not needed.

    B# CO2:2 4ey %ord is mandatory topass an element by value.

    !ddress o G"0!61 is passed 0alue o G"0!61 is passed

    23e subprogram modiicationson t3e passed elements are

    visible in t3e main program.

    23e subprogram modiications on t3epassed elements are local to t3at

    subprogram and not visible in t3e mainprogram.

    Dierence bet%een "tatic Call and Dynamic Call

    "l J "2!2C Call D#!,C Call

    1 dentiied by Call literal.:;P C!LL K8,1.

    dentiied by Call variable and t3evariable s3ould be populated at run time.

    '1 G"8, 8C R('+).,ove K8,1 to G"8,

    C!LL G"8,

    Deault Compiler option is

    OD#!, and so all t3e literalcalls are considered as static calls.

    you %ant convert t3e literal calls into

    D#!,C7 t3e program s3ould becompiled %it3 D#!, option.

    By deault7 call variables and any un

    resolved calls are considered as dynamic.. t3e subprogram undergoes

    c3ange7 sub program and main

    program need to be recompiled.

    t3e subprogram undergoes c3ange7recompilation o subprogram is enoug3.

    "ub modules are lin4 edited %it3

    main module.

    "ub modules are pic4ed up during run

    time rom t3e load library.

    5 "iSe o load module %ill be large "iSe o load module %ill be less.

    & $ast "lo% compared to "tatic call.

    - Less le;ible. ,ore le;ible.

    26"C $=C2O"P

    L:2H 6eturns t3e lengt3 o t3e 8C clause. =sed or inding lengt3 o groupitem t3at spanned across multiple levels.

    ,!R 6eturns t3e content o t3e argument t3at contains t3e ma;imum value, 6eturns t3e content o t3e argument t3at contains t3e minimum value

    =,0!L 6eturns t3e numeric value represented by an alp3anumeric c3aracterstring speciied in t3e argument.

    =,0!LC "ame as =,0!L but currency and decimal points are ignored duringconversion.

    C=66:2 6eturns 1 C3ars alp3anumeric value * ####,,DDHH,,""nnnnnn

    COBOL Page:

    27

  • 7/24/2019 COBOL 1.0.doc

    28/48

    D!2:2::6 O$ D!2: 6eturns 2::6 e

  • 7/24/2019 COBOL 1.0.doc

    29/48

    $L: H!DL! data ile is collection o relevant records and a record is collection o

    relevant ields. 23e ile 3andling in COBOL program involves ive steps.

    "teps in ile3anding

    1.!llocationP 23e iles used in t3e program s3ould be declared in $L:CO26OL paragrap3 o environment division. 23e mapping %it3 ICL DD!,: is done

    3ere. 23e ile is allocated to your program by t3is statement.

    .Deinition. 23e layout o t3e ile and its attributes are deined in t3e $L:":C2O o D!2! D0"O.

    .OpenP Dataset is connected/readied to your program using O8:

    statement. 23e mode o O8: decides t3e operation allo%ed and t3e initial pointer in

    t3e dataset. $or e;ample7 :R2:D mode allo%s only %rite access and t3e pointer is4ept on t3e end o ile to append.

    .8rocessP 8rocess t3e ile as per re

  • 7/24/2019 COBOL 1.0.doc

    30/48

    ICL "tep e;ecuting t3e program s3ould 3ave a dataset %it3 DDNAMas label

    //DDNAM DD D"AB8,!.:,8LO#::.D!2!7D"8A"H6

    ":L:C2 "tatementO6!?!2Ot can be ":Q=:2!L (8" or 0"!, :"D")7 D:R:D (0"!, "D")7

    6:L!20: (0"!, 66D"). Deault is "e

  • 7/24/2019 COBOL 1.0.doc

    31/48

    6:":60: clause Y6:":60: integer !6:! Z can be coded in t3e ":L:C2statement. 23e number o buers to be allocated or t3e ile is coded 3ere.

    By deault t%o buers %ill be allocated i t3e clause is not coded. "ince similar optionis available in ICL7 t3is is not coded in program.

    6:":60: 1 !6:! allocates one buer7 or t3e ile in t3e ":L:C2 statement.

    Deining t3e ile in $L: ":C2O $D

    $D FILNAM

    6:CO6D ,OD: " 0/0B/$/$B6:CO6D CO2!" , CH!6!C2:6" (2O CH!6!C2:6")

    BLOC CO2!" R CH!6!C2:6"/6:CO6D" (2O # CH!6!C2:6"/6:CO6D")

    L!B:L 6:CO6D" !6: O,22:D/"2!D!6DD!2! 6:CO6D " FIL!R)ORD.'1 FIL!R)ORD8C R(nnn).

    $D6:CO6D CO2!"t speciies t3e lengt3 o t3e record in terms o bytes. (t %ill be 6:CO6D

    contains m to n CH!6!C2:6" or variable ormat iles)

    $DBLOC CO2!"

    t speciies t3e p3ysical record siSe. t can be mentioned as number o logicalrecords O6 number o c3aracters7 t3at is multiple o logical record lengt3. t is

    suggested to code BLOC CO2!" ' 6:CO6D" so t3at system %ill decide t3e

    optimum siSe or t3e ile based on t3e device used or storing t3e ile. BLOCCO2!" clause is treated as comments or 0"!, iles.

    !dvantage o Bloc4ingP1.O time is reduced as n numbers o records are read into main memory buer

    during an O..nter record gap is removed and t3e gap e;ist only bet%een bloc4s. "o memory

    %astage due to 6 is avoided.

    $D6:CO6D ,OD: "t can be $ ($R:D) 0(0!6!BL:) $B($R:D BLOC) 0B(0!6!BL: BLOC:D)

    0ariable record ile identiicationP t3ere is no recording mode/record contains clause7 it is still possible to

    identiy variable lengt3 records. t3ere is an OCC=6" depending on clause or t3ereare multiple '1 levels and every '1 level is o dierent siSe7 t3en t3e ile %ould be o

    variable lengt3. ,ultiple '1 levels in $ile section is an e;ample or implicitredeinition.

    $DL!B:L 6:CO6D" Clause

    !s a general rule7 L!B:L 6:CO6D" are "2!D!6D is coded or Dis4 and 2ape

    iles7 L!B:L 6:CO6D" !6: O,22:D is coded or printer iles. n COBOL-7 t3isclause is a mandatory clause %3ereas COBOL+5 made t3is as optional.

    COBOL Page:

    31

  • 7/24/2019 COBOL 1.0.doc

    32/48

    $DD!2! 6:CO6D " Clause

    t is used to name t3e data record(s) o t3e ile. ,ore t3an one record can becoded 3ere.

    O8: "2!2:,:2

    "ynta;P O8: O8:,OD: FILNAMO8:,OD: can be 8=2 O=28=2 O :R2:D

    8=2 $ile can be used OL#$O66:!D purpose.O=28=2 $ile can be used OL#$O6G62: purpose.

    O $ile can be used $O6 6:!D7 G62: and 6:G62: purpose.:R2:D $ile can be used $O6 appending records using G62:.

    CLO": statement.

    23e used iles are closed using CLO": statement. you dont close t3e iles7

    t3e completion o t3e program closes all t3e iles used in t3e program."ynta;P CLO": FILNAM

    O8: and CLO": or 2!8: iles !dvanced

    more t3an one ile is stored in a reel o tape7 it is called as multiilevolume. G3en one ile is stored in more t3an one reel o tape7 it is called as

    multivolume label. One reel is 4no%n as one volume. G3en t3e end o one volume is

    reac3ed7 automatically t3e ne;t volume opens. "o t3ere is no special control isneeded or multi volume iles.

    O8: 8=2 ile1 YG2H O 6:GD T 6:0:6":DZ

    O8: O=28=2 ile YG2H O 6:GDZ

    CLO": ile Y[6::LT=2U YG2H O 6:GDT $O6 6:,O0!LZCLO": ile YG2H O 6:GDTLOCZ

    =2 and 6::L are synonyms.!ter opening a 2!8: ile7 t3e ile is positioned at its beginning. G3en opening

    t3e ile i t3e clause 6:0:6":D is coded7 t3en t3e ile can be read in t3e 6:0:6:":direction. (8rovided 3ard%are supports t3is eature)

    G3en you close t3e ile7 t3e tape is normally re%ound. 23e O 6:GD

    clause speciies t3at t3e 2!8: s3ould be let in its current position.

    CLO": statement %it3 6::L option closes t3e current reel alone. "o t3e ne;t6:!D %ill get t3e irst record o ne;t 6::L. 23is %ill be useul %3en you %ant s4ip all

    t3e records in t3e irst reel ater n number o records processing.

    "ince 2!8: is se

  • 7/24/2019 COBOL 1.0.doc

    33/48

    23e iles O=2$L:1 and O=2$L: used in t3e program are part o a same2!8: and t3ey e;ist in irst and t3ird position in t3e tape. !lternatively7 t3is

    inormation can be passed rom ICL using L!B:L parameter.

    6:!D statement

    6:!D statement is used to read t3e record rom t3e ile."ynta;P 6:!D FILNAMY2O %srecordZ Y:# " FIL!"#$Z

    Y!2 :D/0!LD :# imperative statement1Z YO2 !2 :D/O2 0!LD :# imperative statementZ

    :D6:!D 2O clause is coded7 t3en t3e ile is directly read into %or4ing storage

    section record. t is preerred as it avoids anot3er move o ilesectionrecord to%or4ingstoragerecord ollo%ed by simple 6:!D. 6:!D2O is not preerred or

    variable siSe records %3ere t3e lengt3 o t3e record being read is not 4no%n.:# " clause is used %3ile accessing a record randomly using

    primary/alternate record 4ey.!2 :D and O2 !2 :D are used during se

  • 7/24/2019 COBOL 1.0.doc

    34/48

    "ynta;P 6:G62: FIL!R)ORD Y$6O, %srecordZ Y0!LD :# imperative statement1Z

    :D6:G62:

    "2!62 "tatement"2!62 is used %it3 dynamic access mode o inde;ed iles. t establis3es t3e

    current location in t3e cluster or 6:!D :R2 statement. "2!62 itsel does notretrieve any record.

    "ynta;P "2!62 FILNAM :# is :Q=!L 2O/O2 L:"" 2H!/6:!2:6 2H! 4eyname

    Y0!LD :# imperative statement1Z:D"2!62.

    D:L:2: "tatement

    D:L:2: is used to delete t3e most recently read record in t3e ile. 2o delete a

    record7 t3e ile s3ould be opened in O mode."ynta;P D:L:2: FILNAM6:CO6D

    Y0!LD :# imperative statement1Z

    :DD:L:2:

    6eports * $B!P

    6eports contain t3e printing control c3aracter in t3e irst byte. 23e record ormat

    %ill be $B! and t3e L6:CL %ill be 1 in t3e ICL. 23e program can deineprinting control c3aracter and populate it manually or can deine t3e layout %it3

    1 bytes and by means o program supported G62: verbs li4e!$2:6/B:$O6:/!D0!C. n t3e second case printing control c3aracter %ill

    be automatically added at t3e time o compilation by t3e deault !D0 compiler

    option.

    8rinting control c3aracter :

  • 7/24/2019 COBOL 1.0.doc

    35/48

    !2 :D is anot3er error 3andling clause provided by COBOL. But t3ere is no %ay to3andle all suc3 errors in t3is %ay.

    !ssign ilestatus and ta4e t3e responsibility.

    23e second met3od is7 assigning ilestatus to t3e ile in t3e ":L:C2 clauseand c3ec4s t3e ile status ater eac3 and every O and ensures t3at t3e value o

    status code is one o t3e allo%able values. it is not an allo%able return code7 t3enabnormally end t3e program %it3 error statements t3at %ould be easier to debug.

    But %e 3ave to do t3is c3ec4ing ater eac3 and every O operation.23is is ,O"2 86:$:66:D :66O6 H!DL ,:2HOD in structured programming.

    D:CL!6!20:" * =": statement

    COBOL provides an option to group all t3e possible errors o speciicoperation(s) in a place and t3at %ill be automatically invo4ed during t3e respective

    operation(s) o any ile. 23is avoids redundant code.

    23is is done in D:CL!6!20: section o t3e procedure division. D:CL!6!20:s3ould be t3e irst section in t3e procedure division i coded.

    86OC:D=6: D0"O.

    D:CL!6!20:".=":86OC:D=6: ":C2O.

    =": !$2:6 :RC:82O 86OC:D=6: O 8=2

    :66O686OC:D=6:.C3ec4 t3e ilestatus code or validity.

    :DD:CL!6!20:".G3enever t3ere is an error in t3e processing o !# $L: opened in 8=2

    mode7 t3en t3e control comes to :66O686OC:D=6:. 23e validity o error s3ould be

    c3ec4ed in t3is paragrap3 and allo% or restrict t3e process do%n7 based on severityo error code.

    23e complete synta; o =": statements isP=": !$2:6 "2!D!6D :66O6T:RC:82O 86OC:D=6: O

    8=2TO=28=2TOT:R2:DT ile1 8=2 is coded7 t3e ollo%ing procedure %ill be e;ecuted or every

    operation involved in any ile t3at is opened in 8=2 mode. O=28=27 O and:R2:D 3ave t3e same meaning but t3e mode is dierent.

    ile name (ile1) is coded in t3e =": statement7 t3en all t3e inputoutputoperation o t3at speciic ile %ill be c3ec4ed.

    :66O6 and :RC:82O are synonyms.23e 8rocedure %ritten in a D:CL!6!20: section s3ould not reer to any non

    declarative procedure %ritten ater t3e end procedure and viceversa.

    =": $O6 D:B= !LL 86OC:D=6: .D:B= D:CL!6!20:" 8!6!.

    D"8L!# 26!C D:B=!,::D D:CL!6!20:".

    COBOL Page:

    35

  • 7/24/2019 COBOL 1.0.doc

    36/48

    23is declarative section o t3e program %ill be e;ecuted beore t3e start o e;ecutiono eac3 paragrap3 deined in t3e program. i.e. ]26!C paraname] %ill be

    displayed beore t3e e;ecution o eac3 paragrap3. D:B=!,: is t3e specialregister t3at contains t3e name o t3e paragrap3 being e;ecuted.

    OCO26OL "!,: !6:! !D "!,: 6:CO6D !6:!

    6:":60: clause o ":L:C2 statement speciies t3e number o buers to be

    allocated or a ile. "!,: !6:! allo%s more t3an one ile to use t3e same buerarea. 23is %ill be very useul %3en t3e program must %or4 %it3 a limited memory

    space. But t3e problem is only one ile s3ould be open at a time i "!,: !6:! iscoded.

    "ynta;P "!,: !6:! $O6 ile1 ile ile.

    "!,: 6:CO6D !6:! is coded7 t3en t3e buer is not s3ared but only t3erecord area is s3ared. "o more t3an one ile can be in open state. Ge s3ould be

    careul %3ile illing in t3e record area o t3e output ile. 23is may destroy t3e recordread most recently.

    "ynta;P "!,: 6:CO6D !6:! $O6 ile1 ile ile.

    "!,: "O62 !6:! allo%s more t3an one sort/merge %or4 iles to use t3esame area. 23e sort %or4 iles are automatically allocated %3en ile is opened and

    deallocated %3en ile is closed. !s t3e sort ile is automatically opened and closedduring a "O62 and t%o sort iles cannot be opened at a time7 t3is clause may not be

    useul."ynta;P "!,: "O62T"O62,:6: !6:! or ile1 ile.

    $ile1 or ile s3ould be a "D ile.

    O CO26OL 6:6= Clause6:6= O rescue $O6 :0:6# integer 6:CO6D" on ile1

    23is %ill cause c3ec4point to be ta4en or every integer1 records processing oile1. t3e program !B:D:D beore t3e complete processing o t3e ile17 t3en

    t3e program %ill restart rom integer@1"2record instead o irst record. 23e rescue

    ile details s3ould be mentioned outside t3e program and it varies rom installation toinstallation.

    :26# statement:26# statement establis3es an alternate :26# point in a COBOL called

    subprogram. G3en a C!LL statement naming t3e alternate entry point is e;ecutedin a calling program7 control is transerred to t3e ne;t e;ecutable statement ollo%ing

    t3e entry statement. :;cept %3en a C!LL statement reers to an entry name7 t3e:26# statements are ignored at runtime.

    COBOL Page:

    36

  • 7/24/2019 COBOL 1.0.doc

    37/48

    $L: "2!2=" COD:"

    t is a t%obyte %or4ing storage item. 23e irst byte denotes t3e generalcategory %3ereas second byte denotes t3e particular type o error message under

    t3at category.

    * Success+ul O,N-RAD-%RIT Operation

    ' "uccessul completion

    Duplicate 4ey %as detected %3ic3 is allo%ed as per deinition o !R.

    Lengt3 o record Wust 6:!D didnt conorm to t3e i;ed lengt3 attributes or

    t3e ile.

    5 6eerenced Optional ile is not present during O8:. open mode is O or

    :R2:D7 t3en ile %ill be created.

    - Open or Close statement is e;ecuted %it3 a p3rase t3at implies a tape ile (e;

    O 6:GD) %3ereas t3e ile is not in 2!8:.

    $ %hen AT ND con.ition +ails

    ' "e

  • 7/24/2019 COBOL 1.0.doc

    38/48

    COBOL CO,8L!2O

    "#"862

    8!6, (Compiler listing)(Compiler

    Options)

    "#" "#"L(ObWect ,odule)

    ("ource)

    "#"LB 8!6,

    (Copyboo4 Library) (Lin4

    edit Options)

    "#"L,OD(Load ,odule)

    "#"862 "#"LB(Lin4 edit messages) ("ubroutine Library)

    CO,8L!2O ICLP//","RL+&B IOB 7VCO,8L!2O ICLV7 ,"CL!""AQ7,"L:0:LA(171)7CL!""AC

    //CO,8L:1 :R:C 8,A#C6C2L7 8!6,AR6:$7!8O7!D07,!87L"2)76:OA',//"2:8LB DD D"A"#"1.COBLB7D"8A"H6

    //"#" DD D"A","RL+&.2:"2.COBOL("!,8,'1)7D"8A"H6//"#"LB DD D"A","RL+&.CO8#LB7D"8A"H6

    //"#"862 DD "#"O=2A>//"#"L DD D"ANNLO!D":27 DCBA(6:C$,A$B7L6:CLA+'7BL"?:A'')7

    // D"8A(:G78!"")7=2A"#"D!7"8!C:A(C#L7(571')76L":)7//"#"=21 DD =2AN"#"D!7"8!C:A(C#L7(171')) AE )o.e S#S3T& to 3T4

    //L:D21 :R:C 8,A:GL7CODA(7L2)//"#"L DD D"ANNLO!D":27 D"8A(OLD7D:L:2:)

    //"#"L,OD DD D"ANNO":2("!,8,'1)7D"8A(:G78!"")7=2A"#"D!// "8!C:A(C#L717171))

    //"#"LB DD D"A","RL+&.LO!DLB7D"8A"H6//"#"=21 DD =2A"#"D!7"8!C:A(C#L7(171'))

    //"#"862 DD "#"O=2A>

    //>>> :R:C=2: 2H: 86O6!, >>>

    COBOL Page:

    38

    #C6C2L (COBOL CO,8L:6)

    :GL (Lin4 :ditor)

  • 7/24/2019 COBOL 1.0.doc

    39/48

    //:R:C=2:1 :R:C 8,A>.L:D21."#"L,OD7CODA(7L2)76:OA',//"2:8LB DD D"A","RL+&.LO!DLB7D"8A"H6

    // DD D"A"#"1."C::6=7D"8A"H6//"#"O=2 DD "#"O=2A>

    //"#"862 DD "#"O=2A>

    Compiler Options23e deault options t3at %ere set up %3en your compiler %as installed are in

    eect or your program unless you override t3em %it3 ot3er options. 2o c3ec4 t3edeault compiler options o your installation7 do a compile and c3ec4 in t3e

    compilation listing.

    Gays o overriding t3e deault options

    1.Compiler options can be passed to COBOL Compiler 8rogram (#C6C2L) t3roug3

    t3e 8!6, in ICL..86OC:"" or CBL statement %it3 compiler options7 can be placed beore t3eidentiication division.

    . t3e organiSation uses any t3ird party product or its o%n utility t3en t3ese options

    can be coded in t3e predeined line o t3e utility panel.

    8recedence o Compiler Options

    1. (Hig3est precedence). nstallation deaults7 i;ed by t3e installation.. Options coded on 86OC:"" /CBL statement

    . Options coded on ICL 8!6, parameters. (Lo%est 8recedence). nstallation deaults7 but not i;ed.

    23e complete list o compiler option is in t3e tableP

    !spect Compiler Option

    "ource Language !8O"27 C,867 C=66:C#7 DBC"7 LB7 =,B:67Q=O2:7 ":Q=:C:7 GO6D

    Date 8rocessing D!2:86OC7 2D!2:7 #:!6GDOG

    ,aps and Listing L!=!:7 L:CO=27 L"27 ,!87 O$$":27 "O=6C:7 "8!C:7

    2:6,!L7 0B6:$7 R6:$

    ObWect Dec4generation

    CO,8L:7 D:C7 !,:7 OBI:C27 8,!,:

    ObWect Code

    Control

    !D07 !GO7 DLL7 :R8O62!LL7 $!"2"627 O82,?:7 =,86OC7

    O=2DD7 26=C7 ?GB

    Debugging D=,87 $L!7 $L!,7 $L!"2D7 ""6!:7 2#8:CH

    Ot3er !D!2!7 !!L#?:7 :R27 DL:

    !D0P t is meaningul i your program 3as any printer iles %it3 G62:..!D0!C4ey%ord. 23e compiler adds one byte prei; to t3e original L6:CL o printer iles or

    printing control purpose. you are manually populating printing control c3aracter in

    t3e program7 t3en you can compile your program %it3 O!D0.

    COBOL Page:

    39

  • 7/24/2019 COBOL 1.0.doc

    40/48

    D#!,P =se D#!, to cause separately compiled programs invo4ed t3roug3 t3eC!LL literalstatement to be loaded dynamically at run time. D#!, causes dynamic

    loads (or C!LL) and deletes (or C!C:L) o separately compiled programs at obWecttime. !ny C!LL i.enti+ierstatements t3at cannot be resolved in your program are

    also treated as dynamic calls. G3en you speciy D#!,7 6:"D:2 is also put intoeect.

    L"2/O$$":2P L"2 and O$$":2 are mutually e;clusive. you use bot37 L"2 %ill beignored. L"2 is used to produce listing a listing o t3e assembler language e;pansion

    o your code. O$$":2 is used to produce a condensed 8rocedure Division listing.Git3 O$$":27 t3e procedure portion o t3e listing %ill contain line numbers7

    statement reerences7 and t3e location o t3e irst instruction generated or eac3

    statement. 23ese options are useul or solving system !B:D". 6eer ICL sessionor more details.

    ,!8P =se ,!8 to produce a listing o t3e items you deined in t3e Data Division.

    ""6!:P t3e program is compiled %it3 ""6!: option7 t3en any attempt to

    reer an area outside t3e region o t3e table %ill abnormally terminate %it3

    protection e;ception7 usually "'C.t also avoids any meaningless operation onreerence modiication li4e negative number in t3e starting position o reerence

    modiication e;pression. t3e program is compiled %it3 O""6!:7 t3en t3eprogram may proceed urt3er %it3 Wun4 or irrelevant data. "o usually t3e programs

    are compiled %it3 ""6!: during development and testing.

    6:2P ! program compiled as 6:2 is generated as a reentrant obWect module. CC"

    programs s3ould be compiled %it3 6:2 option to s3are t3e same copy o t3eprogram by multiple transactions (,ultit3reading)

    6:"D:2P =se t3e 6:"D:2 option to re

  • 7/24/2019 COBOL 1.0.doc

    41/48

    2"O Commands rom COBOL program

    CBL APOST,NODECK,OBJECT,BUF(10000),DYNAM => Compile op!io" o#ei$e %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    % FUNCT&ON = T'i mple po*m $emo"!!e 'o+ !o i"#oe %

    % TSO -omm"$ .om COBOL po*m /i"* %

    % !"$$ TSO e#i-e $o-/me"!e$ i" !'e %

    % TSOE Po*mmi"* Se#i-e m"/l %

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    &$e"!i.i-!io" Di#iio"

    Po*m2&D SMSTSOE3

    D! Di#iio"

    4oi"*2S!o*e Se-!io"

    01 Fille

    05 +2$/mm6 Pi- 7(8) Comp

    05 +2e!/"2-o$e Pi- 7(8) Comp

    05 +2eo"2-o$e Pi- 7(8) Comp 05 +2i".o2-o$e Pi- 7(8) Comp

    05 +2-ppl2$$e Pi- 7(8) Comp

    05 +2.l* Pi- 9(:) 3l/e 9;00010001;

    05 +2

  • 7/24/2019 COBOL 1.0.doc

    42/48

    % Cll !'e TSOE Se#i-e @o/!i"e !o ee-/!e !'e TSOE -omm"$ %

    %2222222222222222222222222222222222222222222222222222222222222222%

    CALL ;&KJEFTS@; Ui"* +2.l*,+2 ?eo

    D&SPLAY ;&KJEFTS@ File$, @e!/"2-o$e=; +2e!/"2-o$e

    ; @eo"2-o$e=; +2eo"2-o$e

    MO3E +2e!/"2-o$e !o @e!/"2-o$e

    STOP @UN

    %2222222222222222222222222222222222222222222222222222222222222222%

    % C'e- !'! !'e ALLOCATE -omm"$ +oe$ %

    %2222222222222222222222222222222222222222222222222222222222222222%

    D&SPLAY ;ALLOCATE 4oe$ ; Upo" S6p/"-'

    STOP @UN

    ntervie% Questions(Q)P

    > "ays importance and possibility o t3e >>>>

    .dentiying and ma4ing "tatic and Dynamic call >>>>>.Binary and "e>>>>

    5.G3at are t3e various %ays o passing data rom ICL to 8rogram and 3o% to receivet3em in 8rogram^ >>>>>

    &.Dierence bet%een COBOL- (O"/0" COBOL) and COBOL+5 (0" COBOL) >>>>-."ubscript and nde; dierence and %3en you preer %3at^ >>>>

    +.6eerence modiication. >>>>9.Compiler and Lin4 edit option * ""6!: ,!8 L"2 O$$":2 6:2 6:"D:2

    D#!, and !,OD:/6,OD: >>>1'.Ho% to ma4e a call by content in COBOL^ >>>

    11.Ho% do you set return code rom t3e program^ >>>1.Case structure7 "ubstring7 Do %3ile7 Do =ntil7 BLL e>>

    1.Dierence bet%een section and paragrap3 >>>>>1.Can occurs be coded in '1 level^ >>>>>

    15.!re multiple '1 levels supported in ile section^ >>1&.0arious %ays o overriding deault compiler options >>

    1-."ort algorit3ms >>1+.Ho% to get t3e actual lengt3 o alp3anumeric item^ >>

    19.G3at is =2" means %it3 respect to ":L:C2 statement^ >

    '.Can re%rite a se1.CO,8 items are al%ays better t3an CO,8 in terms o memory. #es/o >>

    .G3ic3 0"!, type is astest^ 6elative 4ey is part o ile section^ >>

    .Ho% to create a report in COBOL program^ >>>.Ho% to submit a ICL rom COBOL program^ >>>>

    5.G3at is "#C Clause^ >>&.G3at is in line 8:6$O6, and %3en %ill you use it^ >>>>

    COBOL Page:

    42

  • 7/24/2019 COBOL 1.0.doc

    43/48

    -.G3at is "8:C2 statement^ >>>+.2o use ":!6CH !LL7 t3e table s3ould be in sorted order. am loading t3e table

    rom one o t3e 8D" members. 23e 8D" member data is not in sorted order. Ho% %ill load t3e table in "O62:D order^ #ou s3ould not sort in ICL. >>

    9.G3at is t3e purpose o =": statement^ >'.G3at are "!,: !6:! and "!,: 6:CO6D !6:!^ >

    1. s dynamic allocation possible in COBOL^ yes7 Ho%^ >. G3at is t3e dierence bet%een O "?: :66O6 and O O0:6$LOG^ >

    .Ho% to s%ap t%o variables %it3out t3ird variable^ >.G3at is limit o lin4age section^ >

    !ns%ers or selected

  • 7/24/2019 COBOL 1.0.doc

    44/48

    =2L :D$O=D O6 G""=B!,: A ' $ G"!,:CH(G""=B!,:P1) O2 :Q=!L 2O "8!C:

    ,O0: V#V 2O G":DO$$:LD D"8L!# VL:2H V G""=B!,:

    :D$ :D8:6$O6,

    Ho% to pass user return code and user !B:D rom t3e COBOL program to t3e ICL^

    6:2=6COD: is a special register and its content is moved to 6egister15 %3en t3econtrol is given bac4 to O". "o move t3e return code to t3is register in t3e program.

    :;P ,O0: 1''' to 6:2=6COD:.23is sets return code as 1''' or t3e step t3at e;ecutes t3is program.

    $or !B:D7 you s3ould call your installation speciic assembler routine or LBO!B'

    %it3 t3e !B:D code you %ant.

    ,O0: 1''' 2O G"!BCOD:.C!LL KLBO!B' =" G"!BCOD:.

    G"!BCOD: is t3e variable t3at 3as !B:DCOD:. t is a 3al %ord binary.23e

    above code %ill issue =1''' abend.

    COBOL Page:

    44

  • 7/24/2019 COBOL 1.0.doc

    45/48

    G3at are t3e sort algorit3ms^ (Q 1- and +)

    Bubble "ortP Consecutive elements are compared and 4eys o t%o elements are not

    in proper order7 t3ey are s%apped. n t3e irst pass7 t3e 4ey %it3 largest value %ill bemoved to t3e last position and n1 passes needed to sort t3e %3ole table.

    n bet%een7 i any pass results no interc3ange it implies t3at t3e table is in sortedorder.

    !rrayP 1 ' 9 5' +

    $irst 8assP (,a;imum comparisons or 5 elements)17 'Eno c3ange7 ' N 9 E ' is great so s%ap (1 9 ' 5')7

    ' N 5' E no c3ange7 5' N + E 5' is great7 so s%ap. (1 9 ' + 5')

    "econd 8assP (1 9 ' + 5') (,a;imum comparison or 5 elements)1 N 9E no c3ange7 9 N ' E no c3ange7 ' N + E ' is great so s%ap(1 9 + ' 5')

    23ird 8assP (1 9 + ' 5') * (,a;imum comparisons or 5 elements)

    1 N 9 E no c3ange7 9 N +E c3ange (1 + 9 ' 5')$ourt3 8assP (1 + 9 ' 5') * (,a;imum 1 comparison or 5 elements)

    1 N 9 E no c3ange

    oteP #ou can come out o sort %3en you ind Kno c3ange in all t3ecomparisons o a pass.

    "3uttle "ortP n t3e irst pass only irst t%o elements are compared and sorted and in

    t3e second pass7 t3ird element is compared %it3 t%o and one and it is placed in t3e

    rig3t position. n t3e it3 pass7 it assumes t3at elements are in already sorted order7proceeds to sort t3e irst (@1) elements by comparing @1 t3 element %it3 7 and %it3 1 and so on until top o t3e table is reac3ed or noe;c3ange in a comparison.

    !rrayP 1 ' 9 5' +

    $irst 8assP 2%o elements (1 ') ,a;imum 1 comparison17 'Eno c3ange

    "econd 8assP 23ree elements (1 ' 9) * ,a;imum comparisons9 N ' E c3ange (1 9 ') 9 N 1 E no c3ange

    23ird 8assP $our elements (1 9 ' 5') * ,a;imum comparisons5' N ' E no c3ange and stop (no need or any ot3er comparison)

    $ourt3 8assP $ive elements (1 9 ' 5' +) * ,a;imum comparisons+ N 5' E c3ange ( 1 9 ' + 5') 7 + N 'E C3ange ( 1 9 + ' 5')

    + N 9 E C3ange (1 + 9 ' 5') 7 + N 1 E no c3ange and stop.oteP #ou can come out o pass i you ind one Kno c3ange

    "3uttle sort is better t3an bubble sort or sorting arrays %it3 more t3an 1' elements.

    CO,8 items are al%ays better t3an CO,8 %it3 respect to memory usage (Q 1)^

    o. CO,8 items occupy less space t3an CO,8 items at boundaries.

    8C "9(') CO,8 occupies bytes %3ereas 8C "9(') CO,8 occupies bytes.8C "9('9) CO,8 occupies bytes %3ereas 8C "9('9) CO,8 occupies 5 bytes.

    COBOL Page:

    45

  • 7/24/2019 COBOL 1.0.doc

    46/48

    8C "9(1+) CO,8 occupies + bytes %3ereas 8C "9(1+) CO,8 occupies 1' bytes.

    3ave a "D" "tudents ile %it3 bytes 4ey. $irst t%obytes contain class number

    and ne;t t%obytes contain student number. %ant to read all t3e students in classK'. Ho% %ill you do t3at^

    !llocate t3e ile %it3 dynamic access mode. ,ove K' to irst t%obytes o t3e4ey and lo%values to ne;t t%obytes o t3e 4ey. #ou can do t3ese moves by

    reerence modiication operator or degrouping t3e ourbyte ield into t%o t%obyteields in t3e ile section.

    ssue t3e "2!62 command %it3 :# " 6:!2:6 2H! clause. "tart readingt3e ile in loop until irst t%obytes is not e

  • 7/24/2019 COBOL 1.0.doc

    47/48

    Dierence bet%een O"/0" COBOL and 0" COBOL ^

    O" 0" COBOL (COBOL-) 0" COBOL (COBOL+5)

    Bit addressing !llo%s 1 bit addressing and ma4es

    easier to develop large applications.

    ested 8rograms are not allo%ed ested 8rogram are allo%ed * mprovesproductivity because dierent

    programmers can develop t3em at t3e

    same time. * 8romote data s3aring anddata protection.

    6eport %rite eature is dropped. (6G)

    O2:"7 KO statement7 6:,!6" areremoved.

    :;plicit scope terminators are introduced.

    8O2:6 clause is added."8:C2 replaces :R!,: %it3 advance

    capabilities.

    COBOL Page:

    47

  • 7/24/2019 COBOL 1.0.doc

    48/48


Recommended