Managing Information Technology

(Frankie) #1

of a large corporation. Each salesperson earns a 1 percent
commission on the first $50,000 in sales during a month
and a 2 percent commission on all sales in excess of
$50,000. The data have already been keyed in and are
stored as a data file on a magnetic disk. One record has
been prepared for each salesperson, containing the person’s
name and sales for the month. The output is to be a printed
line for each salesperson, showing the name, monthly sales,


Chapter 2 • Computer Systems 45

and sales commission. In addition, the program is to accu-
mulate the total commissions for all salespersons and to
print this amount after all the salespersons’ records have
been processed.
Figure 2.11 provides a COBOL program to accom-
plish this processing. The details are not important, but
note the four divisions of the program and the sheer length
of this relatively simple program.

1 8 12

WORKING–STORAGE SECTION.
01 SALES–RECORD.
05 NAME
05 FILLER
05 SALES
05 FILLER
01 COMMISSION–RECORD.
05 FILLER
05 NAME–OUT
05 FILLER
05 SALES–OUT
05 FILLER
05 COMMISSION
05 FILLER
77 TEMP–COMMISSION
77 TOTAL–COMMISSIONS
77 TOTAL–COMM–EDITED
01 MORE–DATA
88 THERE–IS–MORE–DATA
88 THERE–IS–NO–MORE–DATA

PICTURE A(30).
PICTURE X(10).
PICTURE 9(8)V99.
PICTURE X(30).

PICTURE X(10).
PICTURE A(30).
PICTURE X(10).
PICTURE $$$,$$$,$$$.99.
PICTURE X(10).
PICTURE $$$$,$$$.99.
PICTURE X(47).
PICTURE 9(6)V99.
PICTURE 9(10)V99 VALUE 0.
PICTURE $$,$$$,$$$,$$$.99.
PICTURE X VALUE ‘Y’.
VALUE ‘Y’.
VALUE ‘N’.

IDENTIFICATION DIVISION.
PROGRAM–ID. COMMISSIONS–COMPUTE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE–COMPUTER. IBM–AS400.
OBJECT–COMPUTER. IBM–AS400.
INPUT–OUTPUT SECTION.
FILE–CONTROL.
SELECT SALES–FILE ASSIGN DISK-FILEIPT.
SELECT COMMISSIONS–FILE ASSIGN DISK-FILERPT.
DATA DIVISION.
FILE SECTION.
FD SALES–FILE
LABEL RECORD OMITTED
RECORD CONTAINS 80 CHARACTERS
DATA RECORD IS IN–RECORD.
01 IN–RECORD PICTURE X(80).
FD COMMISSIONS–FILE
LABEL RECORD OMITTED
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS PRINT–RECORD.
01 PRINT–RECORD PICTURE X(132).

FIGURE 2.11 COBOL Program
Free download pdf