READ statement was unsuccessful but did not cause an at end



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

READ statement was unsuccessful but did not cause an at end

Postby zhouchung » Sat Oct 09, 2010 8:17 am

       IDENTIFICATION DIVISION.
       PROGRAM-ID. M32FV0.
       DATE-WRITTEN. 10/09/23.
       DATE-COMPILED.
       AUTHOR. ZHC.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT I1-HI-MS-CHECK-FILE ASSIGN TO SYS011.
           SELECT 01-HI-MS-HEADER-FILE ASSIGN TO SYS031.
       DATA DIVISION.
       FILE SECTION.
      **************************
      *    I1-HI-MS-CHECK-FILE-DESCRIPTION
      ***************************
       FD I1-HI-MS-CHECK-FILE RECORDING MODE F.
       01 I1A-HI-MS-CHECK-REC.
         03         I1A-KOJO-CD                  PIC  X(02).
         03         I1A-KIJUN-SHAKEI             PIC  X(05).
         03         I1A-END-ITEM.
           05       I1A-SHASHU.
             07     I1A-KATA                     PIC  X(07).
             07     I1A-KIHON                    PIC  X(03).
             07     I1A-KBN                      PIC  X(08).
           05       I1A-COLOR                    PIC  X(03).
           05       I1A-UCHIBARI                 PIC  X(01).
         03         I1A-ODR-TYPE                 PIC  X(01).
         03         I1A-OFFLINE-YMD.
           05       I1A-OFFLINE-YYYY             PIC  X(04).
           05       I1A-OFFLINE-MM               PIC  X(02).
           05       I1A-OFFLINE-DD               PIC  X(02).
         03         I1A-YMS.
           05       I1A-YYYY                     PIC  X(04).
           05       I1A-MM                       PIC  X(02).
           05       I1A-SS                       PIC  X(02).
         03         I1A-SHORI-KBN                PIC  X(01).
         03         I1A-DAISU                    PIC S9(05)  COMP-3.
         03         I1A-ODR-DAISU                PIC S9(05)  COMP-3.
         03         I1A-FILLER-1                 PIC  X(27).
      **********************
      *    01-HI-MS-HEADER-FILE-DESCRIPTION.
      ********************
       FD 01-HI-MS-HEADER-FILE RECORDING MODE F.
       01 01A-HI-MS-HEADER-REC.
         03         01A-KOJO-CD                  PIC  X(02).
         03         01A-KIJUN-SHAKEI             PIC  X(05).
         03         01A-HI-AREA                 OCCURS  20  TIMES.
           05       01A-OFFLINE-YMD.
             07     01A-OFFLINE-YYYY             PIC  X(04).
             07     01A-OFFLINE-MM               PIC  X(02).
             07     01A-OFFLINE-DD               PIC  X(02).
           05       01A-SHORI-KBN                PIC  X(01).
           05       01A-YMS.
             07     01A-YYYY                     PIC  X(04).
             07     01A-MM                       PIC  X(02).
             07     01A-SS                       PIC  X(02).
         03         01A-FILLER-1                 PIC  X(23).
       WORKING-STORAGE SECTION.
       01 TABLE-AREA.
         03 HIBETUMSHD-TBL-AREA.
           05 HIBETUMSHD-TBL OCCURS 20.
             07 T1-OFFLINE-YMD PIC X(08).
             07 T1-SHORI-KBN  PIC X(01).
             07 T1-YMS        PIC X(08).
       77 IX-HI PIC 99 VALUE 0.
      **************************************************
      *    CONTROL-AREA
      ************************************************
       01 SW-CONTROL-AREA.
         03         SW-ON                        PIC X(01) VALUE 'Y'.
         03         SW-OFF                       PIC X(01) VALUE 'N'.
         03         I1-FILE-EOF-SW               PIC X(01).
           88       I1-FILE-EOF-SW-ON VALUE 'Y'.
      ***************************************************
      *    KEY-AREA
      ***********************************************
       01 KEY-AREA.
         03 SEQUENCE-KEY-AREA.
           05 I1-NEW-SEQ-KEY.
             07 I1-N-SEQ-KOJO-CD                 PIC  X(02).
             07 I1-N-SEQ-KIJUN-SHAKEI            PIC  X(05).
             07 I1-N-SEQ-SHORI-KBN               PIC  X(01).
             07 I1-N-SEQ-OFFLINE-YMD             PIC X(08).
           05 I1-OLD-SEQ-KEY PIC X(16).
         03 SUMMARY-KEY-AREA.
           05 I1-NEW-SUM-KEY2.
             07 I1-NEW-SUM-KEY1.
               09 I1-N-SUM-KOJO-CD                 PIC  X(02).
               09 I1-N-SUM-KIJUN-SHAKEI            PIC  X(05).
             07 I1-N-SUM-SHORI-KBN               PIC  X(01).
             07 I1-N-SUM-OFFLINE-YMD             PIC  X(08).
           05 I1-OLD-SUM-KEY2.
             07 I1-OLD-SUM-KEY1.
               09 I1-N-SUM-KOJO-CD                 PIC  X(02).
               09 I1-N-SUM-KIJUN-SHAKEI            PIC  X(05).
             07 I1-OLD-SUM-SHORI-KBN PIC X(01).
             07 I1-OLD-SUM-OFFLINE-YMD PIC X(08).
      *   SKIP3
      *************************************************************
      *    COUNTER-AREA.
      *********************************************************
       01 COUNTER-AREA.
         03 TBL-IDX-CTR PIC S9(04).
         03 TBL-SEA-CTR PIC S9(04).
      **********************************************************
      *  CONSTANT-AREA
      ***************************************************************
       01 CONSTANT-AREA.
         03 C-TBL-MAX-20 PIC S9(04) COMP VALUE 20.
       PROCEDURE DIVISION.
      **************************************************
      *    1.     MAIN-SHORI
      ***************************************************
       MAIN-SHORI.
           PERFORM KAISHI-SHORI.
           MOVE SW-OFF TO I1-FILE-EOF-SW.
           DISPLAY 'I1-FILE-EOF-SW ==='  I1-FILE-EOF-SW.
           PERFORM I1-FILE-INPUT-SHORI.
      *----*
           PERFORM UNTIL I1-FILE-EOF-SW-ON
               PERFORM I1-SUM-SHOKI-SHORI-1
               MOVE I1-NEW-SUM-KEY1      TO I1-OLD-SUM-KEY1
      *--------*
               PERFORM UNTIL I1-NEW-SUM-KEY1 NOT = I1-OLD-SUM-KEY1
                   PERFORM I1-SUM-SHOKI-SHORI-2
                   MOVE I1-NEW-SUM-KEY2 TO I1-OLD-SUM-KEY2
      *------------*
                   PERFORM UNTIL I1-NEW-SUM-KEY2 NOT =
                                 I1-OLD-SUM-KEY2
                       PERFORM I1-FILE-INPUT-SHORI
                   END-PERFORM
      *------------*
               END-PERFORM
      *--------*
               PERFORM I1-SUM-ATO-SHORI-1
           END-PERFORM.
      *----*
           PERFORM SHURYO-SHORI.
           STOP RUN.
      ****************************************************
      *    1.2.1  KAISHI-SHORI
      **************************************************
       KAISHI-SHORI.
           OPEN INPUT I1-HI-MS-CHECK-FILE
               OUTPUT 01-HI-MS-HEADER-FILE.
      ***************************************************
      *         I1-FILE-INPUT-SHORI
      **************************************************
       I1-FILE-INPUT-SHORI.
           READ I1-HI-MS-CHECK-FILE AT END
                 MOVE SW-ON        TO I1-FILE-EOF-SW.
   [b]       [color=#FF0000] DISPLAY 'I1-FILE-EOF-SW'  I1-FILE-EOF-SW.[/color][/b]           
             IF NOT I1-FILE-EOF-SW-ON
             MOVE I1-NEW-SEQ-KEY         TO I1-OLD-SEQ-KEY
             MOVE I1A-KOJO-CD         TO I1-N-SEQ-KOJO-CD
             MOVE I1A-KIJUN-SHAKEI    TO I1-N-SEQ-KIJUN-SHAKEI
             MOVE I1A-OFFLINE-YMD     TO I1-N-SEQ-OFFLINE-YMD
             MOVE I1A-SHORI-KBN       TO I1-N-SEQ-SHORI-KBN
             IF I1-NEW-SEQ-KEY NOT < I1-OLD-SEQ-KEY
               MOVE I1-NEW-SEQ-KEY      TO I1-NEW-SUM-KEY2
             ELSE
               PERFORM SHURYO2-SHORI
             END-IF
             DISPLAY 'I1-NEW-SEQ-KEY'  I1-NEW-SEQ-KEY
             DISPLAY 'I1-OLD-SEQ-KEY'  I1-OLD-SEQ-KEY
             DISPLAY 'I1A-KOJO-CD'  I1A-KOJO-CD
           ELSE
             DISPLAY 'END'
             MOVE HIGH-VALUE            TO I1-NEW-SUM-KEY2
           END-IF.
      ***************************************************
      *       I1-SUM-SHOKI-SHORI-1
      **************************************************
       I1-SUM-SHOKI-SHORI-1.
           MOVE 0 TO TBL-IDX-CTR.
           MOVE 0 TO TBL-SEA-CTR.
           PERFORM UNTIL TBL-IDX-CTR > C-TBL-MAX-20
               ADD 1 TO TBL-IDX-CTR
               MOVE SPACE TO T1-OFFLINE-YMD(TBL-IDX-CTR)
               MOVE SPACE TO T1-SHORI-KBN(TBL-IDX-CTR)
               MOVE SPACE TO T1-YMS(TBL-IDX-CTR)
           END-PERFORM.
      *    MOVE I1A-OFFLINE-YMD TO O1A-OFFLINE-YMD(IX-HA).
      *    MOVE I1A-SHORI-KBN   TO O1A-SHORI-KBN(IX-HA).
      *    MOVE I1A-YMS         TO O1A-YMS(IX-HA).
      **************************************************
      *      I1-SUM-SHOKI-SHORI-2
      ***************************************************
       I1-SUM-SHOKI-SHORI-2.
           IF TBL-SEA-CTR < C-TBL-MAX-20
             ADD 1 TO TBL-SEA-CTR
             MOVE I1A-KOJO-CD TO 01A-KOJO-CD
             MOVE I1A-KIJUN-SHAKEI TO 01A-KIJUN-SHAKEI
      *      PERFORM UNTIL TBL-SEA-CTR > C-TBL-MAX-20
             MOVE I1A-OFFLINE-YMD TO
                      T1-OFFLINE-YMD(TBL-SEA-CTR)
             MOVE I1A-SHORI-KBN TO
                      T1-SHORI-KBN(TBL-SEA-CTR)
             MOVE I1A-YMS TO
                      T1-YMS(TBL-SEA-CTR)
      *      END-PERFORM
      *      DISPLAY 'I1A-OFFLINE-YMD ' I1A-OFFLINE-YMD
             DISPLAY 'T1A-OFFLINE-YMD ' T1-OFFLINE-YMD(TBL-SEA-CTR)
             MOVE SPACE TO 01A-FILLER-1
           END-IF.
      ***************************************************
      * I1-SUM-ATO-SHORI-1
      ***************************************************
       I1-SUM-ATO-SHORI-1.
           MOVE 0 TO TBL-SEA-CTR.
           PERFORM UNTIL TBL-SEA-CTR > C-TBL-MAX-20
             ADD 1 TO TBL-SEA-CTR
             MOVE T1-OFFLINE-YMD(TBL-SEA-CTR) TO
                    01A-OFFLINE-YMD(TBL-SEA-CTR)
             MOVE T1-SHORI-KBN(TBL-SEA-CTR) TO
                    01A-SHORI-KBN(TBL-SEA-CTR)
             MOVE T1-YMS(TBL-SEA-CTR) TO
                    01A-YMS(TBL-SEA-CTR)
           END-PERFORM.
           WRITE 01A-HI-MS-HEADER-REC.
      ****************************************************
      * SHURYO-SHORI
      ***********************************************
       SHURYO-SHORI.
           CLOSE I1-HI-MS-CHECK-FILE
                 01-HI-MS-HEADER-FILE.
           STOP RUN.
      ****************************************************
      * SHURYO2-SHORI
      ***********************************************
       SHURYO2-SHORI.
           DISPLAY 'ABNORMAL TERMINATION'.
           CLOSE I1-HI-MS-CHECK-FILE
                 01-HI-MS-HEADER-FILE.
           STOP RUN.


I1-FILE-EOF-SW ===N           
I1-FILE-EOF-SWN               
I1-NEW-SEQ-KEY1111111AAAAAAAAA
I1-OLD-SEQ-KEY                 
I1A-KOJO-CD11                 
T1-OFFLINE-YMD AAAAAAAA       
I1-FILE-EOF-SW                 
I1-NEW-SEQ-KEY1111111BBBBBBBBB
I1-OLD-SEQ-KEY     11AAAAAAAAA
I1A-KOJO-CD11                 
T1-OFFLINE-YMD BBBBBBBB       
I1-FILE-EOF-SW                 
I1-NEW-SEQ-KEY1111111CCCCCCCCC
I1-OLD-SEQ-KEY1111111BBBBBBBBB
I1A-KOJO-CD11                  ....

why I1-FILE-EOF-SW is space 
zhouchung
 
Posts: 4
Joined: Sat Oct 09, 2010 8:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: READ statement was unsuccessful but did not cause an at end

 

Re: READ statement was unsuccessful but did not cause an at end

Postby dick scherrer » Sat Oct 09, 2010 9:55 am

Hello and welcome to the forum.

When posting code, jcl, data, etc using the "Code" tag wil improve readability and preserve alignment. There is a Preview function so the post may be seen as it will appear to the forum (rather than the Reply Editor). When the post appears as you want, Submit.

Why do you believe the read was "unsuccessful"?

The reason the eof-sw is blank is probably because it was not initialized. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: READ statement was unsuccessful but did not cause an at end

Postby zhouchung » Sat Oct 09, 2010 10:54 am

sorry, i'm new here.i will pay attention to it next time.
Because when i execute a jcl it point out that There was an unsuccessful READ from file SYS011 (file status 46) in program
zhouchung
 
Posts: 4
Joined: Sat Oct 09, 2010 8:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: READ statement was unsuccessful but did not cause an at end

Postby zhouchung » Sat Oct 09, 2010 11:06 am

The eof-sw had initialized and when the input-file was first read the value of eof-sw was n while after the
second-read the value was space. When read at end of the input-file the value of SW-ON was not passed on to I1-FILE-EOF-SW. i don't know the reason.
zhouchung
 
Posts: 4
Joined: Sat Oct 09, 2010 8:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: READ statement was unsuccessful but did not cause an at end

Postby dick scherrer » Sat Oct 09, 2010 11:07 am

Hello,

sorry, i'm new here
Not to worry - each forum setup is different :)

Suggest you code a FILE STATUS for the files and check them after every attempt to use the file (OPEN/READ/ect).

It appears the code has tried to read a record that does not exist (i.e. after end of file).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: READ statement was unsuccessful but did not cause an at end

Postby zhouchung » Sat Oct 09, 2010 11:52 am

thanks you. i eventually find the reason. when i initialize the table it was overflow.
zhouchung
 
Posts: 4
Joined: Sat Oct 09, 2010 8:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: READ statement was unsuccessful but did not cause an at end

Postby dick scherrer » Sat Oct 09, 2010 9:08 pm

You're welcome - thanks for posting the resolution :)

Good luck,

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


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post