Cobol programming: a complete course in writing Cobol programs 043577803x


195 36 8MB

English Pages [352] Year 1972

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Cobol programming: a complete course in writing Cobol programs
 043577803x

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

_ Cobol Programming - SECOND

11]

r 12

LES)

3

EDITION

a complete course in writing cobol programs

yA)

| ee

Ou

~

(OFe) ole) mMacolele-lanlanligys|

RRC

Digitized by the Internet Archive in 2022 with funding from Kahle/Austin Foundation

https://archive.org/details/cobolprogrammingOO00watt

Cobol

Programming

r

Cobol

Programming

a complete course

by John

in writing Cobol programs

Watters

Education Research Department International Computers Limited

Second

Edition

Cis, Heinemann

Educational

Books

- London

Heinemann Educational Books Ltd LONDON EDINBURGH MELBOURNE AUCKLAND HONG KONG SINGAPORE KUALA LUMPUR NAIROBI IBADAN JOHANNESBURG NEW DELHI LUSAKA

TORONTO

ISBN 0 435 77803 x

© International Computers Limited, 1970, 1972 First published 1970 Second Edition 1972 Reprinted 1974, 1975

Published by Heinemann Educational Books Ltd 48 Charles Street, London W1rX 8AH

Reproduced and printed by photolithography and bound in Great Britain at The Pitman Press, Bath

Introduction This text has been designed to teach you to write programs in the commercial programming language Cobol. Although you don’t need to have had any previous programming experience before starting the text you are expected to know what a programming language is for and what the central processor and its peripherals do. And so, if you are completely new to computers we recommend that you read Basic Digital Computer Concepts* before starting the course. Throughout the text you will be asked to answer questions on the topics you have just learnt. To gain the greatest benefit from this method you must write down your answer before comparing it with the solution, which is always given on the next page. If your answer is wrong and you can’t see why, read over the previous section before continuing. During the course you will be asked to write several complete Cobol programs. Your version of the program may be perfectly correct and still be quite different from the solution we give. Since the best way of checking if a program is correct is to run it on the computer we have included in Appendix E the steering lines needed to run Cobol programs on the ICL 1900 series. If you don’t have access to a computer compare your solution with the one we give and correct any obvious errors in your program. The following acknowledgement is reprinted from the COBOL 1965 Report issued by the U.S. Department of Defense. Any organization interested in reproducing the COBOL report and specification in whole or in part, using ideas taken from this report as the basis for an instruction manual or for any other purpose, is free to do so. However, all such organizations are requested to reproduce this section as part of the introduction to the document. Those using a short passage, as in a book review, are requested to mention COBOL in acknowledgement of the source. COBOL is an industry language and is not the property of any company or group of companies, or of any organization or group of organizations. No warranty, expressed or implied, is made by any contributor or by the COBOL Committee as to the accuracy and functioning of * Published by Heinemann Educational Books.

the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection therewith. Procedures have been established for the maintenance of COBOL. Enquiries concerning the procedures for proposing changes should be directed to the Executive Committee of the Conference on Data Systems Languages. The authors and copyright holders of the copyrighted material used herein FLOW-MATIC Trademark for Sperry Rand Corporation), Programming for the Univac (R) I and II, Data Automation Systems copyrighted 1958, 1959, by Sperry Rand Corporation; IBM Commercial

Translator

Form

No.

F 28-8013,

copynghted

1959

by IBM; FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell have specifically authorized the use of this material in whole or in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL Specifications in programming manuals or similar publications.

Preface to Second

Edition

Cobol Programming has been enhanced to include the Compute Statement and some of the more advanced techniques of program-

mung for direct access.

vi

The Program Divisions Every Cobol program is made up of four divisions, these are the:

IDENTIFICATION ENVIRONMENT DATA

DIVISION DIVISION

DIVISION

PROCEDURE

DIVISION

Within a program the divisions are always in this order.

The Identification Division The Identification Division gives the program a name and starts with the heading:

ICL Sequence

|

ye

No.

1

67

|

8

Sra

sheet

aeoeee

ge TY ¥2

15

20

25

30

35

40

| PSEMELEAGATLON OIISLON., ies Sretera @daore

45

50

Work

All headings start at column 8 and are followed by a full stop.

The Identification Division is made up of paragraphs, each with a paragraph heading. There is in fact only one essential paragraph, called PROGRAM-ID.

ICL Sequence

No.

SLCnEoin sheet

ate

4

IDENT! FICATION DIVISION... 1. a PROGIRAM=[1De bil md Swoe ewe Seine Me

a) ee le

aaa

"| ee

On the ICL 1900 series all program names are four characters long. The first must be alphabetic, the rest can be alphabetic or numeric. Following the program name is a two digit number which is used to give the program’s priority on multi-programming

machines. This program we'll call STOC50. The program name is written starting at column 12 or later and is followed by a full stop. It is usually written on a new line.

| ICL Sequence

1

Beoacarn sheet

seni

No.

+ Suga eerel 2g! S

20

25

NOI

30

VES

TON. ee

35

ST

40

Pima ES

45

ne

50

eee

PROGRADe MSclic et | trent lens will: mls lve el | STOCS¢.seins ae els evilith eet abet 5 |YEO gs eiewer | 1

ll Seccivll aenerd has halls Be eran Be

|

odear Bere

In this text zeros are written with strokes to distinguish them from the:letter O.

The program name is all the information you need give in the Identification Division.

In this text we shall never use columns 1 to 6 or 73 to 80 but here

is a brief explanation of what they are used for. Columns 1 to 6 are used to give each line of coding a sequence number:

[08 DEN

Sequence numbers are usually written in steps of ten in case you want to insert lines in your program.

Columns 73 to see that card in the regarded as

to 80 are used for Identification. The compiler checks these columns contain the same punching on every source pack. Any card with a different punching is having got into the source pack by mistake.

Question Write a complete Identification Division to give a program the name MOON and a priority of 40.

Answer

Sequence

1

No.

67

i

COBOL

ICL

program 4

4

8

Musee

ae

IDENTIFICATION DIVISION, RAM-ID..

OON4P..

1

i

ie

st

=

Ss

2

ee,

=

“a

aie



| ee

ee

l

|

programmer

va

4

oe

25

20

sheet

eS

se

ay kk

mm

I

i

4

SS

eal

—_— =

=

The Environment

Division

The Environment Division specifies the computer and peripherals used by the program and starts with the heading:

program sheet Sequence

vsrammer

No. iy 7

3

yl ‘

15

35

40

45

[ENR OnMENT, BIUTSHON cn lerrisbie eel [ena NOL sical oY If you’ve never been very sure how to spell ‘environment’ you must now learn as headings wrongly spelt will show as errors when the program is compiled.

50

|

The Environment Division is divided into two sections. The first,

the Configuration Section, states which computer is to be used to compile the program and which computer is to be used to run the object program.

In Cobol these are called the source and object computers and each has a paragraph.

COBOL

ICL

program Sheet

11 12

15

20

25

ENVIRONMENT, DIVISIO CONFIGURATION SECTIION. CE - COMPUTER.

30

35

40

title

prcarammer 45

You will notice that whenever a section or paragraph name is made up of more than one word it is hyphenated.

50

In this case the same computer, an ICL

1903, is to be used to

compile and run the program.

C00 ae 1G program Sequence 1

No.

4

4

6

8

11 12

ee

sheet _ prsramme:

/ 15

20

30

25

35

40

45

TENVINRONMENT DIVISION. | (CONFIIGURIATION SECTION. |ISOUIRICE -CIOMPUTIER.

if|__| e983. i A

In addition, in the Object-Computer paragraph, we say how much core-store is available to the object program, let’s say 10000 words.

BO On sheet

ICL 1

4 Gage Semen il2

2

Te ENVIRONMENT. DIVISION... SEELION. so EEN

Sere

50

The second section in the Environment Division, the InputOutput Section, associates the program’s files with their peripherals. It has one essential paragraph, called FILE-CONTROL.

| |JUNPUTour PUT ISECTIIO YL ELUElCONTROL. Be cst |Sonal In Cobol the slow peripherals are known by the following names:

CARD-READER CARD-PUNCH PRINTER PAPER-READER PAPER-PUNCH No variation of these names is allowed.

10

The names you choose for the files must obey the following rules:

1.

A name is made up from the character set: AtoZ 0 to 9 hyphen and must not be more than 30 characters long.

2.

At least one of the characters must be alphabetic.

3.

A hyphen must not appear at the beginning or end of a name.

4.

A name must not be the same as any of the reserved words in Appendix A.

II

Let’s say we have an input file on cards which we have given the name CARD-FILE. It is associated with the card-reader by the statement:

Ts TUNPUIT- OUTPUT PAT |

tL

ISECTIION. eee ee cl ee

ISELEIGT, CARD-FIILE

ASISIGN

[CARD

READEIR

1,

The integer after the peripheral name is used simply to distinguish this card-reader from any other we may assign in the program.

Every file in a program must be assigned a peripheral. Printed output, for example, is also a file.

ll

TFILIE/-CONTROL.

Seal

lel

Lk.



eS



||| SELECT, CARD-FIILE ASSIGN CARD-READER 1. i SELECT, PRINT-FILE ASSIGN PRINTER 1). | Bole eee eee oe ee

Question As you can see the Environment Division is concerned not with what a program does but with the hardware it uses, and so will change if the configuration changes.

Before continuing, try writing the Environment Division for a program where the machine is an ICL 1905, input and output are on paper tape and there are 14000 words of core-store available to the prograin.

13

Answer

ICL

OL ee POA Fahenn programmer prog 11 12

15

20

30

35

|.. | JENVIRONM . ENT7,DEVISION... Ldoane> | CONFILGURATION SECTION. Lavy |...| Source-compu TR KCL po pet 288. ma ia been

40

45

50

a pleaser], Se Dhypaar ney eis ae oe as

.T-COMPUTER.

Mich MEMOIRY

985 14,089

|

: P -OUTPUT |SECTION, (FIUE-CONTROL.| |...

i

Sep

ay

WORDS,

l

ol

Check that you have remembered all the full stops and hyphens .

14

=

SELECT, TAIPE-IN ASSIGN F R-READ _| [SELfa? T TAPE-OUT ASSIGN PAPER-PUNCN

|

The Data Division The Data Division is made up of a number of sections. Only the first of these, the File Section, need appear in every program. In the File Section we describe the files used by the program and those created by it.

COBOL m

ICL Sequence

No.

67

=I Local

cou

r

4

8

A122

diet

15

20

25

rrosrammer

40

35

30

i

sheet

progra

DIVISION SECTION. |

45

50

|

File descriptions can be in any order and each description begins with the letters FD starting at column 8 and the file name starting at column 12.

title

ICL Sequence

pusse sheet

programmer

No. 67

8

{HA

11 12

15

20

30

50

35 jo we el

#8

Els

Se eeewe|

eae eee eeees ewer petal et

15

Label records are used only on magnetic tape files so we add a clause saying that they are omitted.

ICL

eters Sheet UD Y-

15

20

-.....| JOATIAL DIVISION. po ELLE] SECTION. pi... IED | CARDERIL |eal LABEL RECORDS Fees! Pave Ua

25

30

OMITTED

35

rrosrammer

40

45

50

A Puerco ee ee eee

Next we add a clause naming the records held on the file. If in CARD-FILE we have one type of record which we want to call REC-IN the clause would be:

COBOL program

ICL Sequence

1

No.

678

—_—i(‘(itsistes—COS Sheet _ programmer

4

11 12

20

25

BOA LOR os

30

40

45

a | pot tL Bee Ge areneR LOAU

orm RECORDS “OMITTED | BAS beg RD

|S}

be

RECSIN,

immliwnibeesinestes Notice that the full stop comes description.

ee

only at the end of the

file

The statements, Label Records Omitted and Data Record Is, are

required by the Cobol Specifications but can be omitted in ICL 1900 Cobol. We shall continue to use them throughout the text. 16

50

Question Spawn, the Ornamental Toad breeder, keeps a master file on cards of all the varieties raised on his free range toad farm.

Naturally, all the programming at the farm is done in Cobol, and it is our task to describe the master file in the File Section of the Data Division.

Start the Data Division by writing the file description; call the file TOAD-FILE and the data record TOAD.

17

Answer

ee

co . e Ce program sheet Sequence

No.

pesremmer

N

| |FIUK SEQTION a

eee

work

vies

vite

setae

ail

rrr

ty

i ees

Pees

iad

So

)

on

J|

Y LILABEL, REGORDS OMITTED |... |.,.,1...,1

ipars

RECORD

IS| TOAD.

Record Description The file description is followed by a description of each kind of record in the file. Every record in TOAD-FILE has the form:

Name

PISEEe. ;

Each record is made up of a number of fields, some of which contain sub-fields. A field which contains sub-fields is called a group field, a field with none is called an elementary field. Every field in the record is given a data name in the record description. Although the computer attaches no signifieance to data names, a program is usually easier to write and understand if the data names are descriptive.

19

So that the compiler can work out the relationship between the levels of data, every field in a record is given a level number in the range 01 to 49. A record is always given the level number 01.

ICL

COBOL

re ee a a

Sequence 1

ge

program sheet | erarammer

No.

4

6

8

Pip r2

15

z0

25

DATA DIVISION. vets Pas FTE SEQTION

30

35

40

tall Pee 1

45

ee

FD | [TOAD-FILE ein Poben (ee br | J ILABRL RECORDS |OMITTED, |... |... | ones DATA RECORD IS TOAD. itQAD Sec eee fra ParerareBrsvoreee| Add this to your coding sheet.



The main fields in the record are given in a higher level number.

91

TOAD

Catalogue

Col

Quantity

are given a higher level number

than their parent

Nene

bbe

Number

Sub-fields fields.

Colour

Quantity

G2

1

Name

62

O54

O5M|

BOS

705

|

05

Level numbers need not be consecutive but all the fields at the same level must have the same level number. 21

When we write the data names and level numbers on the coding sheet it is usual to indent the sub-fields to show the logical structure of the record.

° n

26 1

BOL | 5

sheet

programmer

a) o i ° 6

ime fee

z

15

20

{ DIVISION.

25

30

Sede |-RTUE SECTION Joie

|

title

program

| (FD | JroaD-FILE

f...../[,,]]LABBL

pp

REGORDS

EAS RECGRD

Fee ae

35

irl. tote

le

OMITTED

at sea UP ieeep eg sspon

Poe SAD Gean eet a B2 ee a2

ee et: hale

Ea wal eae

ae ;

ee

|

|

EEOC A lewd BE mond QUANTITY J a a B3| MAX nee oe eee

2

|

ae

IN

Write this on your coding sheet before continuing.

NN

50

IS TOAD.

Poauecld bess Jonel ins Sree ptt| 2 NAME COLOUR

45

||.,,.1,,,,1...,]}

OAD

B22

40

|

Our description of the record is not yet complete. So far we’ve said nothing about the size of the fields or what kind of data they contain.

Here again is TOAD of TOAD-FILE, this time showing the size of each field and a typical set of data.

Catalogue Number

ia

Colour

Quantity

Name



chars.

23

To describe a record we add a clause, The Picture Clause, to

each elementary item. The sum of the elementary items gives a description of the complete record.

There are three kinds of fields in Cobol, numeric, alphabetic and alphanumeric. An alphanumeric field can in fact hold any character from the set given in Appendix B. An alphanumeric field is shown by the letter X and since CATALOG-NO is alphanumeric and is six characters long, the Picture Clause is: OAD eee lib |LE.| 2 CATALOG-NO FRE Tn

IPIGTUIRE XXXxxx

To save writing six ‘X’s you can write the number of ‘X’s in brackets.

D CATALOG-NO Add this to your coding sheet.

N >_>

|PICTUIRE

X (6)

Question An alphabetic field holds the characters from A to Z and space and is shown by the character A. A numeric field holds the characters from 0 to 9 and space and is shown by the character 9. Before continuing try writing the Picture Clause for the other elementary items. Then add a full stop to every line of the record description.

25

Answer

°

COBOL

n3 e ® 3 ° ® 7 ° ~

title

program sheet _ prcarammer

|

4

By

7

a

|...|

111,

o>

bir

15

20

25

PAM DIVISION.

30

35

40

45

fue sasbharecnd 0b

PRIUESEOMION partial aaitin oodoiments oapM ot

||FD | oaD-FIL

sth. LABEL, RECORDS DMITTED | || PATA) RECORD IS| TOAD).

PE SSE ET SaeL

|. td. | B2, CATALOG-NO. ee |Se eNaME

PICTUR PICTURE,

: A(|2).

oe

PICTURE

A({7).

PICTURE, PICTURE,

A((7).. A({7)..

PICTURE PICTURE

99/9, 99/9.

|Rae)

ee

hea

eecpieuRe acHeAD

eran] |Re Mo snon | ttt]. 63) spors

| tT.| B2 QUANTITY.

DAP TAR aie enon | AL MEAS MIN

bepress: |Yom

N an

50

ead Berne ewe oeee Perey reer

Filler In many programs, some of the items in a record will not be referred to in the Procedure Division. When this is the case you need not give the item a data-name but can simply call it FILLER. For example if the item NAME in the record TOAD going to be used by the program you could say:

CITE

was not

neeGe

|... {1.1162 CATALOG-No |PICTURE X((6). | TT 2 FILLER PICTURE, X(|2).

ees |||CT

Lois fel resarcsec calle rl

It is customary to give all Fillers an alphanumeric picture. The item need not be an elementary item. If, for example COLOUR was not going to be needed either, you could replace both NAME and COLOUR by:

fegd a P2 oad P2

FILLLER

| | | G3] MAX

Peau Poor

PICTURE,

X(#1).-,|

|

QUANTITY, O3|

MIN

PICTURE,

99).

PICTURED

99D.

CiLecedige aioe

27

bos.

In the record TOAD we used only the first 53 of the 80 character positions on the card. With input records, it isn’t necessary to refer to the unused character positions at the end of a record.

But with some models of line printer the record size must be the same as that of a line of print. And so, if your print record is 90 characters long and it is being output to a line printer with 120 character positions you must add a filler of 30 characters to your record description. Always do this unless you are sure that your program will never use a line printer which requires a filler at the end.

This rule also applies when your output is to a card or paper tape punch.

28

Question

A typical record from the file STATISTICAL is shown below. Before continuing try writing the complete File Section of the Data Division for this file; the date of birth is not needed in the program.

Name

}first first nome nome

|

Date of Birth

surname surname

fay

Social

year|“Numbe ontyeor| Number

iE

ee

When writing the description of the elementary items you can abbreviate PICTURE to PIC.

29

Answer

COBOL program sheet Sequence

No.

4

4 1112

FIUR

25

DIVISTON.

30

35

40

AME

$3 FIRST-NAN $3 SURNAME $2 FIILLER P2 SOCIA =—SEC NO

45

50

wrt redmeters Pye

SEQTION,tet Fag iy Oren STANISTIGAL | __ Pee re LABEL REGORDS OMITTED Lod DATA) RECORD IS RECA, | i) 2

