The rest of the program follows below. You can see that it has two DISPLAYs: 
one for ITERATE and one for each READ. Results for PARM='1': 

+Iterate  1  times
+Reading record (repeated 1,100 or 2,200 times depending on input record count) 

I understand that reading a dummy or an empty file should not cause a failure, 
but shouldn't the AT END condition be set immediately for zero data records? 
And when there is exactly one record, I would expect AT END on the second READ. 
This a pretty simple-minded program. ;-(


IDENTIFICATION DIVISION .                         
PROGRAM-ID .   ABOTEST .                          
ENVIRONMENT DIVISION .                            
  INPUT-OUTPUT SECTION .                          
  FILE-CONTROL .                                  
     SELECT TESTIN                                
     ASSIGN TESTIN                                
     FILE STATUS IS testin-status .               
     SELECT TESTOUTE                              
     ASSIGN TESTOUTE                              
     FILE STATUS IS testoute-status .             
     SELECT TESTOUTO                              
     ASSIGN TESTOUTO                              
     FILE STATUS IS testouto-status .             
DATA DIVISION .                                   
FILE SECTION .                                    
FD TESTIN                                         
    BLOCK  CONTAINS 0                             
    RECORD CONTAINS 80 CHARACTERS                 
    RECORDING MODE F .                            
01 input-rec                        PIC X(80) .   
FD TESTOUTE                                       
    BLOCK  CONTAINS 0                             
    RECORD CONTAINS 80 CHARACTERS                 
    RECORDING MODE F .                            
01 outpute-rec                      PIC X(80) .   
FD TESTOUTO                                       
    BLOCK  CONTAINS 0                             
    RECORD CONTAINS 80 CHARACTERS                 
    RECORDING MODE F .                            
01 outputo-rec                      PIC X(80) .   
WORKING-STORAGE SECTION .                         
01 dig-sum                          PIC 9(5) .    
01 quo                              PIC 9(5) .    
01 rem                              PIC 9(5) .    
01 testin-eof                       PIC X .       
01 testin-status                    PIC 99 .      
01 testoute-status                  PIC 99 .      
01 testouto-status                  PIC 99 .    
01 IN-REC .                                     
    05 IN-DIGIT PIC 9                           
                OCCURS 80 TIMES                 
                INDEXED BY i1 .                 
01 out-rec .                                    
    05 rec-sum                      PIC 9(5)  . 
    05 out-filler                   PIC X(75) . 
LOCAL-STORAGE SECTION .                         
LINKAGE SECTION .                               
01 iterate                          PIC 9(5) .  
                                                
PROCEDURE DIVISION USING iterate .              
...


.
.
.
J.O.Skip Robinson
Southern California Edison Company
Electric Dragon Team Paddler 
SHARE MVS Program Co-Manager
323-715-0595 Mobile
626-302-7535 Office
[email protected]

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Farley, Peter x23353
Sent: Thursday, March 31, 2016 4:06 PM
To: [email protected]
Subject: (External):Re: COBOL Rookie Problem

Skip, I would need to see the invoking JCL and the COBOL definition of 
"iterate" in the LINKAGE SECTION to confirm my suspicion, but my first guess is 
that you gave the program a PARM of 1100 to do 1100 iterations, and that is 
what it did.  Empty (even DUMMY) sequential files always open cleanly and the 
first read should take the AT END path.

It would help to see all of the program, from ID DIVISION onward, as well as 
the invoking JCL.

HTH

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Jesse 1 Robinson
Sent: Thursday, March 31, 2016 6:04 PM
To: [email protected]
Subject: COBOL Rookie Problem

I'm writing my first COBOL program in decades. It's not supposed to do anything 
important, but it's not a toy. I need a program that chews up CPU in order to 
try out ABO (Automatic Binary Optimizer). I started with a REXX and am now 
rewriting in COBOL 4.2. It's not doing what I want, which is to read a 
sequential file, do some arithmetic, then write out records to a couple of 
other sequential files. Very simple, but I'm missing something. When the input 
file is empty-no records-the program does 1,100 reads! When the input file has 
one record, it does 2,200 reads!! It's not a real loop because the program ends 
normally after all the commotion. What's wrong? The REXX is structured almost 
identically, and it works fine.

PROCEDURE DIVISION USING iterate .
    IF ADDRESS OF iterate = NULL THEN MOVE 1 TO iterate; END-IF
    DISPLAY "Iterate" iterate "times" UPON CONSOLE
    OPEN OUTPUT testoute
    OPEN OUTPUT testouto
    PERFORM iterate TIMES
      OPEN INPUT testin
      MOVE "N" TO testin-eof
      PERFORM UNTIL testin-eof = "Y"
          display "Reading record" UPON CONSOLE
        READ testin INTO in-rec
          AT END MOVE "Y" TO testin-eof   < < < EOF is not getting set as it 
should
        END-READ
        IF testin-eof = "N" THEN
          MOVE 0 TO dig-sum
          PERFORM VARYING i1 FROM 1 BY 1 UNTIL i1 = 80
            ADD in-digit(i1) TO dig-sum
            MOVE dig-sum TO rec-sum
            MOVE SPACES TO out-filler
            DIVIDE dig-sum BY 2 GIVING quo REMAINDER rem
            IF rem = 0 THEN
              WRITE outpute-rec FROM out-rec
            ELSE
              WRITE outputo-rec FROM out-rec
            END-IF
          END-PERFORM
        END-IF
      END-PERFORM
      CLOSE testin
    END-PERFORM
    CLOSE testoute
    CLOSE testouto
    STOP RUN .
END PROGRAM ABOTEST .
.
.
.
J.O.Skip Robinson
Southern California Edison Company
Electric Dragon Team Paddler
SHARE MVS Program Co-Manager
323-715-0595 Mobile
626-302-7535 Office
[email protected]<mailto:[email protected]>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to