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 This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