PIC PIC PIC PIC

AO). Al( 20). aa . x(8). |.

|

Ww°

ttle ecsremme:

eS

Ee |

;

The Procedure

Division

In the Procedure Division we write the statements to process the input files and to produce the output files. Let’s say that in the Data Division of a program we have described an input file CARD-FILE and an output file PRINT-FILE.

31

The Open Statement In Cobol, each file in a program must be opened before it can be used and closed when it is no longer needed.

To open each file we write an Open Statement which has the form:

LJOPEN INPUT CARD-FILI abe dl| | |]. | IOPEN OUTPUT PRINT-FIILE lea The Open Statements can be combined:

OPEN

INPUT

c

-FI

OUT|PUT

PIRINT-FI

The actual effect of the Open Statement depends on the kind of file. If, for example, the file is on punched cards, the Open Statement causes a message to be typed telling the computer operator to load the file onto the card-reader.

32

The Close Statement When the files are no longer needed they must be closed.

|. |ICL OSIE CARD-FIL | ||GLOS|E PRINT-FIL

ESeed Read

|

er Labsaeueauwd

Or, in one Close Statement.

CLOSIE

c

-FILE

PRINT-FI

Again the effect of the statement depends on the kind of file but in all cases the file cannot again be referred to in the program unless it is re-opened.

33

The Stop Statement The last statement executed in a program is:

Fuvewt OTTuOUTORE 7:7 Dum poneSee which suspends the program and checks that all the files have been closed.

34

Sentences and Paragraphs The statements in the Procedure Division are grouped into sentences, a sentence being one or more statements terminated by a full stop. In a simple program the programmer divides the Procedure Division into a number of paragraphs containing one or more sentences. Each paragraph has a paragraph heading and the names the programmer chooses for the paragraph headings must follow the same rules as other data names except that they need not contain an alphabetic character.

If the paragraph name is numeric it must not contain a hyphen.

35

Here is a complete Procedure Division which opens and closes the files and stops the program.

ePIC sheet _ v:ogrammer

ICL 1112

15

20

25

30

35

PROCEDURE DIVIS.LON. ror MDE CLOSIE

CARD-FILE

45

Ps eh

INPUT CARD-FILE

Fede ST.OP| RUN. Dede

40

OUTIPUT

ee

PRINT-FILE.

PRINT-

Without altering the sense we could have put a full stop after the Close Statement, making PAR-Z contain two sentences.

3 fo.)

50

Question Write a Procedure Division which opens the input file OLD-IN and the output file NEW-OUT, and then closes them and stops the program.

37

Answer

4 1112

15

PROCEDURE

PE

20

25

DIVISION.

30

PUT OLD-IN OUTPUT,

35

40

45

50

NEW-OUT..

CLOSE OLD-IN NEW-OUT 0 P|} RUN.

fae Graven brdboriral bares’ barony. bmene Lic!

The Read Statement Once an input file has been opened we can read a record into store with a Read Statement which starts: Sequence

No.

1

aa

||

4

jhe 72

67

att

15

20

25

30

35

40

45

50

O}GE DURE, DIVISION. \2

PARHA

Mean PE

|....| PARMB.

INPUT CARD-FILE

Yt| READ! CARD-F.ILE)

perenne

OUTPUT,

PRINT-FILE.

AT__EIND

|

In Cobol every file must have an end of file marker. On the 1900 series for example, the end of file marker for card files is a record containing four asterisks ****. Every time a record is read into store the computer tests to see if it is the end of file marker. In the Read Statement we must include another statement telling the computer what we want done when the end of file marker is read.

39

The Go To Statement The Go To Statement tells the computer to go to the start of a specified paragraph. If we want the computer to go to the paragraph which closes the files when the end of file marker is read, the statement is

G0 TO PAR=Z Sequence No. 1

r

6 A

11 12

Ewereu

P|ROGE DU

eer

aibeavOPe

|

PAR.

15

20

D

25

30

35

PUT,

CARD-F

2

ILE,

tT|IREAD) CARD-FILB AT, EIND

OUTPUT

45

LOSE, CARD-FILE, STOP| RUN.

PRINT-F

PIRINT-

-

GOTO PAR-z.

/



40

SION.

Ii

Question Here are two paragraphs from a Procedure Division. Sequence 1

No. Bt

8

11 12

15

20

25

30

3

Write a paragraph which will read the input file and go to the paragraph which closes the files when the end of file marker is reached.

4I

READ!)

OLDAIN,

AT

D,

GO, TO!

FINIS

Did you remember the full-stop at the end of the sentence ?

42

The Write Statement When the computer is reading a file it can only read the next record in the file whether or not there is more than one type of record, and so you need give only the file name in the Read Statement. But when we write to a file it is the program which decides which record is to be written and’so we give the record name in the Write Statement.

The file description in the Data Division tells the computer which file the record belongs to. Except when output is to the line printer this is all there is to the Write Statement.

43

When output is to the line printer you must add a clause to the Write Statement giving the line spacing.

ITIE

P

Toh

FTIER

ADVANCING

INES

Or simply:

|

H: Wal. PRINT-REC AFTER 2

:

Similarly you can print the record before moving forward.

[TIE

PRUNT-REIC

BEFORE

1

That is, write PRINT-REC before advancing one line.

)

:

Question 1.

Write the statement which advancing three lines.

2.

Write the statement to print REC-B lines.

will print out REC-A

before

after advancing two

45

Answer

RIT

EC-A

BEFORE, |3

* Spacing of more than two lines produces a great deal of object code and is to be avoided wherever possible.

46

The Paper Control Loop Instead of line spacing records we can print a record on a specified line of the page, say line 16 by using the Paper Control Loop which is always present in the line printer. A Paper Control Loop is simply a piece of plastic tape whose length is the same as that of the individual pages on the printer. There are seven channels on the Paper Control Loop and there is always a hole punched in Channel-1 corresponding to the first print line of the page.

47

If we wanted the record HEADINGS of a page we would say:

ITIE

HEADINGS|

to be printed at the top

AFTEIR

CH

EL-|1

Similarly if there were a hole punched in Channel-2 corresponding to line 30 we could print HEADINGS on line 30 by writing:

LTE,

HEADINGS|

AFTER

CH

EL-|2

As with line spacing we have the option of writing either BEFORE or AFTER.

48

Question Here is a printer with the Paper Control Loop already punched.

What would the Write Statements be to print TITLES on line 1 and SUB-TITLES on line 12 and CONCLUSIONS on line 35.

49

Answer

RI

TITLES

AFTER

ITE AA

CONCLUSTIONS

CHANNEL-1

ITE, SUB-TITLIES AFITER CHANNEL-3, | |

liewars Aree

50

AFTER

Al MePa

|CHANNEL-4

Ne

The Special Paragraph

Names

One of the aims of Cobol is to make programs as machine independent as possible. That is, a Cobol Program written for one machine should be able to run on a different machine with as little alteration as possible. Channel-1, Channel-2, etc. are not Cobol names but are peculiar to the ICL 1900 series. If you don’t want ICL 1900 hardware names in the Procedure Division of a program you can substitute a name of your choosing, say NEW-PAGE for CHANNEL-1 and then add a paragraph, the Special-Names Paragraph, to the Configuration Section of the Environment Division.

SI

program sheet sss

ICL —

i

an

V2

15

|... | ENVIRONMENT,

20

25

DIV.ISTON.

30

|... | (CONFIGURATION SECTION. |__| JSOURCE-COMPUTER. Seen Ten rots.

35

40

|

lis

45

50

|... | PBJIHCT-COMPUTIER.

1

tt. |

ich1943

fog MEMORY 1600 WORDS. T ,. | ISPEICIIAL-INAMES|. tf LICH ANIMEL-1| 1S NeW-Pal tt| ICHANNEL-3)

1S UINE-1/2.

Po

1S LIINE-35.

tT

ICHANNEL-4|

| _.,. | ItNBUT-oUTPUT |SECTION. ees | Nt

SUB|-TITLES.

|

AFITER,

LIINE- 1|2

|

RITE, CONCLUSIONS, AFTER LINE-35___ | | beware ararea brew a Wor CU Let ire cl

52

Question Write the Special-Names Paragraph to give Channel-1 the name START-PAGE and Channel-7 the name LAST-LINE.

a8)

Answer

|... | SPAGTAL-NAMES.

Pt | ICHANNEL=1 SITARTAPAGE.|...1....1,. TS, 41

