ID DIVISION.
PROGRAM-ID.  SLS02.
FILE-CONTROL.
	SELECT SALESPERSON-FILE
		ASSIGN TO DISK.
	SELECT REPORT-FILE
		ASSIGN TO PRINTER.
DATA DIVISION.
FILE SECTION.
001000
 FD  SALESPERSON-FILE.
 01  SALESPERSON-RECORD.
	05  FILLER              PIC XX.
	05  SP-NUMBER           PIC X(4).
	05  SP-NAME             PIC X(18).
	05  FILLER              PIC X(21).
	05  SP-CURRENT-SALES    PIC 9(5)V99.
	05  SP-CURRENT-RETURNS  PIC 9(4)V99CR.
 FD  REPORT-FILE.
 01  REPORT-RECORD.
	05  FILLER              PIC X(10).
	05  RT-NUMBER           PIC X(4).
	05  FILLER              PIC X(6).
	05  RT-NAME             PIC X(18).
	05  FILLER              PIC X(6).
	05  RT-CURRENT-SALES    PIC ZZ,ZZZ.99.
	05  FILLER              PIC X(6).
	05  RT-CURRENT-RETURNS  PIC Z,ZZZ.99CR.
	05  FILLER              PIC X(65).
 WORKING-STORAGE SECTION.
	01  WS-EOF-FLAG             PIC X.
*
	PROCEDURE DIVISION.
*
	MAIN-ROUTINE.
		OPEN INPUT SALESPERSON-FILE
			OUTPUT REPORT-FILE
		MOVE "N" TO WS-EOF-FLAG
		READ SALESPERSON-FILE
			AT END MOVE "Y" TO WS-EOF-FLAG
			END-READ
*
		PERFORM UNTIL WS-EOF-FLAG IS EQUAL TO "Y"
			MOVE SPACES TO REPORT-RECORD
			MOVE SP-NUMBER TO RT-NUMBER
			MOVE SP-NAME TO RT-NAME
			MOVE SP-CURRENT-SALES TO RT-CURRENT-SALES
			MOVE SP-CURRENT-RETURNS TO RT-CURRENT-RETURNS
			WRITE REPORT-RECORD
			READ SALESPERSON-FILE
				AT END MOVE "Y" TO WS-EOF-FLAG
			END-READ
		END-PERFORM
*
		CLOSE SALESPERSON-FILE, REPORT-FILE
		STOP RUN.
