The COBOL Programming Language

Salesperson File


Click below to go directly to a specific section:
Description | Source Code | Sample Run | Program Notes


Description

This program takes all input records of salesperson data and writes it to an output file reformatted.


Source Code


000100 ID DIVISION.
000200 PROGRAM-ID.  SLS02.
000300 FILE-CONTROL.
000400     SELECT SALESPERSON-FILE
000500         ASSIGN TO DISK.
000600     SELECT REPORT-FILE
000700         ASSIGN TO PRINTER.
000800 DATA DIVISION.
000900 FILE SECTION.
001000 FD  SALESPERSON-FILE.
001100 01  SALESPERSON-RECORD.
001200     05  FILLER              PIC XX.
001300     05  SP-NUMBER           PIC X(4).
001400     05  SP-NAME             PIC X(18).
001500     05  FILLER              PIC X(21).
001600     05  SP-CURRENT-SALES    PIC 9(5)V99.
001700     05  SP-CURRENT-RETURNS  PIC 9(4)V99.
001800 FD  REPORT-FILE.
001900 01  REPORT-RECORD.
002000     05  FILLER              PIC X(10).
002100     05  RT-NUMBER           PIC X(4).
002200     05  FILLER              PIC X(6).
002300     05  RT-NAME             PIC X(18).
002400     05  FILLER              PIC X(6).
002500     05  RT-CURRENT-SALES    PIC ZZ,ZZZ.99.
002600     05  FILLER              PIC X(6).
002700     05  RT-CURRENT-RETURNS  PIC Z,ZZZ.99.
002800     05  FILLER              PIC X(65).
002900 WORKING-STORAGE SECTION.
003000 01  WS-EOF-FLAG             PIC X.
003100*
003200 PROCEDURE DIVISION.
003300*
003400 MAIN-ROUTINE.
003500     OPEN INPUT SALESPERSON-FILE
003600         OUTPUT REPORT-FILE
003700     MOVE "N" TO WS-EOF-FLAG
003800     READ SALESPERSON-FILE
003900         AT END MOVE "Y" TO WS-EOF-FLAG
004000     END-READ
004100*
004200 PERFORM UNTIL WS-EOF-FLAG IS EQUAL TO "Y"
004300     MOVE SPACES TO REPORT-RECORD
004400     MOVE SP-NUMBER TO RT-NUMBER
004500     MOVE SP-NAME TO RT-NAME
004600     MOVE SP-CURRENT-SALES TO RT-CURRENT-SALES
004700     MOVE SP-CURRENT-RETURNS TO RT-CURRENT-RETURNS
004800     WRITE REPORT-RECORD
004900     READ SALESPERSON-FILE
005000         AT END MOVE "Y" TO WS-EOF-FLAG
005100     END-READ
005200 END-PERFORM
005300*
005400 CLOSE SALESPERSON-FILE, REPORT-FILE
005500 STOP RUN.

Sample Run


          0005      BENNETT ROBERT           1,600.35         12.50
          0016      LOCK ANDREW S              357.72         79.85
          0080      PARKER JAMES E          18,200.00        165.00
          0401      REDDING OLIVIA          16,123.99      2,301.75
          1375      BENTON ALEX J            3,250.00         56.50
          1442      ADAMS JUNE R             4,635.21        125.16
          1842      COLE ROBERT N           14,285.14      6,385.29

Program Notes

This program was tested and run using the RM/ COBOL-85 compiler.


[Back] [Home]


Last modified: 11:39 PM on 10/04/1999