| [|

Deron [es

54

JCHANNEL-7|

IS

|

UAST-LIINE.

The Move Statement The Move another.

|

Before

After

Statement

is used to move

| | Move ONT

|MONTH-IN

data from

one

field to

10 MONTH-QUT,

IS[E]

P| T/E [M/BIE

|,

[R|

MONTH-OUT

= [Q| X/Q/ XQ] X]Q/ x]X|

MONTH-IN

T[EIM BlE[R IS{E] P{T|EM/

|

MONTH-OUT

M [S[E[ P|T[E|M[B[E[R|

That is, after the Move Statement has been executed the sending field is unchanged and the old value in the receiving field is lost.

ob)

|... |

The following rules apply only to alphabetic and alphanumeric fields.

If the source field is shorter than the receiving field the contents of the source field are moved into the left-hand end of the receiving field and the remaining character positions are filled with blanks.

OVE

ar

-IN

1/0

-OUT

NAME-IN

LJ TE [NIN] Y|

NAME-ouT

LJJEININ[I[FIEIR |

erore

Re

NAME-IN NAME-ouT

—_ [JLE[NINTY] [J[EININTY] | J]

If the source field is longer than the receiving field the extra characters are lost from the right-hand end.

56

Question Write the Move Statements for the following and show contents of the receiving fields after the Move.

ASSEMBLY

CODE-NO

the

[BiX/6[3[2]5 |

—-

LBILTATNI KTS]

TREE-IN TREE-OUT

LE} L |M| LSTYIC[AIM[O[ RIE]

MASK LAST

fe [*[*] ele] [+ | IN [AIM]E|

y

Answers

OV

SEMBLY,

CODE-NO-

OVE

TO

TREE-OUT

= {Ey UIM)s) opi SK|

TO

T

LAST — [# «|| *] *]

58

=

[B[X]6 [3] 2]5]

OVE] TREE-IN TREE-OULS

[TO, C

A single Move Statement can be used to move the contents of a field to a number of receiving fields.

OVA MASK TO GODE-NO FIBLD-A \NAME| banat ali cpr rea

The receiving fields need not be of the same size and the result of the move will be the same as if a separate Move Statement had been written for each receiving field.

oy)

Literais The Move Statement can be used to fill a data area with a string of characters. In Cobol any string of up to 120 characters (excluding quotation marks) which is bounded by quotation marks is regarded by the computer as a non-numeric literal.

OVE)

“UP

|TO

12¢

Cc

CTERS”

Ti0 LIT-1

Again, if the literal is smaller than the receiving field it is moved into the left-hand

end

and

the remaining

character

positions

filled with blanks. If the literal is larger than the receiving field the excess characters are lost from the right-hand end.

60

80

Identification

4

AME

Cu WOME Suet

Here is an example of a literal which has been extended over two lines. Notice that the continuation line has a hyphen in column 7 and opening quotation marks and that there is a closing quotation mark only at the end of the complete literal.

» 60

55

50

Tic ae de ele LL eee | eee ae

45

a

A.)

Yn |

a eueE A a)

=)

J

ee|

=a

8

|MOVE) OF |. THE |GROW;| [THEY HOW "CONSIDER LILIES, FIIELD,| |THE, THE, PLES NOT,| NEIT 61

No. Sequence

If we write:

OVE

ALL

“ICL

41993"

10

SLOGA

then the Literal will be repeated until the data area is completely filled.

Cobol allows you to fill a data area with spaces simply by writing

|

}

iHeNE SPACES

ee Bec

:

vol :

In all cases the type of Literal you move to a field must agree with the field’s description in the Picture Clause. We shall deal with numeric literals later on.

62

Question

Write the Move Statements 1

To give HEADINGS

the value HEADINGS.

Po

To fill the 120 character field PRINT-REC COBOL.

with the literal

To space-fill BLANK-REC. To fill the fields GOLD, letter S.

SILVER

and PEWTER

with the

63

Answer

OVE|

"HEADINGS|"'

OV.

OVE|

TO

"COBOL",

SP

HEADIINGS

T

5. FOcCRE

INT

-—

-

eed boc.) OVE|

ALL

|"S"

TO

GOLD

SILVER

PEWTER

Fawbrirareee) (ae oy

64

Example Orders received at Mollusc Oil Supplies are punched into cards and we have been asked to write a program which will list each week’s orders. Our computer is an ICL 1902 and there are 5000 words of core store available to the program.

Start the program by writing the Identification Division, giving the program the name FUEL and a priority of 50. Then write the Environment Division, including in the Configuration section a Special-Names Paragraph which gives Channel-1 the mnemonic NEW-PAGE.

65

Answer

| eisai

ICL Sequence 1

No.

4

Grits

11 12

15

355

Loe

FUEL59.

ae

“ee

1

6

7

11 ‘

LS

40

20

25

ENVIRO T DIVISION, CONFIGURATION SECTION,

50

Ai syed Poe

Tijesk

30

35

40

45

50

i ae sae a ee ey

ICE ~QOMPUTBR 6 tei a | ae GUA9 Boel

Uf

45

pee |

Fe ae

ee

aes

ee

Pe

ee

CT -COMPUTIER,.

CL4190 MEMORY,

aaa

pee 5€4@@ WORDS.

AL

owas

Hs NNEL=1l TS, IS NEW-PAGE... |... 1.1... |

T-OUTPUT

= Z vu tes

L

[ez

|SECTION,

— CONTROL. Ee eee SELECT, CARD-FIILE, AS|SLGN, CARD-READEIR 1... | SELECT, PRINT-FIILE ASSIGN PRINTER, ee Le ee

Make sure that you have Environment Division.

a6

included

all the headings

ll.

in the

|

Input Each card in the Input file has the form:

Account

Discount

{Quantity

Code

{Ordered

Customer Number

a aan

a Start the Data Division by writing the complete description for

the Input file. The discount code is not required on the print-out so you'll be able to use the option Filler for this item.

67

Answer

n ® re}Ee ® ro 2) ® cA ° ~

a

o>

1112

15

20

25

30

35

40

DATA DIVISION. Zz. ] SEQTION, | | FD | [CARD-FILB | | | |LABEIL, REGORDS |OMITTED | | DATA) RECORD IS| CARD-REC.| 1 | |CARD-REC. | | {62 AICCOUNT-NO Pic X(7|). | | |92 GUSTOMER PI A(1|5). | | {02 FITLLER PIC X(6j). | | (2 QUANTITY pea aaa abe ine ae ie em ies) => ult [ver ewe 2 ean

PIc

45

socal | |

999/99.

elas Cho eee

50

S

Output There are two kinds of record in the Output file:

Alciclolu[n[r] | [cluls[rfo[M[eyRy | ese JSS SRR aS ieisiolol| ee

HEADING

LIST-OUT

2| alate

led

The only change in the file description is that you now say DATA RECORDS ARE instead of DATA RECORD IS. In the record description of HEADING describe the whole record as an elementary field of 120 characters and we can then move the literals into the field in the Procedure Division.

In the record description of LIST-OUT keep the fields the same size as on the input document and supply the spaces with the option Filler. Although you can in fact give the fields the same names as those on the input file distinguish between them, perhaps by adding -0 to each name. In all our examples we shall assume that the line printer has 120 character positions.

69

Answer

| ....| FD |

| TT. . | JUABEIL,

PRINT=FI

RECORDS,

| | |. | DATA! RECORDS. | «|1. | (HEADIN

(OMITTED ARE

HEADING LIST-OUT. PIC A(1|\20).

|... |Bl,| LTSTOUT..

| = sd |. | (2, ACCOUNT-NO-O | PIC

X(7)).

eet Seat Ser Ce | TT.| 2, CUSTOMER-O Ile Bea Waert EER

Pi PIC PIC

oe A(1/5). XX.

2) | a ee OUANTIT Yo

Pic

99989,

eas Eeerud ibe

FELeer

PIC

X(90)..

Now try writing the Procedure Division from the flowchart.

Open Move

Files literals

to heading

Read input record

End of File

YES

marker 2

ap

ah a nd SNOT ee re taees J | + ja

TEINISH

!WRITE-OUT } ! | | I | | } |

Move

input

to

output

Write

record

Close

Files

| | !

| | I | |

| | | |

If you are unfamiliar with the standard flowchart symbols turn to Appendix C before attempting to write the Procedure Division. Wat

Sal

CL Sequence

sheet

sith

40

45

No.

(3

ll ¥

-—T Prod DURE DIVISION.

|. |START.

30

35

tS

50

eee

- Wieeea Ca

__. | 1..| OPEN INPUT CARD-FILE OUTPUT, PRINT-FILE a __ | MOVE] "ACCOUNT | CUSTOMER QTY" pl O, HEADING ieee RUD EAIDING |AFTER| NEW-PAGE.| __, |

||

|

| READET |. L.|IREAD! CARDI-REC, |AT, END, GO, 0.F.INISH.|..| pag sou, Pewee Wer FETE Breen! | ss [|... | MOVE] ACCOUNT-Nb. TO. |ACCOUNT-NO-O eeapeas || Gees a CUSTOMER [TO CUSTOME|R-O | | | | MOVE] QUANTITY [TO QUANTITY-O | ss ||. | WRITE LIS|T-OUT| AFTER 2

PTE To, 70.READ=IN. PTF rnin, Yt}. | CLOSE, CARD-FILE

WORM

PRINT- a

Pe Ua BTORURUN.| Hl ovenbee Eeenll

—N

l

eee

|

Storage Allocation When the compiler is allocating storage to a program’s files, each file is given only enough storage to hold one record . This means that if a file has, for example, two kinds of output record each will occupy the same area in store. In the program we have just written, PRINT-FILE had two kinds of records, HEADING and LIST-OUT and we started

the program with the statement

This moved the literals into the left hand end of the file’s record

area and space filled the rest.

ACCOUNT

CUSTOMER

Orley

HEADING

And

this in effect is what the record LIST-OUT

start of paragraph WRITE-OUT.

ACCOUNT ACCOUNT-NO-O

CUSTOMER CUSTOMER-O

held at the

Only Frfawn

73

FILLER

We were fortunate in that the three Move Statements in paragraph WRITE-OUT completely overwrote the literals in the record area and gave us the space characters we wanted. But it is safer to assume nothing about the contents of a field before you put something in it and so, immediately before you start moving data to an output record, spacefill the complete record area.

74

Question What difference would it make if at the start of paragraph WRITE-OUT we wrote the statement:

OVH

SPACES

TO

HEADING

peels Lracsoreral instead of:

|

| | :pov SAGES TO LIST-OUT |.

|

7

Answer None, since HEADING same area in store.

76

and LIST-OUT

are both names for the

Qualified Data Names In the program FUEL50 we said that you can give the fields in the output record the same names as their corresponding fields on the input record: ae

ARDGREC

Hee

SI

waitin,

ny ea

CUSTOMER

fl _

Pic

PIC pe

nat ia

[ee

cemeea reas |

peau

ou fall 2

“areaeal

COUNT SNON ee PICEX CU)

PI,

P

Ic

rare

cio

AC,COUNT,-NO,

2 SUS)

SI

Ln

fea eae

ACs)...

|

X(6))

fe

999/99. | a |ned

x(4/8). SiMe

ys

ate

|

aki es bo eared oe

l2G

ae

i

eed OE i]

Re

rai ll ned Ware al

28s

Fes)

A

aia

ESCO SOMER es ene CaN b) eet

Scalia

|

ae [ed

crate

ened

eene

XOXee

OO Ses ee

et

LCE RlReeee ene | Cex (0) ee ens (ae Loci easel Phacae” wed are De eee

but now when we refer to a field in the Procedure Division we

must qualify the field name to show which record it belongs to.

MOVE ACCQUNT-NO_OF |CARDAREC, ,| TO ACCOUNT-NO OF _ LIS T-OUT (ill cinScated Lae Ars Laer DN

TW

WS ee

nad |

We can qualify a data name further. Say we had given both the input and output records the name FUEL-REC.

OVE] QUANTITY, |IN FUEL-REC OF CARD-FILE TO QUANTITY IN FUEL|-REC, |OF PRINT-FIILE | | ¥ | A file name cannot be qualified. Qualifying data names different names but easier to understand.

78

is more long winded than giving fields it will often

make

a Procedure

Division

Question The records REC-IN and REC-OUT both have the description:

PS

Boe STOCKSL

EVER!

ree (tHe Ag eee) eS oan en

te

a

Bavned aPag

Oo sORDERTOTY: @3 @

MA A

ieetare: |iAerie

ls

ee DM Pe ee

Dike Pia dice AMC LEDs chicos, PIC

|999.

Ly

To move the STOCK-LEVEL LEVEL of REC-OUT.

adben, bawad nleawe

Die Cho on dunone lager reyest ha al rare ere

Write the Move Statements: =

eal

of REC-IN

To move MAX in the ORDER-QTY corresponding field in REC-OUT.

to the STOCK-

of REC-IN

to its

19

Answer

=.

|

enh 7

OVE _S,TOGK-LEVEL, OF) REC4IN TO SITOCK4LEVEL| OF REC-OUT

bksva

Epgecbeeas OVE| MAX |... {].. |fro MAX IN

Reeseee fa ae fe

80

id Ee

{IN

ees

ORDER-QTY

ORDEIR-QTY

OF

OF|

5 ee

RECSIN

REC-O

|

ER

|

|

Zero Suppression The first four characters on a card represent a number between 0 and 9999:

|

|

acerJoe TLS

Oo LO

co ee

ec a] ee ae

If the value of NUM-IN is 56, it is punched as 0056.

Similarly, if in a print record we have a field:

2 NUM-OUT

all

PIC

99919.

be acil ie wsdl imre owaat lem allven td Ue nD

a value of 56 will be printed as 0056. In printed output a numeric field generally looks better if leading zeros are replaced by spaces. This is called Zero Suppression.

81

A numeric field which is to be output to the line printer can be edited to give Zero Suppression. If we re-write NUM-OUT’s picture as:

2

-O

IC,

Z4249.

then leading zeros, up to the number of Z’s in the picture, will be replaced by spaces. If we want the field to be completely blank when NUM-OUT has a value of zero, we must add another clause.

2

82

-O

IC,

ZZ

W

Question A field in a print record is described as

TREE

CHO 009998 ewe eee

Re-write the description to give: I.

Zero suppression but with a minimum printed.

2.

Zero suppression and blank when zero.

of three characters

83

ef S|

Answer

Me

2

fnnf Tie INA #22229 BLANK) WHEN ZERO... | ee

|

get

tae ee ede

Seite

bares

ee

1

|

ee

ey

ar

You can abbreviate the pictures by writing the number of character positions in brackets

|

182 INT.

Pitc 4(13)9 (S20

2.

pf

84

fiaant Ans a8 BLANK WHEN (ZERO. | Saee l ae

Signed Numeric Values The first field on an input record is to hold a value in the range -9999 to +9999, To show that a field contains a signed numeric value we start the picture with the operational sign ‘S’

92

NUM-IN,

Plc s99 |.99. |... 1... |

If the value on the card is positive it is simply punched in the first four columns. If it’s negative the absolute value is punched in the first four columns and the minus sign (11 on the 1900 card code) is overpunched on the first digit.

85

That is, the left-most digit is altered to a non-numeric value.

-1 -2 -3 etc.

becomes becomes becomes:

J K L

(11/1 on the 1900 card-code) (11/2) (11/3)

To show that this is the way a negative value is held we add the clause DISPLAY to the description.

ee

a Pe NUM-AM. _ PIC $9999 DISPLAY. ||... pate aya i

86

|

Overpunching the first digit is the usual way of representing negative numbers but the minus sign can be punched in a separate column. The picture is the same:

|.

|| |2 NUM=IN Pc so999 tt |

But now we add the clause DISPLAY-3.

|

!| :Pa 2 NUMGIN __ Plc $9999, DISPLAY-3...

1.

|

|Oieemrene See Beh Sve rene ee nie|e Oe Send A full list of Display Clauses is given in Appendix D.

87

© he =ptw -pees mer

4 134

8c

-64~ tube wd ate.

nso eg

.

20

ML nou tus elas

:

ia? vg reap seme © v

* 4_

>

ee et He ; =

e-

we

Sta

i bin ow

oe iat



88

7

Question I.

The first column of a card contains a character either from

0 to 9 or from J to R. Write the description of this numeric field. 2.

The first two columns of a card contain a signed numeric value in the range -9 to +9. Write its description.

89

Answer

I

2 INTEGHR G2 INTEGER

PIC S9 DISPLAY.

|

PIC S9 DISPLAY-3.|....1,.., | Be

|

nN

* In fact, since this is the normal way of representing data, Display will be assumed by the computer in the absence of a Display Clause.

90

|

|

Output of Signed Numeric Values We don’t use the operational sign S with printed output instead we use the report signs ‘--’ and ‘-’,

A field in a print record is to contain a signed numeric value

between -9999 and +9999,

If we describe the field as:

|

tH ®2NUM-OUT Ple +9999.) Td EN BSA ate ailtine nt\/P scl) ordSlikturee wileWssee | Poe |

the sign will always be printed, that is 1357 will be printed as +1357 and -1357 as -1357.

But if we describe the field as:

2 GLIOMA

oan.

Lele eoee nea

a value of 1357 will be printed as simply 1357, that is the plus sign will be replaced by a space.

OI

Both the report signs can be used to give zero suppression and to float the sign. If we say:

2 NUM-OUT

PIc

-99/99,

then -23 will be printed as -0023. But if we replace the leading 9’s by minus signs

j

2

SOUT.

PIC SSee Sei Bel Tee | ee Rene were Lavin OPP

a value of -23 will be printed as:

-23

Notice that you need one more report sign than the number of zeros suppressed.

92

Question 1.

A three digit number is to be output to a line-printer. If present the plus sign and leading zeros are to be printed.

2.

‘The same number is to be output but the plus sign and leading zeros are not to be printed and the field is to be blank when Zero.

Write the descriptions for these fields.

93

Answer

Bet ae aco ses ee

Pa

2

94

INTEG

PIC

---9

er

re

er

BLANK

WH

ZERO.

Decimal

Fields

So far we’ve dealt only with fields holding intege r values but Cobol can of course handle decimal numbers. The decimal point is not normally punched on an input document and we must show its implied position in the picture of the field. A three character field on a card holds a value between 0-00 and 9-99.

The character ‘V’ indicates the position of the decimal point and it can, if needed, appear at the start of the picture.

95

Output of Decimal Fields Naturally, when a decimal field is to be output to the line printer we want the decimal point to be printed. A field containing a value of between 0-00 and 9-99 is to be printed out.

2 DEC-OUT

-PIt

SV.9.

The decimal point is an insertion character which can be placed anywhere in a picture without altering the size or value of the field. On output it will be printed in the position shown by the picture. Since the decimal point has no effect on the value of a field, we still need the ‘V’ to show the computer the position of the decimal point.

96

Question A four digit field on a card contains a value of betwee n 0-00 and 99:99, Write the description for this item. A decimal value in the range 00:00 to 99-99 is to be output to the line printer. Write its picture. The characters ‘S’ and ‘V’ can appear in the same picture. pp p 3.

The first column of a card holds a value of between --1 and

-9, What is its picture?

Describe the output field when a value of -:1 to --9 is to be printed.

oi,

Answers

2,

oh

Me lalades

PAMIBE RAMDESNUSM Farle carers card iver BO ULTIPLY, |6 BY U || | DIVIDE 2 |INTO, Dp ||. | ADD B Cc TO D

db

132

The Giving Clause In all the Arithmetic

Statements so far, one of the values was

destroyed to make way for the result. We can keep all the values unchanged by adding the Giving Clause to the statement.

ADD IA B GIVING Xx SUBTIRACT [A FROM, B, GIVING x ULT|IPLY |A BY GIVING xX DIVIDE A |INTO GIVING xX

Notice that the ‘TO’ is omitted when the Giving Suet is used with an Add Statement. When you use the Giving Clause the receiving field can be either an edited or an unedited field.

133

The Rounded

Clause

The rules for arithmetic are the same as those for moving numeric data. That is, if the decimal part of the result field is too short the result will be truncated; if the integral part is too small the most significant digits will be lost. You can mitigate the error caused by truncation by adding the Rounded Clause to any of the Arithmetic Statements.

Se

U

DIVIDE

tle

B |INTO

IVING|

ROUNDED

X ROUNDED

Sener (8s The result will now be rounded correct to the number of decimal

places in the receiving field.

134

The On Size Error Clause If you suspect that the receiving field may not be big enough to hold the largest result possible, you can add the On Size Error Clause.

ULT

Y

Y

ON

SIZE

[ERROR

Following the On Size Error Clause you add a statement telling the computer what to do if it finds that a result is too big for the receiving field.

TO ER.| [MULTIPLY[ABY(8ON SIZE [ERROR Co,aduae s ‘a Logodbeswdle pubwmbobeo “lik dug:

135

You can use any or all of the optional clauses in Arithmetic Statements but you must keep them in the order shown.

136

Question Write the Cobol sentence for the following calculation. result is to be rounded and placed in NUM-OUT.

The

-3:596 NUM-IN If NUM-OUT

is too

small to hold the result branch

to the

paragraph MISTAKE.

137

Answer

138

Error Stops The paragraph you branch to when an “on size error’’ occurs will usually be one containing a statement telling the computer to stop the program. Instead of writing STOP RUN which you use when the program has run successfully, you write STOP followed by a literal which can be either numeric or non-numeric.

If the statement STOP 555 is executed the program will stop and display 555 on the operator’s console typewriter.

If you have several Stop Statements in a program the literal will tell you which statement the program stopped at.

After an error stop has been executed the operator can restart the program at the next statement.

139

It isn’t in fact necessary to branch to another paragraph following an “on size error”, you can simply say:

DD

140

TO

|B ON

|SIZE

ERROR|

STOP|

666

Example In an office block each room has the shape:

We have been asked to write a program which will calculate the total wall area of the office block excluding doors and windows.

I4I

A card with the following information is punched for each office: COL. COL COL COL COL COL COL

Es 4— 6 7— 9 10—I1 12—13 14—15 16—17

length height width door—height door—width window—height window—width.

All of the values are to one place of decimals.

And a typical output on the line printer is:

BERR ES EREE EMER REaSaaES IN[O[ [O|F] [RjojojmM(s| | JAlv[ [ATRIE/AT | [TOlrjAley [AURELIA BERRA ee Oe Asa eEaRaeaL. rato] | | ay aie tops pepste pst fy ts]2),16) 9)7 ae OERRERELAaEE SERRANO

142

Question Don’t bother this time with the Identification and Environment

Divisions; start by writing the File Section of the Data Division. On output the maximum number of rooms is 99, and the maximum area for the average and the total is 999-9 and 999,999 sq. tt respectively.

We want zero suppression on all the quantities.

143

Answer

waa

ON

Se

oe

ICL

AD

inn

aaa

Earn Sheet = vegramme: 4

1

Oi

il 12

at

po)

TA

15

20

25

DINTS LON. 0s

30

eee

35

40

ere

eel

45

50

1a

BETDE ASEGT LON “ere ieee eer)|e

eomen

FETRAsE,Rees punt} LABE|L RECORDS OMITTED DATA)

RECORD

IS;

oe 2ereNcTE ee||| e SOE CAT ‘|. .| 02 WIDTH|

PIC 99V9. PIC 99V9, PIC g9vo. PIC j9V9, PIC 9v9.

||. | 2 DooR-H Snr ir Ye tL. 2 WoN-H |} Pe IN-W

|

ES

REC-IN,

|

PIC v9. PIC . pvo.

PRINT-F ILI

a

LABEL, DATA)

RECORDS RECORDS,

OMITT AIRE

HEADING!

COMP-REC,

"> Bee

OMP|-REC..|

0 2, NO-OF

D2 AV-RB xo No

= _ |a, ee ies]

Ss

ae See2

4ROOMS|

iS

ohn.

PIC

Pa

a

ae

|z9.

L, Shay)

| PIGMZOV.B. PIC

k(4).

iit l@2 NOTAL4AREA | PIC |222, 429, PEEEEEEE PREP EE aes Dol ESS a ie

I

4

Se

1... |

Here is a flowchart showing the steps in the Procedure Division.

Open files move literals to heading

write

heading

| READ-IN

at Read

input

record

End

of file

marker ?

Calculate area of room

r BRINT-OUT

| | | | | | } } | |

Move

spaces

to

comp-—rec calc average area move

values

to

comp-rec

|

| |

Add room area to area total add one to room total

| | | | !

| }

Close

files

|

| | I |

| | | {

START Start the Procedure Division by writing the paragraphs and READ-IN.

145

Answer

ICL

Nai

Sequence No. 1

4

67

8

11 12

15

Jee GEDURE START

20

25

DIVISION.

epepel cys vile

30

35

|.

40

45

Liat ot

50

1 wea

||, | JOPEN INPUT CARD-FIUE OUTPUT PIRINT-FILE | of MOVE "NO |OF ROOMS |AV AREA |TOTAL |AREA" TO

ge) ey

ge

eae

be

oe

HEADING

RITE HEADING |ARTER CHANNEL-l|.. |... |

READ AON). ead

I - nN

READ

2 sl ele AT

CARD-FILE|

BEND

oh

GO|

TO

aa

PIRINT-OUT.

fra eee es

In the paragraph AREA-CALC we calculate the wall area of each office.

write the statements

to

The total area of the walls, including doors and windows is given by the formula: 2(height x length) + 2(height x width) which can be reduced to:

2 x height (length + width) Before we can write the Cobol Statements for this calculation we

must reduce the formula to a series of simple steps. 1. 2. 3.

Add length and width. Multiply the sum by height. Multiply the new sum by 2.

147

In Cobol this can be written as:

-CALIC. |. ADD, LENGTH, WIDITH GIVING, § ULTIPLY HEIGHT BY SUM Fea | | MULTJIPLY

badd

|2 BY |SUM.

We have described LENGTH,

HEIGHT

and WIDTH

in the

File Section of the Data Division, but so far we’ve said nothing about SUM. When in a program we need data areas to hold intermediate values we add another section, the Working-Storage Section, to the Data Division. A quick calculation shows that the maximum value of SUM 999-99 so its picture is 999V99, RKJIING-3STORA|IGE Creede TTT v7 Sum. PIC

is

SEICTION,

99)9V99

ees ical Simple data areas in working-storage are always given the level number 77.

148

The Computational

Clause

Numeric items in working-storage are held in the best form for arithmetic if we add the clause COMPUTATIONAL to the field’s description. COMPUTATIONAL can be abbreviated to

COMP.

Leeaa blWORKKIING-STORAIGE

|

dT |

beamed

77, SUM,

SECTION,

PITC 99)9V99

|COMP.

Add a Working-Storage Section to your program before continuing.

149

The Synchronized Right Clause If you are writing Cobol programs for the ICL 1900 series should add the clause SYNCHRONIZED RIGHT to description of arithmetic items in working-storage. This position the item in the 1900 word in the most efficient way fast arithmetic. The clause can be abbreviated to SYNC

you the will for

RIGHT

INGS,TORAGE SECTION. _ | | 77, SUM, PTC 999V9 COMP SYNC RIGHT.) | Lo gsL Se ey 1 ee If you are programming another machine or if you are adapting a program which contains the SYNC RIGHT Claus e refer to the appropriate manual before using it because it is only useful on some types of computer.

It won’t be used again in this text.

150

Question Here is the paragraph AREA-CALC so far:

ARE|AI-CAL(C,, ADD LENGTH WIDTH GIVING ULTIIPLY HEIGHT BY SUM

eau

Pex

| | MULTIPLY, |2 BY

SUM

|SUM.

peas Add this paragraph to your program and then complete it by writing the statements to calculate the area of the door and window and to subtract them from the sum. You'll need two more items in working-storage, call them DOORAREA and WIN-AREA.

151

Answer

|... |ARBA-CALIC..

| |].| ADD [LENGTH WIDTH GIVING | tL. | MULTIPLY |HEIGHT BY |SUM erent) o|Penile MUlLATHT P Vee vane tone |... |]. | MULTIPLY |DOOR4H BY DOOR |... {].. ||GIVING DdOR-AREA. |. LL. | MULTIPLY |WIN-H BY tt. IGIVING WIN-AREA, |... |ft..| SUBTRACT |DOORJAREA

|SUM

WIN-W

WIN-AIREA FIROM,

mie 184

SUM.

Sequence No. i

67

o>

~ ~ —a

15

20

25

30

35

|... | JNORKINGSSTORAGE SECTION. |... t]..|]77, suM BIC 999V99 COMP. |... {|| ]77, DOOR-AREA PIC 99V99 COMP.

pa

152 wn

40

IN-AREA |PIIC 991V99 COMP. |

45

50

|

l

The Value Clause In the next paragraph TOTALS we add the room area to the total area and add one to the room total. The paragraph starts:

eed

|

rom

P|

tee

[cused ead

ADD

SUM

TIO ARE|A-TOTAL.

And, of course, we must describe AREA-TOTAL in the Working-

Storage Section.

|

|

Lf AREACTORA pas KZI¥88 co

Now the initial value of an item in working-storage is undefined, so to make sure that AREA-TOTAL contains a value of zero

before we start, we must add a clause, the Value Clause, to its

description

File Section. The Value Clause must never be used in the

LS and add Before continuing complete the paragraph TOTA ng-Storage Worki the to AREA-TOTAL and ROOM-TOTAL Section.

153

:

:

| roms. PTL.AD, sum LADD it, To PTT. 60. 70_RE Doarallaced T_T T..1 P7 , AREAImad Ifogubacotan: rth PZ, Room necerna|t [Sea Eee ieascdieach

154

O AREA-TO AL. ROOM-|TOTAL|, \D-IN,

OTAL PIC IS ZERO, OTAL PIC IS ZERO,

9\(7)V9I9 Qf

COMP

COMP

Question Now complete the program by writing the paragraph PRINTOUTs

155

ING4STORAGE SBHCTION. 77 SIUM PITC 9919V99 COMP. 7? DOOR-AREA P\IC 99V99 COMP. 77, WIN-AREA |PIIC 99V99 COMP. 77 AREA-TOTAL [PIC 9(7)V99 COMP ALUE, |IS ZEJRO. 77 ROOM-TOTAL |PIC 99 COMP VALUE |IS ZERO.

Answer

=iie = =

DURE, DIVISION.

OPEN OVE;

TO

3

INPUT CARD-FILIE OUTPUT "NO |JOF ROOMS |JAV AREA

PIRINT-FILE OTAL AREA"

HEADING

RITE HEADING |AFTER CHANNEL-1lj,

LEE LEE EL

|

AID-IN,.

|

READ) CARD-FILE) N-CALC, ADD

|LENGT]H

AT

WIDTH

EIND

TO |SUM

|HEIGHT BY {2 BY |SUM.

fe |,

ULTIIPLY

DOOR-H

NOOR —Nae

BY

|

PIRINT-DUT.. |

ULTIPLY ULTIIPLY

GIVING

|

|

WIN-W

WJN-AREIA,

SUBT|IRACT |DOOR4AREA LO

GO

GINVING

GIVING DOOR-AREA, MULTIPLY |WIN-H BY

a]

|

Sahn a

WIN-AIREA

ee

|

See

ADD |SUM TO AREA-TOTAL. ADD |1 TO |ROOM-TOTAL),

GOTO READ-IN.|

FIROM__S|UM.

Po

ds

he

ee

|.

|

OVE| SPACES TO COMPLREC _.. |]. | RIVIDE ROOM-TOTAL INTO AREA-TOTAL |_| GIVING

AAV-AREA

ROUNDED

|.

os

| MOVE, ROOM-TOTAL TO INO-OF|-ROOMS

a MOVER AREA-TOTAL 156

WRITE

COMP-REQ

TO |TOTAL|-AREA

AFTEIR

|

LL

Zz

2.

| ||CLOSIE CARD-SELUE PRINT PML ma STOP, RUN,

|

The Compute Statement The four arithmetic statements, Add, Subtract, Multiply and Divide are adequate for most of the requirements of commercial programming. But there are times when you need more powerful facilities for performing calculations. To meet this need, most versions of Cobol incorporate the Compute Statement. To add A and B giving X using the Compute Statement, we write:

All the values to the right of the equals sign must be either unedited elementary numeric fields or numeric literals. The receiving field can be either an edited or an unedited numeric field. We

can use both the Rounded

Clause and the On

Size Error

Clause in a Compute Statement.

MUTE xX ROUNDED

= A+B...

_ | oMPUTE X ROUNDED HA +B. es SIZE ERADR ico10 ERR |

|, eee

157

In the Compute Statement, Add, Subtract, Multiply and Divide are replaced by the arithmetic operators:

7s

a / Both the arithmetic operators and the equals sign must be preceded and followed by a space.

158

Question Write Compute Statements arithmetic statements

corresponding

to

the

following

I.

UBTRACT DIF FROM SUM

|...

5 es esae

159

Answer

OMFU SUM TE = SUM 4 DIF |... |... Se eeDecra heave wa otdeal... SOOM Bee Woe

tyra

When there is more than one kind of operator in a statement, the computer performs all multiplication and division first, and then all addition and subtraction. In other words the operators « and

| take precedence over + and —. For example, in evaluating the statement:

OMPUTE Xe AuB*G..1..../.., Ws!

Ht. if

ee

an

ete

Where operators are at the same level (for example « and /) the expression is evaluated from left to right. For example:

X=

AxB

C

See

is equivalent to:

teeta

|, 1

the computer first multiplies B by C and then adds A to the result.

is equivalent to:

1

ERs,

nares

A KX= — *C B

161

ets. For example, in You can override these rules by using brack the statement:

evaluate the comthe computer will first add L and W and then plete expression from left to right. complex, it is Where an expression within brackets is itself expression. ete evaluated according to the same rules as a compl tion starts at the When brackets are nested in a statement, evalua

innermost set of brackets.

be preceded by a In the Compute Statement, a left bracket must bracket must right space but not followed by a space, conversely a a space. by not be preceded by a space but must be followed

162

Question Write Compute Statements to perform the following operations:

1.

X=(A+B)(A —B) LOAD

Be NN

x LENGTH

eae se LEP EXP

Sp PSS ase

ial dL a =r ce ee | | | 02 DI. Bue 99 9} UA. i: IS ae eae ed am a JE IS ; [oad D2 D2 -

Poll Fale bead ee

02 D3 O02 D4 $2 D5, @2 D6

ee

02

| | (02 Di7,.

Eoga

DS

PIC PIC Pllc PIIC

999| 999| 999| 999}

PIic

999] VALUE,

