Problem with OPEN/READ a table



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Problem with OPEN/READ a table

Postby GUI1504 » Fri Oct 01, 2010 12:00 am

Hello guys, i'm an another little problem. I'm trying read a data table in a cobol program and I can't. I'm think that's a JCL problem, but I don't know what really are. In compilation, i have Return Code 0, but the file don't open (WS-Status will show).

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=*
/*


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.


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
GUI1504
 
Posts: 28
Joined: Fri Sep 03, 2010 10:40 pm
Location: Campinas, SP - Brazil
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with OPEN/READ a table

Postby Robert Sample » Fri Oct 01, 2010 12:25 am

1. COBOL DISPLAY statements do not go to SYSPRINT, they go to SYSOUT. So your program will not produce any output as the JCL is coded.

2. You are using a multi-step procedure. You need to put the step name in front of EACH DD name or you may get unexpected results due to mismatched DD names. ENTRADA, for example, will not be read by your executing COBOL program as you have coded your JCL -- period.

3. When I compile and run your program using your JCL with correct DD names, I get results of
 ARQUIVO OK!
 CODIGO DO CLIENTE: 0001
 NOME DO CLIENTE NOME-DO-CLIENTE-01------------
which is exactly as expected based upon the code you have.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Problem with OPEN/READ a table

Postby dick scherrer » Fri Oct 01, 2010 1:43 am

You also need to stop posting the same question multiple times. . . :(

If this continues, the topics will be deleted.

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post