﻿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.