IDENTIFICATION DIVISION. PROGRAM-ID. VJLAB1. AUTHOR. VICKI JONATHAN. DATE-WRITTEN. 09-01-98. **************************************************************** * * * THIS PROGRAM READS AN INPUT FILE AND WRITES A RECORD. * * IT ALSO SERVES AS AN EXAMPLE OF CLASS STANDARDS. * * * **************************************************************** ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-370. OBJECT-COMPUTER. IBM-370. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPUT-FILE ASSIGN TO UT-S-INPUT1. SELECT OUTPUT-FILE ASSIGN TO UT-S-OUTPUT1. DATA DIVISION. FILE SECTION. **************************************************************** * I N P U T F I L E * **************************************************************** FD INPUT-FILE BLOCK CONTAINS 0 RECORDS RECORD CONTAINS 80 CHARACTERS RECORDING MODE IS F LABEL RECORDS ARE STANDARD DATA RECORD IS INPUT-RECORD. 01 INPUT-RECORD PIC X(80). **************************************************************** * O U T P U T F I L E * **************************************************************** FD OUTPUT-FILE BLOCK CONTAINS 0 RECORDS RECORD CONTAINS 80 CHARACTERS RECORDING MODE IS F LABEL RECORDS ARE STANDARD DATA RECORD IS OUTPUT-RECORD. 01 OUTPUT-RECORD PIC X(80). *************************************************************** * * * W O R K I N G S T O R A G E * * * *************************************************************** WORKING-STORAGE SECTION. *************************************************************** * INDICATORS AND FLAGS * *************************************************************** 01 WS-FLAGS. 05 EOF-IND PIC XXX VALUE "NO ". *************************************************************** * WORK FIELDS * *************************************************************** 01 WS-WORK-FIELDS. 05 WS-CNT-RECS PIC 9(3) VALUE ZERO. 05 WS-DATE. 10 WS-YY PIC 99 VALUE ZERO. 10 WS-MM PIC 99 VALUE ZERO. 10 WS-DD PIC 99 VALUE ZERO. *************************************************************** * INPUT RECORD * *************************************************************** 01 IN-RECORD. 05 IN-CHECK2 PIC X(02) VALUE SPACES. 05 IN-FIELD78 PIC X(78) VALUE SPACES. *************************************************************** * OUTPUT HEADER RECORD * *************************************************************** 01 OUT-HDR. 05 FILLER PIC X(40) VALUE "----+----1----+----2----+----3----+----4". 05 FILLER PIC X(40) VALUE "----+----5----+----6----+----7----+----8". *************************************************************** * OUTPUT DETAIL RECORD (REPORT BODY) * *************************************************************** 01 OUT-RECORD PIC X(80) VALUE SPACES. *************************************************************** * OUTPUT FOOTER RECORDS * *************************************************************** 01 OUT-FOOTERS. 05 OUT-FTR1. 10 FILLER PIC X(40) VALUE "----+----1----+----2----+----3----+----4". 10 FILLER PIC X(40) VALUE "----+----5----+----6----+----7----+----8". 05 OUT-FTR2 PIC X(80) VALUE "END OF VJLAB1A". **************************************************************** * * * P R O C E D U R E D I V I S I O N * * * **************************************************************** PROCEDURE DIVISION. **************************************************************** * M A I N L I N E C O N T R O L P A R A G R A P H * **************************************************************** A000-CONTROL. PERFORM B000-INITIALIZE. PERFORM C000-PROCESS UNTIL EOF-IND = "YES". PERFORM D000-FINALIZE. STOP RUN. **************************************************************** * I N I T I A L I Z E P A R A G R A P H * **************************************************************** B000-INITIALIZE. OPEN INPUT INPUT-FILE OUTPUT OUTPUT-FILE. MOVE "NO " TO EOF-IND. PERFORM U100-READ-INPUT. **************************************************************** * P R O C E S S I N G P A R A G R A P H * **************************************************************** C000-PROCESS. IF IN-CHECK2 = "VJ" WRITE OUTPUT-RECORD FROM OUT-HDR ELSE IF IN-CHECK2 = "04" MOVE "04 ** VICKI JONATHAN" TO OUT-RECORD ELSE MOVE IN-RECORD TO OUT-RECORD END-IF WRITE OUTPUT-RECORD FROM OUT-RECORD END-IF. PERFORM U100-READ-INPUT. **************************************************************** * F I N A L I Z A T I O N P A R A G R A P H * **************************************************************** D000-FINALIZE. WRITE OUTPUT-RECORD FROM OUT-FTR1. MOVE SPACES TO OUT-RECORD. WRITE OUTPUT-RECORD FROM OUT-RECORD. WRITE OUTPUT-RECORD FROM OUT-FTR2. CLOSE INPUT-FILE OUTPUT-FILE. **************************************************************** * R E A D P A R A G R A P H * **************************************************************** U100-READ-INPUT. READ INPUT-FILE INTO IN-RECORD AT END MOVE "YES" TO EOF-IND.