       ID  DIVISION.
       PROGRAM-ID. PRIMER.
       AUTHOR. UNIKIX.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT  INREC    ASSIGN TO INPUT1
                            ORGANIZATION IS INDEXED
                            ACCESS IS SEQUENTIAL
                            RECORD KEY IS DOACCT
                            FILE STATUS IS INREC-STATUS.

       DATA DIVISION.
       FILE SECTION.
       FD  INREC.
       01  ACCTREC.
           02  DOACCT               PIC X(5).
           02  DOSNAME              PIC X(18).
           02  DOFNAME              PIC X(12).
           02  DOMI                 PIC X.
           02  DOTTL                PIC X(4).
           02  DOTEL                PIC X(10).
           02  DOADDR1              PIC X(24).
           02  DOADDR2              PIC X(24).
           02  DOADDR3              PIC X(24).
           02  DOAUTH1              PIC X(32).
           02  DOAUTH2              PIC X(32).
           02  DOAUTH3              PIC X(32).
           02  DOAUTH4              PIC X(32).
           02  DOCARDS              PIC X.
           02  DOIMO                PIC X(2).
           02  DOIDAY               PIC X(2).
           02  DOIYR                PIC X(2).
           02  DORSN                PIC X.
           02  DOCCODE              PIC X.
           02  DOAPPR               PIC X(3).
           02  DOSCODE1             PIC X.
           02  DOSCODE2             PIC X.
           02  DOSCODE3             PIC X.
           02  DOSTAT               PIC X(2).
           02  DOLIMIT              PIC X(8).
           02  FILLER               PIC X(108).
       WORKING-STORAGE SECTION.
       01  INREC-STATUS           PIC  9(2) VALUE ZEROES.
       01  CONDCODE               PIC S9(4) COMP.
       01  COUNTREC               PIC 9(9) COMP.
       PROCEDURE DIVISION.
         DISPLAY ' READING KSDS FILE '.
         OPEN INPUT INREC.
         IF INREC-STATUS NOT = 00 GO TO ABTPRIMER.
         MOVE ZERO TO COUNTREC.
         DISPLAY '================================================='.
       LOOP1.
         READ INREC AT END GO TO ENDLOOP1.  
         IF INREC-STATUS > 02 GO TO PRIMERIOERR.
         ADD 1 TO COUNTREC.
         DISPLAY DOACCT ' '  DOSNAME ' ' DOFNAME.
         GO TO LOOP1.
       ENDLOOP1.
         DISPLAY '================================================='.
         DISPLAY ' NUMBER OF RECORDS PROCESSED = ' COUNTREC.
         MOVE ZERO TO COUNTREC.
         MOVE 10002 TO DOACCT.
         START INREC KEY > DOACCT.
         IF INREC-STATUS NOT = 00 THEN GO TO STATUS-ERROR.
         DISPLAY ' STARTING FROM KEY > ' DOACCT.
         DISPLAY '================================================='.
       LOOP2.
         READ INREC AT END GO TO ENDPRIMER.  
         IF INREC-STATUS > 02 GO TO PRIMERIOERR.
         ADD 1 TO COUNTREC.
         DISPLAY DOACCT ' '  DOSNAME ' ' DOFNAME.
         GO TO LOOP2.
       ENDPRIMER.
         CLOSE INREC.
         DISPLAY '================================================='.
         DISPLAY ' NUMBER OF RECORDS PROCESSED = ' COUNTREC.
	        GOBACK.
       STATUS-ERROR.
         CLOSE INREC.
         DISPLAY ' THE START COMMAND FAILS, STATUS ' INREC-STATUS.
         MOVE INREC-STATUS TO CONDCODE.
         CALL "CCF_SET_CONDCODE" USING CONDCODE.
         STOP RUN.
       PRIMERIOERR.
         CLOSE INREC.
         DISPLAY ' ERROR READING FILE. STATUS = ' INREC-STATUS.
         MOVE INREC-STATUS TO CONDCODE.
         CALL "CCF_SET_CONDCODE" USING CONDCODE.
         STOP RUN.
       ABTPRIMER.
         DISPLAY ' ERROR OPENING FILE. STATUS = ' INREC-STATUS.
         MOVE INREC-STATUS TO CONDCODE.
         CALL "CCF_SET_CONDCODE" USING CONDCODE.
         STOP RUN.