IS | 181.

999)

IS | 212.|

, PIC

VALUE IS a VALUE IS 90. VALUE IS | 12¢.| VALUE IS | 151. VALUE

P2eDOMIP ICT 99S VALURMIS i243. O2EDLOUP CEOS SPVALUE SIS 5275. P2 Dill, PIC 999| VALUE IS | 34..|

Hd

2

D2

PIIC

fe Stree

999|

es

VALUE

et

|

|

ae

IS | 334.

ele

It is conventional, but at least in the 1900 series, not obligatory, to list all the 77 levels before the 01 levels.

211

|

Answer

STABLE REDER INES DUMMY-TABLE.|,. 1. PIC |999 OCCURS 12 TIMES. |

212

Question Now try writing the Cobol paragraphs to calculate the number of days from the flowchart shown overleaf. If you want to try it without help, first draw up a flowchart of your own and then compare it with the one shown.

213

fi

ar

eet itieaiieta

214

al ai tin a:

In this flowchart we haven’t shown the Cobol paragraphs. It’s up to you how you divide up the program. Subtract YEAR.

1960

from

Multiply 365 by YEAR giving NO-OF-DAYS Divide giving

4 into’: YEAR DIV

YES

Add

DIV to

Subtract

YEAR

DIV

giving

Add i to NO—OF-—DAYS

