JCL
//GUI1504J JOB (GUI1504),GUI1504,CLASS=A,MSGCLASS=X,NOTIFY=GUI1504
//PROCLIB JCLLIB ORDER=IBMMFS.PROC.IBMCOB
//COMPILE EXEC IGYWCG
//ENTRADA DD DSN=GUI1504.FINAL.ENTRADA,DISP=SHR
//COBOL.SYSIN DD DSN=GUI1504.FINAL.COBOL,DISP=SHR
//SYSPRINT DD SYSOUT=*
/*
//PROCLIB JCLLIB ORDER=IBMMFS.PROC.IBMCOB
//COMPILE EXEC IGYWCG
//ENTRADA DD DSN=GUI1504.FINAL.ENTRADA,DISP=SHR
//COBOL.SYSIN DD DSN=GUI1504.FINAL.COBOL,DISP=SHR
//SYSPRINT DD SYSOUT=*
/*
COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. FNAL.
*
ENVIRONMENT DIVISION.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ENTRADA
ASSIGN TO ENTRADA
FILE STATUS IS WS-STATUS.
*
*
DATA DIVISION.
*
FILE SECTION.
FD ENTRADA
LABEL RECORD IS STANDARD
RECORDING MODE IS F
RECORD CONTAINS 80 CHARACTERS.
*
01 REG-FILE PIC X(80).
*
WORKING-STORAGE SECTION.
*
01 WS-STATUS PIC X(02).
01 WS-REGISTRO.
10 WS-CODIGO PIC 9(04).
10 WS-NOME PIC X(30).
10 WS-ESTADO PIC X(02).
10 FILLER PIC X(44).
01 WS-ESTADOS PIC X(54).
01 WS-SIGLAS REDEFINES WS-ESTADOS.
10 WS-SIGLA PIC X(02) OCCURS 27 TIMES.
01 WS-FLAG PIC X(03) VALUE 'NAO'.
01 WS-CONTADOR PIC X(02).
*
PROCEDURE DIVISION.
*
0000-MAIN.
PERFORM 1000-START.
PERFORM 2000-PERFORM UNTIL WS-FLAG EQUAL 'SIM'.
PERFORM 3000-END.
STOP RUN.
*
1000-START.
INITIALIZE WS-CONTADOR.
OPEN INPUT ENTRADA.
IF WS-STATUS NOT EQUAL 00
DISPLAY 'ERRO AO ABRIR O ARQUIVO!'
DISPLAY 'STATUS = ' WS-STATUS
STOP RUN
END-IF.
PERFORM 1500-READ.
IF WS-FLAG EQUAL 'SIM'
DISPLAY 'ARQUIVO VAZIO'
ELSE
DISPLAY 'ARQUIVO OK!'
END-IF.
*
1500-READ.
READ ENTRADA INTO WS-REGISTRO AT END MOVE 'SIM' TO WS-FLAG.
*
2000-PERFORM.
DISPLAY 'CODIGO DO CLIENTE: ' WS-CODIGO.
DISPLAY 'NOME DO CLIENTE ' WS-NOME.
MOVE 'SIM' TO WS-FLAG.
*
3000-END.
CLOSE ENTRADA.
PROGRAM-ID. FNAL.
*
ENVIRONMENT DIVISION.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ENTRADA
ASSIGN TO ENTRADA
FILE STATUS IS WS-STATUS.
*
*
DATA DIVISION.
*
FILE SECTION.
FD ENTRADA
LABEL RECORD IS STANDARD
RECORDING MODE IS F
RECORD CONTAINS 80 CHARACTERS.
*
01 REG-FILE PIC X(80).
*
WORKING-STORAGE SECTION.
*
01 WS-STATUS PIC X(02).
01 WS-REGISTRO.
10 WS-CODIGO PIC 9(04).
10 WS-NOME PIC X(30).
10 WS-ESTADO PIC X(02).
10 FILLER PIC X(44).
01 WS-ESTADOS PIC X(54).
01 WS-SIGLAS REDEFINES WS-ESTADOS.
10 WS-SIGLA PIC X(02) OCCURS 27 TIMES.
01 WS-FLAG PIC X(03) VALUE 'NAO'.
01 WS-CONTADOR PIC X(02).
*
PROCEDURE DIVISION.
*
0000-MAIN.
PERFORM 1000-START.
PERFORM 2000-PERFORM UNTIL WS-FLAG EQUAL 'SIM'.
PERFORM 3000-END.
STOP RUN.
*
1000-START.
INITIALIZE WS-CONTADOR.
OPEN INPUT ENTRADA.
IF WS-STATUS NOT EQUAL 00
DISPLAY 'ERRO AO ABRIR O ARQUIVO!'
DISPLAY 'STATUS = ' WS-STATUS
STOP RUN
END-IF.
PERFORM 1500-READ.
IF WS-FLAG EQUAL 'SIM'
DISPLAY 'ARQUIVO VAZIO'
ELSE
DISPLAY 'ARQUIVO OK!'
END-IF.
*
1500-READ.
READ ENTRADA INTO WS-REGISTRO AT END MOVE 'SIM' TO WS-FLAG.
*
2000-PERFORM.
DISPLAY 'CODIGO DO CLIENTE: ' WS-CODIGO.
DISPLAY 'NOME DO CLIENTE ' WS-NOME.
MOVE 'SIM' TO WS-FLAG.
*
3000-END.
CLOSE ENTRADA.
ENTRADA
0001NOME-DO-CLIENTE-01------------AC
0002NOME-DO-CLIENTE-02------------AL
0003NOME-DO-CLIENTE-03------------AP
0004NOME-DO-CLIENTE-04------------AM
0005NOME-DO-CLIENTE-05------------BA
0006NOME-DO-CLIENTE-06------------CE
0007NOME-DO-CLIENTE-07------------DF
0008NOME-DO-CLIENTE-08------------ES
0009NOME-DO-CLIENTE-09------------GO
0010NOME-DO-CLIENTE-10------------MA
0011NOME-DO-CLIENTE-11------------MT
0012NOME-DO-CLIENTE-12------------MS
0013NOME-DO-CLIENTE-13------------MG
0014NOME-DO-CLIENTE-14------------PA
0015NOME-DO-CLIENTE-15------------PB
0016NOME-DO-CLIENTE-16------------PR
0017NOME-DO-CLIENTE-17------------PE
0018NOME-DO-CLIENTE-18------------PI
0019NOME-DO-CLIENTE-19------------RJ
0020NOME-DO-CLIENTE-20------------RN
0021NOME-DO-CLIENTE-21------------RS
0022NOME-DO-CLIENTE-22------------RO
0023NOME-DO-CLIENTE-23------------RR
0024NOME-DO-CLIENTE-24------------SC
0025NOME-DO-CLIENTE-25------------SP
0026NOME-DO-CLIENTE-26------------SE
0027NOME-DO-CLIENTE-27------------TO
0002NOME-DO-CLIENTE-02------------AL
0003NOME-DO-CLIENTE-03------------AP
0004NOME-DO-CLIENTE-04------------AM
0005NOME-DO-CLIENTE-05------------BA
0006NOME-DO-CLIENTE-06------------CE
0007NOME-DO-CLIENTE-07------------DF
0008NOME-DO-CLIENTE-08------------ES
0009NOME-DO-CLIENTE-09------------GO
0010NOME-DO-CLIENTE-10------------MA
0011NOME-DO-CLIENTE-11------------MT
0012NOME-DO-CLIENTE-12------------MS
0013NOME-DO-CLIENTE-13------------MG
0014NOME-DO-CLIENTE-14------------PA
0015NOME-DO-CLIENTE-15------------PB
0016NOME-DO-CLIENTE-16------------PR
0017NOME-DO-CLIENTE-17------------PE
0018NOME-DO-CLIENTE-18------------PI
0019NOME-DO-CLIENTE-19------------RJ
0020NOME-DO-CLIENTE-20------------RN
0021NOME-DO-CLIENTE-21------------RS
0022NOME-DO-CLIENTE-22------------RO
0023NOME-DO-CLIENTE-23------------RR
0024NOME-DO-CLIENTE-24------------SC
0025NOME-DO-CLIENTE-25------------SP
0026NOME-DO-CLIENTE-26------------SE
0027NOME-DO-CLIENTE-27------------TO