I assume you don't know why it happens 1100 times. I assume the program is EXEC PGM=? Or are you running it from TSO?
You have a value in "iterate". Exactly what you have will depend on the definition, and the PARM that you have given. You are attempting to give a value of 1 to iterate, thinking that it has no address - but if it has no address, it has no storage, and your MOVE 1 will get a S0C4 as you try to clobber address zero. Other than that, I can't see anything "wrong" with the program, assuming that you want to open-process-close the file as many times as iterate (a real one) tells you to. So, definition of iterate, and JCL or other method which fires off the program. The semi-colon is cute, but drop it. The unwary would think it means something. I'd (always) put FILE STATUS on the SELECT and use the file-status field for identifying end-of-file (the AT END/NOT AT END with END-READ are... ephemeral, and lead to "odd" code, often. On Thursday, 31 March 2016 23:04:15 UTC+1, Jesse 1 Robinson wrote: > 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 ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