(2

NO-OF-DAYS from

DIV

YES

NO

Add 1 to NO-OF—DAYS

Add 1 to NO-—OF-DAYS

Add accumulated No. of days for MONTH to NO-OF-—DAYS

Add

DAY to NO-OF-DAYS

DIS

Answer

ICL

COBOL program sheet

Sequence No,

titie programmer

4 Tak

gl

15

20)"

25

30

35

40

45

5

OVE] ZEROS, TO, NO-OF-DAYS[,.../...,/...,

SUBTRACT 11,960 FROM YEAR |.,,.1...,./.... LE YEAR TiS, ZERO GO TO PAR-D.. ||

on

Be

MULTIPLY, 1365, BY. YEAR GIVING a~OF-DAYS_ DIVIDE, 4 |INTO NEAR GIVING DIV Loa Liha) ees wera TE Te L ee. ADD H,TO INQ- ORDAYS. mee O TO PAR-E. ADD, DIV to Nos0r-Davs

;

|

MULTLPLY,|4 BY. DLV. | Pee SUBURACT |DIV FROM YEAR GIVING DIV Bev F DLV Id NOT |ZERO _ ADD 1, TQ [NQ-ON-DAYS | | ES MOM rd |Se MGO NOs PARE oo) fee een ee eer ete eee See ee Sh, es ane Ih MONTH [TS GREATHR THA oy ADD, 1, ,LQ -QF-DAYS.

eee eee Se Oe el eee | sae JADD MCLONTH) DAY TO NQ-OF-DAYS. joa: Sa

216

The Perform Statement A procedure is the name we give in Cobol to a paragraph or a group of paragraphs which performs a complete task. The bit of a program you have just written, for example, could be called a procedure. Sometimes in a program you will want the computer to perform a certain procedure a number of times. For example, three of the fields on an input record hold dates.

YY

ZZ

estimated

actual

completion

completion

date

SNS HA

On the corresponding output record we want each of these dates to be written as a number of days from the last day of December 1959.

217

We could of course incorporate the procedure into the program wherever it was needed but this would mean duplicating the body of instructions three times. Instead, after moving a date to its corresponding field in working-storage:

| tL. | MOVE) S-DAY TO DAY |... t|..| MOVE) S-MONTH TO MONTH | | b. | MOVE] S-YE|AR TO| YEAR

borer aburcald

we simply say:

|

| | : PERront PIAR-A, |THRU [PAR-E|

|

|

|

|

|

After performing the procedure the computer returns to the first statement following the Perform Statement.

OVE]

NO-OF-DAYS

TO

|SNO-OF-DA

If you had written the procedure as one paragraph the Perform Statement would be:

|

| | : PERFORM DAY-COMP

|

|

|

|

Rwooe heweolee VEN book... wd

218

Question 1.

A procedure consists of one paragraph SELECTION. Write a Perform Statement for the procedure.

2.

A procedure is made up of five paragraphs ONE, THREE,

FOUR

and

FIVE.

What

would

TWO,

be a Perform

Statement for this procedure.

219

Answer

I

ERFIORM

SELECTION

De

ERFORM ONE THRU|....1....1....] FIVE

220

The Exit Statement Let’s say we want to write this paragraph as a procedure:

Is

Bird

‘Cuckoo’ ?

Is Month

‘April’

Whether or not the statement WRITE LETTER is executed we want to go on to the next statement, but at the end of a procedure the next statement will depend on where the Perform Statement is in the program. To make it possible for the computer to find its way back to the statement after the Perform, it is a rule in Cobol that irrespective of the path the program takes through a Procedure it must always end with the same statement.

221

What we must do is add a paragraph containing the statement EXIT which does nothing but return control to the statement following the Perform.

OO-TEST, B) I RD IS EQUAL RN-A. od

ae SS ED:

IS EQUAL |TO

| | TO "'CUQKOO"

"APRIL"

eeeee

si

=

Crewe

WRITE re

i

AND

LETTER,

eed)

he eee

The Exit Statement must always be in a paragraph by itself.

222

| MONTH | |

|

Question A group field is made up of 100 subscripted numeric data items. Write a procedure which will sum the contents of these items. Assume that the subscript and the field to hold the total have both been set to zero before the program enters the procedure. Then write a Perform Statement for the procedure.

223

Answer

|... | [sum-up. | tT | App {2,70 |sus |... |]... | ADD |ITEM(SUB) |_| |IF SUB

| | |Go | | |GO

|TO TOTAL

IS EQUAL

TO

{100

To RETURN—A. TO SUM-UP.

vo)2 | >

Sees

ERFORM

SUM-UP}

THRU

RETURN-—A\|.

We shall now use this example to show some of the more complex forms of the Perform Statement.

224

Here the procedure has been simplified by stating that it is to be performed a certain number of times.

DD|LTEM(SUB), (TO, TOTAL, 1

|

al [este

vials

cel See

| : PERFORM HER 100, |TIMES|

|

|

We can also specify that a procedure be performed until a certain condition is satisfied.

tt tt PERFORM SUM=UP, su TS GREATER THAN, 100.0100, UNTIL ee

eee

eee

ee ee

If we had specified that SUM-UP. was to be performed until SUB equalled 100, the condition would have been satisfied when

only 99 items had been added.

225

eee

|

Here we have reduced the procedure to a single statement.

|, |BuMebp

[|

t,

Rop’ rem (suB) ro ToraL.

Frees iiFaai

it]

TE

eek | ae

226

IPERFORM SUM-UP| VARYING sup FROM 1 BY 1

UNTIL

suB

IS

GREATER

THAN

10¢

Cobol Subroutines The Stately Homes Building Society have asked us to write a Cobol procedure which calculates the compound interest due on sums deposited with them. Because of the procedure’s usefulness, they want us to write it in such a way that it can be incorporated in any program which needs it. We can do this by writing the procedure as a Subroutine. A Subroutine is a procedure which can be written and compiled independent of any program which may use it. The compiled version of the Subroutine is stored in a library and when a program needs it the computer searches through the library and gives the program a copy of the Subroutine.

227

The Identification Division All the program divisions must appear in a Cobol Subroutine in the same order as in a program. In the Identification Division, the Subroutine’s name can be up to eleven characters long and must not be the same as any other in the library.

OL COB program

ICL Sequence

1

No.

sheet

i

vesemme:

4

678

hie,

iG

20

25

30

a

AMALD 2) | COMINTEREST. |... |. SSI? |i,nhac rere

|[PROGR

228

ie

‘s

a

The Environment

Division

In the Environment Division, only the Object-Computer has to be specified. It need not be the same as that specified for the program which uses the Subroutine.

ICL Sequence No.

67

1

OL m COBgra

sheet

5

40

pro

it

prosrammer

4

8

Wie

18

25

20

| ENVARONMENT, DIVIS TON, |...

30

45

50

|__| CONFIGURATION SECTION,

E-GOMPUTER, .. | SOURC |.

Pree

Ne

|

gOB J]CT

= GOMPUTIER feet

e903.

ss ||ENPIUT-OUTPUT

.-CONTROL,. FIUB . |.| Soeeon|t| far!

|SECTION.,

a

.|.,,,1,,

od eee eee

229

The Data Division When a Subroutine needs working-storage the entries are filled in in the same way as in any other program.

ICL Sequence il

program al

sheet

v0p.sremmer

4

No. ones

i

Fe

15

20

VALCAC)

AAAS UA

25

Peed

30

ee

230

i

PI

40

Pe

45

50

ee

el eeicy wavs de MEP

|. |WORK ING4STORAGE SECTION.

He (ea

35

6).

.|....|_..|

|

The Linkage Section The program which uses our Subroutine must supply it with the following information:

Original Amount Interest Rate/Period No. of Interest periods

(pounds) (fraction)

and expects to receive the following result:

Final Amount

(pounds)

These items are called the parameters of the Subroutine, and must appear in a special section, the Linkage Section, which is used only in Subroutines.

231

Items in the Linkage Section which have no subfields can be given either the level 01 or the level.77. If the item contains subfields it must have the level 01.

LINKAGE SECTION. | | |77 PIRINCIPAL | | |77 RATE

PIC 999V99). PIC vg999.

A177 | | [27 AMOUN

PIC PIC

eee

9999, 9999V99.

Sequence

1

No,

Ome

pewenrer

eee sheet

ICL

f

' a

4

V5

20

25

30 J

ft

35

40

Teeagt

HeSSN

tan

a

a

45

50

heats

Se

ff

Medak:

Sen

Se

MISROUNDED 2 Wisi tattle len. igi saRAENDiveSas ale,

eee (a

te Es

et

rn et

a

a

(Sen

ee

Sea

eS

ae

Eases

SS

1S

ST

Ses

Saint

a

tae

et

ap es Tee

Ree

ie

a

eT

es

See

eS

eee

ff

Se

ee

ae

ee

Pea

a

Set

Seat

SS

SS

ee

east

eer

ge

2 See

SS

STE

ea

eS

SS

SS

ae

et

Hott

Slt

|eae (ee

a

SS

et

aS

et

ee

aS

Sa

as

ei

thee

=

ee

a

et

a

es

ei

EAE

jh

SE

sa

(este

Sin

ah:

Ss

eS

ae

gh

ul

SSS

eT

SS

eee

ares

Se

ee

SS

aSi0

Seen

fea ee

SES)

Se

see

ee

eT

aS

SSS

2S

SS

iE)

SESE

ae

(ees

VesUe

aie

i]

SNS

233

ESSE

Ete

The Call Statement A program which wants to use the Subroutine COMINTEREST must describe, in its own Data Division, the items listed in the

Linkage the File the same the same

Section. The items, which can be described either in Section or the Working-Storage Section, need not have names as in the Subroutine, but they must be listed in order.

We call the Subroutine into the program with the statement:

CALL|

COMINTERE|ST =

In the Call Statement we list the parameters by adding the Using Clause:

Again the parameters must be listed in the same order as they appear in the Linkage Section. The parameter names must, of course, be those we used to describe the items in the main program.

234

qa

Question Write a Subroutine which converts prices in £. s. d. to £p us ing the following table to convert old pence to new pence.

asad.

£p

2 3 4 5 6 i 8 9 10 11

1 1 13 2 24 3 34 4 4 43

1

}

In the main program’s Data Division the two parameters described as:

are

Ld 101 MONEYIN, PIC |999, ent elec a ROUNDS ae |i MN OONSHTULINGS eR TCN oO. PIC | 99. TTT LY, 64 PENCE PCa DONA os eer |||S| )1 MONEY-OUT

[oouoddeese

235

Answer

OL COB program

ICL ~

oa



'

8

pe 74

TDENTIFIICATION PROGRAM

nal

ID

uA,

1 pidtesre M

—COMP.U

ER..

1 | 2}



fahearer

| tere

ITNAUT-OUTPUT |SECTION. TUE|-CONTROL. IF el ea ae ee Gn |

6

N Ww

Bad

Fs5

§

ue

ie

i

re eee

Reiteleee

ENVIRONMENT DIVISION. ICONFILGURATION SECTION. ISOURCE-COMPUTER. OBJECT | | JTCL41903.

|

eas

a

.

ONEY.CON

a

4s

;

DIVISION. a

of

ie»srammer

40

35

30

25

.

20

5

sheet

Derr’

ter

Ls

: ree

De

Sequence

No.

f

‘ LZ

15

20

25

30 1

6)

eC

40

Tes CS TR a Ce

ORMINGSTORAGE SHCTION....|... |r PSS Ce a (SC

ee

ARACT

ES

Pac

MII,

!

fe

SSS

45

ee, ee

|....1..

Es ee eee

Ma

IDUMMY-TABLE . $2 01, ..PIc P94 VALUE IS

$2 D2. Plc P94 VALUE IS |.0 02 D3. PIC P99 VALUE IS

“| |é2 Dy PIG P99 VALUE IS

P99 VALUE IS |.¢

$2 D5

PIC

G2

Pic .P9d VALUE

06

TS

|.@254....

02 D7. PIC P99 VALUE IS |.030.

$2 D8. PIC P99 VALUE IS |.0351. ~\ |d2 D9. PIC P99 VALUE IS |.Oudd,

G2 D1 PIC P99 VALUE IS |.0u0. | (@2 D411, PIC P99 VALUE TS |.0454 PENGE-TABLE .REDEFINES DUMMY-TABLE. $2 -P

PIC

P99

|OCCURS 1/1, |RIMES

dace SECTION. Oi ¢1 MONEY-4IN. mOZe POUNDS Ri PIC

$2 SHIULINGS PIC|

AP Re Mae ar

2 sole

99-1,.,.1,..,1.

02 PENCE PIC | 99. O41. MONEY OUT FIC TOI O22 1

ots

1

1

ee

eine

ff

ee

237

st

9a

COBOL

program Sheet

17)2 ¢ oe 5 ) ) Zz ° 1

title

programmer

4 o>

6

TIelZ

15

20

|. | PROGEDURE

ee

25

30

35

40

DIVISION.

SARE

45

vee

|... | [| Movg POUNDS TO MONHY-OUT), |. LE. | MULTIPLY |5 BY |SHILLINGS | [| | DIVIDE 149 INTO SHILLINGS |. tt. |JADD |FRACT| TO MONE Y-OUT | tf |YEF ENCE |IS EQUAL TO ZERO a aN Se GOornOuRETURN =a |... |]... | ADD IP(PENCE) TO MONEY-o

GIVING

FIRACT

Li... |RETURN ~A.

fit

Peecsadte sau

8

N Ww

LEXI)

PROGRAM.

Seaweecwewen

;

Question Write the Call Statement needed to use the Subroutine in a program which has described the parameters of the Subroutine as

enlimonpernice, ee Ee Te JU Le aaah ae GeO

eae] |

dace 1cwy9

91:

AO 2 RDS PCW

OOF:

| TT | (6, NIEW-PRIICE,

coe

MEA

"SelM

PIC, 99/9V999|.

A

eer lobes Si

Na Mr

239

Answer

O

240

AY-CON

USING

OLD-PRICE

==

The Enter Statement Calculating an employee’s income tax and graduated pension contributions are just two of the common tasks undertaken by a commercial computer installation. To save each of the hundreds of users writing his own programs for these jobs ICL maintains an extensive library of commercial subroutines which are freely

available to customers. For example, the subroutine NGPM2 calculates the graduated pension contributions for monthly paid employees. To enter this subroutine into a Cobol program, we give the language the subroutine was written in and its name in an Enter Statement.»

ENTER PLAN NGPM2

| ne nae

Plan is the assembly language of the 1900 series.

The Call Statement is used only with Cobol Subroutines.

241

ec

| en

The Cobol program which calls the subroutine must supply it with data to work on and with the name of the data item which is to hold the result.

Ist data item 2nd data item 3rd data item 4th data item

set to zero if not contracted out No. of months holiday pay included current pay for month contribution due (result).

These data-items are called the parameters of the subroutine and the names you choose for them follow the usual Cobol rules. We list the parameters by adding a Using Clause.

ENTEIR

PLAN

NGPM2

USING

C HOL

PAY

You must be careful to list the parameters in their correct order.

242

DUE

Question The ICL 1900 library subroutine CPAYECODEFP derives the Free Pay Allowance for week 1 or month 1 of the tax tables. It has three parameters Ist data item 2nd data item 3rd data item

code number. set to zero for week 1, set to 1 for month 1. result.

Write the statement to enter this subroutine into a Cobol program.

243

Answer

[TT |JENTER PLAN

POR

CPAYECODEFP

USING

CODE-NO

bed Se eee wee

Eee. JHE

Please consult the appropriate reference manual before using any of the library subroutines.

244

User’s Subroutines Occasionally you will find that parts of a program can be written more easily in a language other than Cobol. Say for example you wanted to evaluate the function:

T = tanx + 1/3tan®x You can write this as a Fortran subroutine and enter it into your program in the same way as you would a library subroutine.

|

|

LENTER FORTRAN FANEURS uStNS : ve

245

|

|

ee, Phas ia Lalae lee stints Lig: aurits I 3 egy

sectemlue

OP ae

Van»de ieee ot ce Yew sete

ee }

i

oiiee

¢

a

ae oe

a

he

~

eack

th)

