       ID  DIVISION.
       PROGRAM-ID. GENESDS.
       AUTHOR. UNIKIX.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT  OUTREC1  ASSIGN TO EBMOUT1
                            ORGANIZATION IS SEQUENTIAL
                            ACCESS IS SEQUENTIAL
                            FILE STATUS IS OUTREC1-STATUS.
       DATA DIVISION.
       FILE SECTION.
       FD  OUTREC1.
       01  OUT-ACCTREC.
           02  OUT-DOACCT               PIC 9(9) COMP.
           02  OUT-DOSNAME              PIC X(18).
           02  OUT-DOFNAME              PIC X(12).
           02  OUT-DOMI                 PIC X.
           02  OUT-DOTTL                PIC X(4).
           02  OUT-DOTEL                PIC X(10).
       WORKING-STORAGE SECTION.
       01  OUTREC1-STATUS         PIC  9(2) VALUE ZEROES.
       01  CONDCODE               PIC S9(4) COMP.
       01  COUNTREC               PIC 9(9) COMP.
       01  MOD-COUNTREC           PIC 9(9) COMP.
       01  DISPLAY-RECS           PIC 9(1) VALUE 0.
       PROCEDURE DIVISION.
         OPEN OUTPUT OUTREC1.
         IF OUTREC1-STATUS NOT = 00 GO TO ABTPRIMSEQOUT1.
         MOVE 1 TO COUNTREC.
         DISPLAY '================================================='.
       LOOP-REC.
           MOVE COUNTREC TO OUT-DOACCT.
           MOVE FUNCTION MOD (COUNTREC 10000) TO MOD-COUNTREC.
           IF MOD-COUNTREC = ZERO
           THEN
             DISPLAY '  ' OUT-DOACCT ' RECORDS WRITTEN'
           END-IF.
           WRITE OUT-ACCTREC.
           IF OUTREC1-STATUS > 02 GO TO PRIMSEQIOERW1.
           IF DISPLAY-RECS > 0
             DISPLAY 'Writing RECORD  '  OUT-DOACCT.
           IF COUNTREC = 500000
           THEN
             GO TO ENDLOOP1
           END-IF.
           ADD 1 TO COUNTREC.
           GO TO LOOP-REC.
       ENDLOOP1.
         DISPLAY '================================================='.
         DISPLAY ' NUMBER OF RECORDS PROCESSED = ' COUNTREC.
         CLOSE OUTREC1.
	        STOP RUN.
       PRIMSEQIOERW1.
         DISPLAY ' ERROR WRITING OUTPUT1 FILE. STATUS = ' OUTREC1-STATUS 
         MOVE OUTREC1-STATUS TO CONDCODE.
         CLOSE OUTREC1.
         CALL "CCF_SET_CONDCODE" USING CONDCODE.
         STOP RUN.
       ABTPRIMSEQOUT1.
         DISPLAY ' ERROR OPENING OUTPUT1 FILE. STATUS = ' OUTREC1-STATUS 
         MOVE OUTREC1-STATUS TO CONDCODE.
         CALL "CCF_SET_CONDCODE" USING CONDCODE.
         STOP RUN.