ia

Question A Fortran subroutine QUADROOTS equation ax? —- bx + c= Write

an Enter

Statement

to use

evaluates the roots of the 0

this subroutine

in a Cobol

program. It has three input parameters A, B and C and two output parameters X1 and X2.

247

Answer

CENTER food LIU oe fescedULoa

248

FORTRAN

|QUADROOTS

USING

A

B

The Fast Peripherals Until now we have only written programs to process files held on slow peripherals such as the card-reader and the line printer but in most installations much of the work will be concerned with creating and updating magnetic tape and direct access files. Programming for files held on a fast peripheral such as a magnetic tape unit is usually a very complicated task but fortunately Cobol has succeeded in making it as simple as possible. Even so, the computer requires a lot more information to work on and this must be supplied by the Cobol program.

We shall start by looking at the changes we must make in the Divisions of the program and at the additional information we need to give to process magnetic tape files.

249

The Identification and Environment Divisions of the program are the same until we come to the File-Control paragraph of the Input-Output Section.

t

oe

{ere

GN

§

Y

1

aguchatiaos

veo

8 fiqu

th ; fee

gosh

|TAPES).

The integer before TAPES tells the computer how many magnetic tape units are to be assigned to the file.

With the ICL 1900 series operating system it is never necessary to assign more than one magnetic tape unit to a file. When the object program is being run and the end of one reel is reached, the computer automatically searches for the continuation reel on all the other magnetic tape units. If it can’t find it a message is typed out on the console typewriter telling the operator to load the continuation reel. You can, if you wish, give the number

of reels in the Select-

Assign statement. It will be useful for documentation but will not be used by the computer.

250

|

|

oe

Question Write an Input-Output Section which assigns two magnetic tape files called FAST-IN and FAST-OUT.

251

Answer

INP|UT-OUTPUT |SECTION.

F IUE|-CONTROL. neal ELECT FAST-IN ASSIGN 1 |TAPES|, | | SELECT FAST-OUT ASS|IGN 1| TAPES.

252

l

The Data Division The information we give in the Data Division about a magnetic tape file depends to some extent on whether we are creating the file or reading from it. Let’s start by writing a file description for a program which creates a file MAGT-OUT.

253

Block Sizes Before writing can take place on a magnetic tape file the tape must be travelling at full speed. And so, between each record there is a length of unused tape.

ct ful speed.

J}

record

77

inter—block

I

!

rest

'

7

se

Genie

writing

\

!

1

I

'

'

\



\

/



U

\

/



1

at

——

/ \

1

record

ae \

t

?

gap

\

‘ A

ioe

7

ane

ee ee

starting

writing

ae

Te

As you can see from the diagram, if the records are small much of the reel is wasted. Therefore, unless a record is very big, it will save a lot of space on the magnetic tape if the program writes several records at a time.

254

\

If we start the file description with the statement:

ee

I

acs

re eee

the computer will reserve an area in store big enough to hold six records. Each time a Write Statement is given, the output record will be moved into this area which is called a buffer. When the buffer is full the block of six records is automatically written to the magnetic tape file. It’s up to you to decide how many records to put in a block but on the 1900 series it’s conventional size of 512 words.

to have a maximum

block

255

Standard

Labels

At the start of every reel of magnetic tape there is a header label which holds the following information:

the characters HDDR tape serial number FILE IDENTIFICATION reel sequence number file generation number RETENTION PERIOD date written. Soe MS At ata The two items shown in capitals must be supplied by the Cobol program. We start by saying that the file has standard labels.

FD | MAGT-ouT T IBLOCK CONTAINS)6 RECORDS | | (LABE|L RECORDS STANDARD rad

ee eps ec. | | =|

On the 1900 series a file’s Identification is a non-numeric literal which must not be more than 12 characters long.

VALUE

OF |ID 1S| “STUDENT-FILE”

ID is an acceptable abreviation of IDENTIFICATION.

You will notice that the file’s Identification is not the same as the File Name. The File Name is used solely to distinguish one file from another within a Cobol program. The file’s Identification on the other hand distinguishes one magnetic tape file from another in the tape file library. We don’t usually make the File Name the same as the Identification because most magnetic tape processing is updating files and we generally want the output file to have the same Identification as the input file.

257

The retention period is the number of days which must elapse before the information on a file can be overwritten. In Cobol this is called the Active Time

of the file and has a

maximum value of 999 days.

|

| !ALINE TIME is 3 The Active Time is added to the date written to give the date, called the purge date, when the file can be overwritten.

258

:

And finally, to complete the file description we add the Data Records Statement.

| | PATA DIVISION.

Poe,

meet, | SECTION)... |....1....|

DTD | MacT-ourCONTAINS| pd le || |

|LABAL, RECORDS

TT. | [VALUE OF |

"STUDENT

Wee Fee ACTIVE TIMERS SSO

|

| |

FILE"

|

ne ee eel ee tat leasoere a relBoruefeleaeoe perereeeleameralina Eaeea

| EDATARRECORDI ee

swat eal

|

6 RE|CORDS

|STANDARD

|ID IS

|

TSIMAGIREC

en

You will notice that again the full stop comes only at the end of the complete description.

259

> i,

preetwewre,

> 2 ae

as)

Re

Pao ey reed OTe Sonos : fio tnt a

:

Pt ae

ta 7

OMe n

e

Wwe

ot

)— f

ra te

AAS fens

»

eas «

Pat te TARTS” ey. g — Se 1 ee marie pu ot

—o

:

;

a

Le

ES

7



a

i eA |

,

yi

1

i

Ss bry ar Ge ylae vornua qoie U1 oe) otewe tads Sauen Mw aot a=

ckntoonls Sikqri ate

=

=

=



a

Question You are writing a program to create a magnetic tape file TAPEOUT which has two kinds of records REC-A and REC-B. There are to be five records to a block and on the standard label the Identification is to be MASTER-FILE and the Active Time

29 days.

Write the file description for TAPE-OUT before continuing.

261

Answer

ICL Sequence

1

pcsammer t = Sovmme program shee Bifogram sheet

No.

4

6

8

VE 12

15

20

DIVISTON.. H

SEQTION,|

pL Bog LABE|L

erat ee

25

30

§ Pe

L pee

er Bere

35

40

ro ae ey

Se

wale CONTAINS) 5 REICORDS| . REQORDS

|STANDARD

Fad ALUE, OF |1D, 1S] "MASITER-FITLE”, | ACTIWVVE—TIME

Pedal DATA) hea

N ONN

RECQGRDS

IS;

29

AIRE

REIC-A REC-B.|

.

ee

|. ;a

ee

The Record Description On the 1900 series the first field of every magnetic tape record is used to give the size, in words, of the record.

If the records are fixed length you need never refer to this field in the Procedure Division and so it can be given the name FILLER.

MAGTI-REC,

2 FELLER

Lae

The compiler will calculate the size of the record from the record description and insert it in the field.

263

The size of the field must be one 1900 word, which is made up of 24 bits.

a

Bei

|

ae

bhte

I

i_i_1_

i

|

A ‘lV in the Picture shows that it is a bit field.

To show that the value in the field is held as a binary number we add the clause COMPUTATIONAL-1 which can be abbreviated to COMP-1.

AGT|-REC,| SLPS

2

ea ea

a

ce

pees

264

|

| Le

|

|

ee ds

1

i

PLLLLER PIC>, 1 24)| |COMP ae |

otitis

i

|

| dd

.

Question Write the description of the first field on a magnetic tape record called STUD-IN.

265

Answer

SD LUD

Ne

$2 FIILLEP|

ees

| cyl

266

eee

PIC, |1,(.24)| COMPL1.

Wee Bee

ee ee

The Procedure

Division

When a magnetic tape file is opened for output:

eee) TERCOEDURERD IMECHONWigeumecstiona i) Pal ee asta (eee eee see tT et eer ill PourpuramAcr-ouUpaee rh el ieee

POE Cecudt call the computer searches through the magnetic tape units for a file with a standard label which says it can be written to; this will either be a file whose active time has expired or one with the identification “SCRATCH TAPE”. If it can’t find one a message is typed out on the console typewriter telling the operator to load a scratch tape.

When the computer finds a file it can use, it opens it by writing the file’s identification and active time on to the standard label at the start of the reel.

267

When a magnetic tape file is opened for input:

PROGEDU

5

DI

ISTON.

| | PPEN| INPUT

| 1

my

a

| 11

aie

TAPE-IN.

Pal

the computer searches through the magnetic tape units for a file with the required Identification. Since the computer only checks the information on the standard label, there is no need to give the active time in the file’s description, since this was recorded when the file was created.

-PAnA DIVISION.

SECTION, | Sane oe nt | FO APEING. | Weel met |__| BLOCK, CONTAINS] 5, RECORD LABEL ea |, | MALUE, Coad DATA| fod

RECORDS

OF

|STANDIARD

|ID IS| "MASITER-FIILE"

RECORDS

AIRE

REC-A

REC-B,

The block size must, of course, be the same as it was when the file was created.

ro) 268

| | |

| |

Direct Access There

are two

kinds

Files

of direct access

device for which

Cobol

programs can be written, these are the: Exchangeable Disc Store Fixed Disc Store

(EDS) (FDS)

The abbreviations are the names they are known by in Cobol. It makes little difference to the Cobol programmer which kind of direct access storage his files are on; Cobol handles them all in the same way. We shall use the ICL 2802 Exchangeable Disc Store in all our examples.

269

Seek Areas and Blocks Just as on a magnetic tape file the maximum amount of storage is one reel of tape, on an exchangeable disc store it is one cartridge. Each cartridge can be considered to be an area of store with the following dimensions. BLOCKS

SEEK AREAS

199

A block is 512 characters long and is the mini mum amount of store which can be transferred with one periph eral instruction. Since the size of a block is fixed for each type of device it is sometimes called a hardware block.

A seek area is made up of 80 blocks and is the amount of storage which can be accessed without moving the readwrite head.

270

79

On the ICL 1900 series a file is allocated an area of store and loaded onto direct access storage by 1900 library programs. All the information given in the file allocator and load programs, the file’s Identification, Active Time

and so on is recorded in the

reserved area at the start of the cartridge.

area

file

area

Within a file, each block of records is numbered from one up-

wards. A block of records need not be the same size as a hardware block and to avoid confusion is called a bucket. A bucket can be 1, 2, 4 or 8 hardware blocks long. The bucket size for a file is

fixed by the file allocator and cannot be altered during the life of the file.

271

stor

With a magnetic tape file the computer has to read every block in turn into the buffer in store. block

block

block

buffer

CORE

STORE

To find a particular record the computer must read each block, starting at the first, and examine every record in turn until it finds the one it wants.

272

The position of every file on a cartridge is recorded in served area. This enables the computer to translate a file’s numbers into hardware addresses. So to read a particular the computer need only know the number of the bucket holds that record. bucket

no.1

bucket

no. 2

the rebucket record which

bucket

no. 3

buffer

CORE

STORE

The computer cannot read individual records but must read the whole bucket into store.

273

bucket

no. 4

Sequential Files There are several kinds of direct access file but perhaps the commonest is the sequential file. In a sequential file records are stored in the buckets in key number sequence. During the life of a file some records will be deleted, some will be added and in some cases records will change size, but the tendency will always be for the file to grow.

To allow for this activity and still maintain the records in Key number sequence it is usual to leave part of the space in each bucket empty when loading the file.

The ratio of used to unused space in each bucket is called the bucket packing density. Once the file has been loaded this space becomes available to cope with changes in the file.

274

On most files it will not be enough simply to leave some space in each bucket since it will often happen that three or four additional records should go in one bucket and none in another.

To cope with this we leave some of the buckets in each seek area empty when the file is loaded. These buckets are used only to hold records which cannot fit into their proper bucket. The buckets which are filled when the file is loaded are called home buckets and those used to hold overflow records are called overflow buckets. OVERFLOW HOME

BUCKETS

BUCKETS

The proportion of home to overflow buckets is called the seek area packing density.

When the computer finds that it must put a record in an overflow bucket it puts a tag in the place where the record should go which points to the overflow bucket.

275

None of this really concerns the Cobol programmer, the bucket and seek area packing densities will have been decided when the file was loaded and the computer will automatically tag records and put them in the overflow buckets.

In fact all the Cobol programmer needs to know is that if his file is sequential the computer will maintain it for him in key number sequence and that if he wants to access the records in key number sequence the computer will do so whether the records are in home or overflow buckets. When the file has been active for some time and there are many records in the overflow buckets processing time will be slow and the file will need to be reorganised but this again is done by 1900 library programs.

276

Sequential Access When a file is stored in key number sequence we can access the records in the file in two ways. If only a few of the records in the file are to be altered then we can save a lot of processing time by accessing only those records which need to be changed. This is called random access. If, on the other hand, a high proportion of the records are to be altered it will be quicker to access every record in the file. This is called sequential access.

Let’s look now at the Divisions of a program which is to access a file sequentially. The Identification Division and the Configuration Section of the Environment Division are the same as usual.

277

The Input-Output Section of the Environment Division is the same as for slow peripherals except that we must add a statement to the File Control paragraph saying that the file is to be accessed sequentially.

ao

L = pe"

y

Baad NANCE AS\S IGN DS 1 Ac USSSEGQUERTIAINS.- ti) ae

Notice that the full stop comes only after the second statement. If there were two files the File Control paragraph would be:

ees. PaaS. SELECT PART-F ILE AS|SIGN. EDS Pea ACCEISSMODE, IS| SEQUENTI |..AL . ],,. ., | we Wran ee

278

The Data Division In the file description of a direct access file the Block Contains Statement gives the file’s bucket size in characters. | | | Ber nil D AY DIVISION, SECTION, herelll ae D | MAIN-FILE| | BLOCK CONTAINS, 51.2 (CHARACTERS fee

LABE|L Jew b Lil!

4

hal

AL

E

DATA)

RECORDS OF

|1@1,| |TYPE|-REC. TY |l@2 FILLER ——

|

Jat. Pe

ID

RECORD

pee

eee

ee

et

Dae

Is|

MASITER-FIILE"

| we

bie

IS| TYPE|-REC,

PIc |1(24)| CompPl-1.

eet | ee

Cee

| Ce

eel

storage.

Like on magnetic tape files, the first word of every record must give the record’s length.

279

|

|... |

|STANDARD

You will notice that we don’t give the file’s active time in the description; this was recorded when the file was allocated its direct access

|

The Procedure Division A sequential file cannot be opened for output only but it can be opened for input.

PEN

,INPUT MAIN|F |,I ,..1 L,. E ..1

The most usual form of processing a direct access file is where the program wants to read a record from the file, update it, and then write it back to the file. This is called processing by overlay.

OPEN

INPUT—OUT/PUT

MAIN-FIL | E | .

280

Example At the Garden Centre of Cudweed and Fleabane a re-order file is kept for all the items stocked. Records are 100 characters long and the first four fields in each record give the following information:

24

record

part

re-order

quantity

length

number

quantity

last

BITS

6 CHARS

sold year

8 CHARS

8 CHARS

We have been asked to update the file in two ways: 1.

Increase by 50°, the re-order quantity of any item where the number sold last year exceeded the re-order quant'ty.

>.

Delete from the file any record where the quantity sold last year was Zero.

281

aan ® si zabveetts oonlaohh bee da wae rene wad @oiteres OC

ow dred

bed:

_ ienlA tr ania renky aes oath wot

;

LJ

ae



©

&

. ie

a)

-

a

ts dip hry id

“ti

.

ap pebvoey alt O08vd 9 ort) Tlurs tape seat Bos j

v3

Yee

iti od)

apni seed]

=

_

+

7

-

Question Start the program by writing the Identification, Environment and Data Divisions.

The file which has the Identification ““FLOWER-FILE”’ is held on an ICL 2802 Exchangeable Disc Store.

The records in the file are in key number character buckets.

sequence

in 512

The computer is an ICL 1905 and there are 16000 words of store available to the program.

283

Answer

9 ios

BOL

n ® a € ® f] Qa o ze ° . ~

o

7

title

program

o>

4 111215

|, | JEDANTIFICATIOQN

DIVISIO

30

35

sheet

programmer

40

45

|...| PROGRAM-ID. |... tt, | MEEDSO. [I

pp NVIIIRONMENT DIVISION. |. | (ONFITGURATION SECTIION, |, | SOURKCE-COMPUTER.

ea} |PCa

50

|

gs.

|... {|PBJEIT-COMPUTER.

een ae CEG 5

|... 1]. . | MEMoRY. 16666 worDs. |__| [INPIULP-OUTPUT |SECTIDN.

Co Tetueccontron. |... |[| SELECT ORDER-FILE

Leslee |... |

ASSIGN EDS |,

|]. |AccEIss MQDE Is} SEQUENTIAL. |... ees ea re | ae ee eee eae ere

284

| ss | | | ee,

patil DIVITSION, FILE] SECTION. ORDER-F ILE

peel BLOCK CONTAINS| 512 CHARACTERS ieee LABEL, RECORDS, STANDARD peg ALUE, OF, [ID IS| "FLOWER-F|ILE" TT {| PATA] RECORD IS) ORDER-REC|. |

|

Pl | PRDEIR-REQ.

ee ee 2S CER PIC (24) CoMpEl: Fak 2 P|IART-NO PIC| X(6)},

Deere |Ree 2SORDER IOTYOimer temo C8)|

| LY | 82, QT Y-SO|LD

GE

| Foes) Pes

ee

PLC

Ce)

ee

Bee ee

a

285

ee

Question From the flowchart on the opposite page, write the paragraphs START, READ-IN, FIND-RECS and FINISH. (The Close Statement for a direct access file is just the same as before.)

286

Open

order-file

Read

a record

TEINISH

:

| | |

|

Close

| | | | | | |

greater than order-qty

order-file

qty-sold

equal to zero

|

INC-PAR

| |

Multiply

|

order—qty

| |

by 50%

|

|

Write updated record back to file

|

| |

| |

TDEL-PAR

| | | | |

|

Delete record from file

| |

=



=



S

| | | | |

| |

287

4 ~

fon

HITZ

o>

15

20s

25

30

35

40

45

50

es){(e) eo S

¢,

bd

ey mee,

OPEN D>D

| tH Fa

1es

INPUT-OUTPUT ks

SGweee

Sree

eo

y

oe

l cite

eee

O|RDER-FILE.| bowes

Pree

ere

READ ORDHR-FILE AT END GO TO FINISH. FINDA REC peers, Le aor IF QTY-SQLD IS| GREATER THAN ORDER-QTY | | | |GO

TO INQG-PAR,

|

Pt

Via

| LIEF QTY-SQLD IS| EQUAL: TO ZERO |_| | | {GO TO DEU-PAR.

ead 0 TO READ-IN,|. feared SEA Se H. PR MEN FINI CM E OP

= LOSIE ORDER-FILE | . ire Pet BTOP RU Nel a 1 Se PSs, ot theeg te Ra Seo Ea oe eS RIS ee

N CoCo

|

]

The Rewrite Statement In the paragraph INC-PAR, we alter a record and then write the updated record back to the file.

INCG-PAR,.

muscild ULTIIPLY ean REWRITE

| |

Fea

|1.5 BY ORDER-OTIY ORDER-REC

ROUNDED

GO, TO. READ-IN,

eee

|

pat)

eat shea

When a file’s access mode is sequential, the Rewrite Statement replaces the last record read by an updated record. The Rewrite Statement can only be used when the file has been opened for input-output.

289

The Delete Statement In DEL-PAR

we delete unwanted records from the file.

Tee

pessoa i TULA ieee FeRaces

+H a

it.

When a file’s access mode is sequential the Delete deletes from the file the last record read.

Statement

Like the Rewrite Statement, the Delete Statement can only be used on files which have been opened for input-output.

290

The Write Statement On another direct access file, Cudweed and Fleabane have assembled a large number of new records which they want to add to Flower-File.

Let’s assume that we have already written the first three divisions of the program and go straight on to the Procedure Division.

When a file’s access mode is sequential and the file has been opened for input-output, the Write Statement causes the new record to be inserted in the position immediately preceding the last record read.

291

Question When we move a new record to ORDER-FILE’s record area we overwrite the last record read. Since there may be several records to be written to the file before the next Read Statement we need to preserve the part number of the last record read. To do this, we have described the item ORDER-KEY in workingstorage which is used to hold the current part number from ORDER-FILE. Now try writing the Procedure Division from the flowchart opposite. You will notice that if we come to the end of ORDERFILE before NEW-FILE is exhausted we abandon the run and type out 999 on the console typewriter.

292

|

|

| | | | |

|

| | |

Open | | | \

NEW-FILE

|

Open

|

Input-Output

| |

[NEW-ORDER-WRITE Move

ORDER-FILE

|

=———™ 1

NEW-REC to

ORDER-REC

| i}

|

| |

| |

input

Move

zero

| |

to

ORDER-KEY Write

|

ORDER-REC

223)

Read

NEW-FILE

End of file

AES

marker T| EINISH

| | |

|

| |

|

|

Close

files

STOP

RUN

| | | |

| !

| | |

|

| | |

| | !

| ! | | | I I |

| } | | | | I | | |

Move

PART—NO to

ORDER-KEY

|

| | | |

293

Answer

°© a) 2

o

ttle »csemmer

COBOL program sheet

5) > i e ine

foo}

15)

20

~

25

PROCEDURE, DIVISION, £

:

RT.

| |OPEN po EEN MOVE| NEW-READ, —

bse |

bey apd, !

4

BAS

[

ben

ee

18 Pees

INPUT. NEW-FILE| ont | [Soi oe ee ORDER-FILE | |, 1,,,,] ZERO TO ORDER-KEY. | | NEW4FILE AT END GO |TO FI

-RE|AD, IF, NEW-KHY IS NOT GREATE|R THAN ORDE|R-KEY GO TO NEW-ORDEIR-WRITE. _,_| JREAD| ORDER-FILE AT, [END S/TOP, 9/99... | |

ONE EAR TINO O10

WRITE [tit ~PRDERPRONRITE IOVE

i:
on

CL

n@

He)r= ® fo] a) r) Zz °

~

an

"CORO an program sheet

a

»osemme:

' o>

PIS

15

zo

-

25

30

ee ee a a ee

ee

RONMENT Un

OIVISTON. | ..ti. tii, SECTION. |, ,,,| eee ISOURCE-GOMPUTER. , 3

| | {ICL4195,

OB

&

JEICT-COMPUTER.

rE CESS Si

|

ee

|

Oe. tae

|

pee

|

eee

| | MEMORY 146009 WoRDS. INPUT-OUTPUT |SECT ION. FIVE -CONERCL J) eee | | |SELECT CARD-FI|LE AS|ISIGN |CARDSREADER 1. | | ||SELEICT DISC-FILE, ASSIGN EDS 1)... |... | ACCESS MQDE IS| RANDOM |... .|,,.. |

ORGAN ESA TON NO S YMBDE LG 1KE ee ENG

Ww0O

a ee

Question Start the Procedure Division by writing the paragraphs START and READ-IN from the flowchart shown below.

Open

input

| | | | | | | | | | |

CARD-

Rill Open

Input-Output

DISCS EIEE

| Sa

SSS

r

| FINISH |

| | | | |

|

|

| \ | \ | |

Seek

DISC—-FILE

Close

files

|

record

| \ | |

a

Delete

record

|

| | |

YES

|

|

eee

eS 5

|

|

|

NO

Display Invalid

|

Key number

| |

\ \ !

\ |

|

ee cr es

| |

| |

} |

301

Answer

iis Lier

rare redbahalWerte Wren

iy

oe

INPUT CARD-FILE |__|

||. | OPEN

INPUT-OUTPUT

eee eee eee

[READ| CARD|-FILE| AT END GO| TO FIINISH|,

Once we have read a card record into store the symbolic key field will contain the key number of a record we want to delete.

302

|

DIISC-FITLE.

[|READIN ole =| pee | oe fel

U|_|

ewes Do

The Seek Statement In the paragraph DEL-REC the file.

we delete unwanted records from

Before the computer can locate a record in DISC-FILE it must translate the key number held in the symbolic key field into the number of the bucket which holds the record.

We instruct the computer to do this by writing a Seek Statement.

SEEK) DISC-FILE| RECORD

|...

|,..,.,.1,...,]

303

The Invalid Key Clause When a file’s access mode is random, we must add a clause to the

Delete Statement saying what we want done if the record’s key number lies outside the range set when the file was loaded.

DELETE

DISC-FILE| RECORD, ,|,,,. |, DISC-REC INVALID

KEY

|.

of Let’s say that we want the key number of any out of range record displayed on the Console Typewriter. We can do this simply by writing a Display Statement.

ealJ|__| SEEK) DEU-REC..

pet fl PELE

‘Sere|!

DISG-F ILE] E_DISC-REIC

DISPLAY

esreveiiweeanouaul

RECORD

INVALID

KEY

KEY-NQ.

(foosull

When a file’s access mode is random, the Invalid Key Clause must

be used on Read Statements.

304

and Write

Statements

as well as on

Delete

|

Here is the complete Procedure Division for our program.

~~

OL... “CprOB ogram sheet PYa2

15

Tea

20

Mee

25

30

ar a

t= eh erie

35

| Prsemmer 0

45

Mircoleuhedl|

Bey: ae

PENS INPUT CARD CE IUE gn lee | ODE EN BUT OUTED To ee EEE ce eee nel READ)

CARD-FILE|

[peau

easel SEK

| AT END GO| TO FIINISH.

sp martes

[eeenicom ss

1.1. RECORD DISC-REIC INVALID |... KEY |... 1,.,,1 DISG-FILS

DELE|TE

| GO TO READ-IN. Fr ES oe 0050 eieercotl crane briaearld revel rere cre aval a re er ose CARD =F TIE. DISC SEILE. Peels We | ow,lee | e ole MES OPER ON [etmee Et eee ier

seh)

The Display Statement As you saw in the last program, Display Statement:

if the computer

executes

a

the value of KEY-NO is printer on the console typewriter. The Display Statement can be used whenever you want the program to output a small quantity of data. If you don’t want the data output to the console typewriter you can give the peripheral of your choice a mnemonic name in the Special Names paragraph of the Configuration Section:

(__ BPaGIAL OME ca eli egress ones JS MONITOR-PRINT. | | Pescanicnn feeeeanrean ears BAWIIS FPS aes and then say:

DISPLAY

KEY-N

UPON

MONITOR-PIRINT.

The printer will be allocated to the program and will not be released until the program is finished.

306

|

Oe

Transfer Replies The Invalid Key clause only tells us when the key number of a record we are trying to Read, Write or Delete lies outside the

range of key numbers set when the file was loaded. Occasionally a program may attempt to read or delete a record which is in the correct key number range but is not actually on the file.

We can test for this condition by specifying a field in working storage which the computer’s input-output system can use to give the program information about what has happened during a peripheral transfer.

- a |; ieREPLY WORD |PIC #.(2u)| SYNC| RIGHI.. 1

et

il

|

ep

| pee

ee

| ee

ETS

en

ey

phy

The field must always be described as PIC 1 (24) SYNC RIGHT.

307

es

eh

|

To show that this field has been set aside for use by the computer’s input-output system we must add a new paragraph, the I-OControl paragraph, to the Input-Output .Section of the Environment Division.

ONTROL,.,

PPLY RPLE-WORD 10 TRANSFER-REPLY ON

LI SCs ELE. 24) alee

deels rs

ae haze

Jet =

i

oe ee |

A

If, during the running of the program, an attempt is made to Read or Delete a record which is not on DISC-FILE, REPLYWORD will be set to a value of one. If the transfer is successful REPLY-WORD will have a value of zero.

We can test the value of REPLY-WORD |

ae

308

|

eset

UE yyy

in the usual way.

|

Sg

epee

gy

||

Index Table Buffers Let’s look a little more closely at how the computer translates a key number into a bucket number. As you know, each direct access file has, associated with it, a buffer

area in store equal in size to a bucket. When a Seek Statement is executed, the computer reads the index tables into the file’s buffer area. It then searches the table to find which bucket holds the record specified in the symbolic key field. Having found the correct bucket it reads that bucket into store overwriting the index table. From this you can see that each Seek Statement causes the index table to be read into store. This is all right where only a few records are to be accessed or where core store is limited but we can save a lot of time if we allocate a separate buffer for the index table and keep it in store during the running of the program.

309

To allocate a buffer area for the index table we must describe a record in working storage of the size we want. There are various factors involved in calculating the size of an index table and you must refer to the appropriate reference manual for details. On the 1900 series the table must be an integer number of buckets plus 12 characters.

Let’s say we need an area of 1036 characters.

NG-STORAGE, SECTION... |. | | ee: L REPLY-WORD, |PIC f.(24) SYNC!RICHES.

x(120) OODURS. 8 TIMES. We need to build the area up in this way since the maximum picture allowed for an elementary field is 120 characters.

310

}— |}+ —

To show that the area described in working-storage is to be used as an index table buffer, we add a new sentence to the I-O- Control paragraph.

pegertc dhs mrerel a einai ON, , —~WORD_TO TRANSFER-REPLY|

‘aTOINDEX-BUFFER ON

ee

Bit

Se

1

Question The personnel file of Luddite Electronics is held on an ICL 2802 Exchangeable Disc Store. The first five fields of each record have the forms. Record

Clock Number

Length

S

Name

Ba

name

|

Marital

Status ae surname

The bucket size of the file is 512 characters and the file has an

index table which occupies one bucket. We have been asked to write a program which will change the marital status, and if the employee is female, the surname of any

employee who has married. A small card file has been prepared of the personnel records which need to be changed. Clock

Marital

Number

Status

312

We want an index table buffer for the file and the clock number of any record which is not on the file is to be output to the line printer. Here are the Identification and Data Divisions; try writing the rest of the program.

ara) Lame bocail oe || aes |

woe

| DIVISION,

Gee

Le

E| SEQTION.

| sd]JFD | |CARD|-FILB

Foot tL ABBL RECORDS (OMETTED Jott

(ers DATA| RECORD IS| CARD-REC. el oe ss fa. | [CARDI-REC. | | TT |J@2 GQLOCKNO | PIC 9 (4).

TTT|(2 MAR-STAT ee i Peeideesex TTL 88 FEMALE rE,|102 SJURNAME

Sa)

PIC A.

PILCTOS VALUE JIS ZERO. PIC

A(|\2Q).

| | {FD | MASTIER-F ULE 512 |CHARACTERS| | JBLogk CONTAINS |]. | TT | LABEIL, REGORDS, |STAND|ARD VALUE OF [ID IS "PERSONNEL" {| | rT| (DATA RECORD | | (1, | MASTIER-REC.

IS; MASTIER-REC..

rsd.|(@2 SURNAME

PIC A( 29).

| |

PIC (2) OMP ee |)ORR IULER tne rT |(2 GLOCK-NUMB PIC 9(4 (id). PIC TLLL162 FILLER rT |(@2 MARITAL-STATUS

Pall

@2 FILLER

|

ie

PITC A. CA

-l..

IL. 313

|

|

|

|

ay)

|

inte.

sheet

edt

;Cc L Sequence

eee

SE

on

2

No.

[RONMENT DIVISION.

ila

-

Z

oreotiiiil

ONHIGURATION SECTION, |. Jisist ud ee eb dee URCE=

caehND

aanHeme1%

eed |

Ak

ee

PIG A120) conn) RS, a TIM BS.ai |

314

|

4.8

ie

Sequence

No,

:

oars

sheet

eo

IC L

' Me

20

25

DIVIs:

ON.

Ne)

DURA

AT

n lb LL

OPENe

al ee

LNEUD

30

35

Te ae

eee

eo ea

ST

fe

CARD-F

40

ye

esas

(OE

ee

eS

aS

eS SS SS

ese

fi

—-IN.



Se

ee(eae (a Ya

Sash

SS

ee!

Sp

|

READ CARU-=RILA AT BND GO TO HINISS..

|SESK MASTER-FILE RACORD, 1

TO

no

jy

TO

a

ee

IRTTE

pO M Ast

MASTHR-RiC

FINYS

i

ead!

i

RHAD-IN

se Sea al

Yi

| \cLOSe

(AA

ES See

GLOCKSN

| IDISBLAY WOQ

st

oCe ae Sse K

eT eee

1

| ee |

Cpe

et

TME-PRINTHR

BO (ce a

J

ce cee a

yt os ea

1

oe

ee

Hei Si IE

ee

1

ete

Sete

Sees

Lr

[erie eis

a

CARD-FLIUE MASTHR-HILE

=I et

ea

SURNAMY OF CARD-REC

as

SURNAMS

jt

GQ

a

ee

Ce ee

re

oi

MicomiomRD aT RS

=

fo

|

MOV MARSSTAT 20 MARTTATRSTATUS «|

GH-REG

F FEMALE MOV

ct

Se

ee

eth

aE

i

DIGP-PAR.

De De ORD EQUAoe eh Q. 10 DISPPAR. |

CHAS

Ie

INVALTO KSY ||

READ MASTER-FILE GO

J Stet

feaston

ea eee

eee

ed

le

a

Se

Rr

eae

fiat!

_



Le ee

OPEN INPUT-QUDPUT MASTER RTE 4

45

| (STOP

315

St om ei

-

Address Generation Sometimes a direct access file is arranged in such a way that it is possible to calculate the bucket number directly from the key number.

To take a very simple example; in a file, key numbers lie between 1000 and 5000 and we have stored the records five to a bucket in the following way: Bucket No.

1

Bucket No. 2

1000 1001 1002 1003 1004 To

find which

Bucket

1005 » 1006 1007 1008 1009 bucket

holds

No. 3

1010 1011 1012 1013 1014

the record

No.

1007

we

use

following procedure. Subtract 1000 from Key-No. Divide 5 into Result Add 1 to Result

316

1007 — 1000 = 7 7—5 1+ 1

= — Bucket No.

the

When we update a file using an address generation procedure to access to records, we must state in the Input-Output Section of the Environment Division that the access mode is random and that the organization is direct.

|SECTION

Zi

|

aie siecle NS Let cate

;

fetal

Ds) el reat

jeer se Ne

SCR MASTER-FILE [ASSIGNEDS| 1... |...| ACERS MODE 1S,eae Jims 6dieied feet GAIN DIRE In addition we must give the names of two fields which we have defined Key, is second number

in the Data Division. The first of these, called the Actual used to hold the bucket number we have calculated; the field, called the Symbolic Key, is used to hold the key of the record we want.

ACTUAL aa

KEY

Sule

Sa Bn

BEE

No | LOTS

wee

317

The Procedure

Division

When we access a record which has been found by an address generation procedure, the Read Write and Delete Statements need the Invalid Key clause.

| READ-IN.

|| | [PERFORM ADD-GEN.

ql

READ

BAS

ees F ULE

INV ALID

KEY

You must be careful when writing the address generation procedure that the Symbolic Key is not destroyed since this is still needed by the computer to find the record.

318

Question Let’s say that we can find the bucket number of any record in the master file of the last program by an address generation process.

Rewrite the Input-Output Section and the paragraph FIND-REC so that we can find the record without using the index table. The address generation procedure is in a paragraph called TRANSPAR. You will also need to change the Working Storage Section.

319

Answer

UITNPIUT-OUTPUT,

|SECT ION. ee | bie -CONTROL || , 1 SELECT CARD-FI|LE AS|SIGN ee tl T| | SELECT MASTER-FILE |ASSIGN EDS| J r{ | ACCESS MGDE IS| RANDOM || (ORGANIZATION IS DIRECT |. ACTUAL KHY IS |BUCKE|T-NO i SYMBIOLIC |KEY, I|S_ CLO?K-NO.

Hlea

|

biiiewal

u

oe 7 BUCKET-NO PIC 9(4)._, Peeaeersnss

te f

||. |PERFORM TRANS-PAR. |. |... cipecraans=FILEINVALID) KEY

L

42) TO

320

DISP- “EAR

ober oy silaa toe eee

|

Conclusion It is difficult to understand a program written by someone else, it is often just as difficult to understand a program written by yourself some time ago. A Cobol program is probably easier to follow than one written in any other language but we can improve the readability of a program and provide the essential documentation if we take full advantage of the facilities offered by Cobol.

Here is the Identification Division of MARI50 expanded to show the optional documentation paragraphs.

&

i}

35

30

25

20

15

7

INTIFICATIONDIVISION.

Law,

ae

sar

Sagan sheet

ICL

PROGRAM=ID.

1

ee

RISQ.

ee eet

Away INST

1

He

2a

Ll

pe

WAITTERS|, eeeen

=

es

\JANUARY

-COMP ILED,.

|

Oe

eS

i

a

fae

Se

a

hak

are

jae

TSS |

|

2k

|

|Soe ce: ee

PAIRK.

ee eae _ J 1ST

i

7

Se

Sel

jee SN

WiFi

eel wera

|

es:

ee

DATE|-WRITTEN.

|

a

55,

50

i

teci La ‘cl artic

i

Weoeet

IPATEgL ON Clee

HEDSOR

45

|

a

(Rae

| ae

|,

40

|

|

19/7¢.

|

[| i ee | IREMAIRKS.. NEL", B "PERSON UPDATES, PROGRAM [THIS| | | : AND, TF| THE [i (ALTERING |THE, MARITAL, STATUS, OPEANY cl), cel E, ©, SURNAM [THE, | “| EMPLOYEE, [L8, FEMALE, tees —— E MARRIED).

He

(WHO HIAS "| [EMPLOYE

aa

eter

| tele:

ete

|

eee

er

|e

as

321

|

JL si

tite

SSS

oat

jj

In the Procedure Division we can include comments

in the text

by using a Note Sentence.

|. |

ICOMMENTSPAR.,

||

protic

9 eal

r ||| NOTE) THE [PARAGRAPH ADD-GEN CONTAIN THE |ADDRBSS GENERATION PROCEDURES, Ree | |

eet

aes

|

|

|

If NOTE is the first word of a paragraph then the whole paragraph is taken to be a comment. The paragraph is printed when the program is listed but causes no coding to be generated when the program is compiled. A Note Sentence can be included in a paragraph but here the comment ends at the first full stop after the word NOTE.

322

|

Finally, Cobol includes many optional words which can be inserted in a program to improve its readability. In this programmed text we have made no distinction between optional words and those words called key words which must appear in a statement. Your reference manual will tell you which words are key words and which are optional.

We failed to make this distinction in the hope that it would simplify your task of learning Cobol and have if anything erred on the side of using too few optional words. When you start programming in earnest don’t ignore the many options offered by Cobol to improve the readability of your program. A little extra effort put into writing a program will repay you when you come to change the program long after you’ve forgotten it existed.

323

Appendix A Reserved

words

In the following list, optional words are marked with a single dagger [t]. Words which are sometimes optional and sometimes key words depending on the context are marked with a double

dagger [T1]. All the other members of the list are COBOL Keywords.

TABOUT ACCEPT ACCESS ACTIVE-TIME ACTUAL

ADD

TADVANCING AFTER ALL ALPHABETIC

324

ALPHANUMERIC ALTER + ALTERNATE AN AND

APPLY

TARE TAREA TAREAS ASCENDING

ASSIGN AT TAUTHOR BEFORE BIT-nn

(where

oo < nn < 23) BITS BLANK BLOCK

BY CALL CARD-PUNCH CARD-READER CASSETTE-* CASSETTES CHANNEL-I CHANNEL-2 CHANNEL-3 CHANNEL-4 CHANNEL-5 CHANNEL-6 CHANNEL-7 CHARACTERS CHECK CHEQUE CLASS CLOSE COMMA COMP COMP-I COMPUTATIONAL COMPUTATIONAL-I CONFIGURATION CONSTANT CONTAINS CONTROL COPY CORE-EDS CORE-MT CORRESPONDING CORR CURRENCY DATA *DATE +DATE-COMPILED +DATE-WRITTEN

DECIMAL-POINT DELETE DEPENDING DESCENDING

DIGITS DIRECT DISPLAY DISPLAY-I DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DIVIDE DIVISION EDS EDS-* ELSE {TEND ENTER ENVIRONMENT EQUAL EQUALS ERROR TEVERY EXAMINE EXCEEDS EXIT FD FDS FDs-*

FILE FILE-CONTROL FILE-MESSAGE FILLER FIRST FIRST-LEVEL FLOAT FOR FROM GENERATION-NO GIVING GO GREATER HAND-KEYS HIGH-VALUE

HIGH-VALUES ID IDENTIFICATION IF IN INDEX-BUFFER INDEXED INPUT INPUT-OUTPUT INSTALLATION INTO INVALID I-O I-O-CONTROL

TTIs JUST JUSTIFIED KEY KEYS LABEL LEADING LEAVING LEFT LESS TLINES LINKAGE TLOCATION LOCK LOW-VALUE LOW-VALUES LOWER-BOUND LOWER-BOUNDS MCF MCF-* MEMORY TMODE MOVE MULTIPLE MULTIPLY NEGATIVE NEXT

325

NO

RECORDS

SUBTRACT

NOT NOTE NUMERIC

REDEFINES REEL RELEASE

SUPPRESS SYMBOLIC SYNC

OBJECT-COMPUTER OBJECT-PROGRAM OCCURS

TTOF OFF OMITTED

+TON

= {REMARKS RENAMES REPLACING

RERUN RESERVE RETURN

REWIND

THEN

REWRITE RIGHT ROUNDED

ORGANIZATION OTHERWISE

RUN SAME

{RECORD RECORDING

326

TAPE-* TAPES +THAN

OPEN OR ORGANISATION

OUTPUT PAPER-PUNCH PAPER-READER PERFORM PIC PICTURE +PLACES POINT POSITIVE PRINTER PROCEDURE PROCEED PROCESSING PROGRAM PROGRAM-ID +PROTECT QUOTE QUOTES RANDOM RANGE READ

SYNCHRONISED SYNCHRONIZED TALLYING

SECOND-LEVEL SECTION SECURITY SEEK SEGMENT-LIMIT SELECT SENTENCE SENTINELPROCESSING SEQUENCED SEQUENTIAL SIGN SIGNED SIZE SORT SORT-* SOURCE-COMPUTER SPACE SPACES SPECIAL-NAMES STANDARD

+STATUS STOP

THROUGH THRU TIME * +TTIMES TTTO

TRANSFER-REPLY TYPE TYPEWRITER UNEQUAL UNTIL UPON UPPER-BOUND UPPER-BOUNDS TUSAGE USING VALUE VALUES VARYING +WHEN WITH WORDS WORKING-STORAGE WRITE ZERO ZEROES ZEROS

Appendix B Alphanumeric

data character set

0 to 9 : colon

( )

; < = >

Eeerasterisk. + plus sign , comma — munus

semi-colon less than equal sign greater than



left parenthesis right parenthesis

full stop or decimal point

question mark

.

+t

space exclamation mark quotation mark number sign

/ oblique stroke @ at sign AtoZ [ left bracket

°% & >

pound sign percentage ampersand apostrophe

$ ] *

IS LESS THAN St TSeEOUAT RIO EQUALS IS =

IS NOT

GREATER

ISPNO IS NOT IS NOT IS NOT

De LESS

THAN

< EQUAL

IS NOT = IS UNEQUAL

THAN

TO

TO

Sign Conditions. PSeLlOsimiveE IS NEGATIVE IS ZERO

IS NOT IS NOT IS NOT

POSITIVE NEGATIVE ZERO

IS NOT IS NOT

NUMERIC ALPHABETIC

Class Conditions.

IS NUMERIC IS ALPHABETIC

Words not underlined are optional, that is they can be omitted when writing the Conditions.

ae)

Index Access Mode 278 random 297 sequential 278 Active Time 258

Enter 241 ) de, Environment Division Exit 221 Exit Program 233

wie eee fe after 44 before 44 And 177 Apply—To Index-Buffer pply—To Index-Buffer

File Description File Names 11 File Section 15 Filler 27

At End

O On

311

39

Blank When Zero 82 Block Contains 255 Call

If 107

Insertion Characters

Computational 149 Computational-1 264 Compute 1

Condition Nea

Invalid Key I-O-Control

181

177

condition-name conditions

relation conditions

sign conditions

174

174

Configuration Section Continuation Indicator

Currency Symbol

107

Data Description

23

Data Division 15 Data Names 11 Data Record 16 Delete 290 269

EDS

336

256

figurative constants numeric

61

231

Literals 60

non-numeric

8

20

60

60

Magnetic Tape

Memory

9

2 49

Mnemonic Names

51

Not 174 Object Computer

129

Object Program Occurs 198

269

Elementary Fields

Level Numbers Lines 44 | Linkage Section

Move 55_ alphabetic 55 arithmetic 116 Multiply 129

Display 366 Display-n 87 Divide

183

Open

19

Ontiry7

32

10

96

304 308

Label Record

Conditions 174 class conditions 174 compound conditions

1

169

Input-Output Section

33

Direct Access

40, 193

Identification Division

47

Cheque Protection

Close

SS

Go To

15

Group Fields 19 Hardware Names 51

234

Channel-n

Lig

7

9 9

62, 122

Organization 297 direct 316 indexed 297 Paragraph 35 Perform 217 Picture 24 Procedure Division Procedures 217 Program-Id 2 Program Name 3

31

Qualified Data Names Read 39 Record Description 19 Record Size 263 Redefines 207 Report Signs 91 arithmetic 91 sterling 108 Reserved Words II Rewrite

Rounded

289

77

Size Error 135 Source Computer 9 Special Names 51 Statements 31 Stop Literal 139 Stop Run 34 Subroutines 227 Cobol 227 other language 241 Subscripted Data Names Subtract 126 Symbolic Key 297 Synchronized 150 Tapes Times”

250 225

Transfer Replies Until

197

307

225

Value 153 Value of Id 257 Varying 226

134

Seek 303 Select—Assign Sentences 35

Working Storage Section Write 43

148

12

Zero Suppression

81

33/7,

~>

@

"| i

tj nine

icone —2i\t iad

. =