View previous topic :: View next topic
|
Author |
Message |
komal
New User
Joined: 09 May 2005 Posts: 17
|
|
|
|
I have a paragh which writes
MAIN-PARA.
.......
.......
PERFORM PARA-A UNTIL EOF-INPUT.
CLOSE ALL INPUT & OUTPUT FILES.
GO BACK.
PARA-A.
......
......
MOVE DATA-REC TO WS-IN-REC.
PERFORM WRITE-PARA.
......
......
IF A NOT= B
PERFORM ABEND-PARA.
END-IF.
WRITE-PARA.
WRITE OUT-REC FROM WS-IN-REC.
ABEND-PARA.
PERFORM WRITE-PARA.
CALL 'ABEND'. ----> THIS IS THE CODE TO ABEND THE PROGRAM.
In the above scenario, all the input records are getting processed and are writing to output. Incase, the abend para is called, the last record is not writing to output though the write para is called just before abending the program.
BUT,
if i close the files just before abending the program as shown below, the last write statement also working.
ABEND-PARA.
PERFORM WRITE-PARA.
CLOSE ALL INPUT & OUTPUT FILES.
CALL 'ABEND'. ----> THIS IS THE CODE TO ABEND THE PROGRAM.
Can some one explain me what is the scenario in writing the records with CLOSE and without CLOSE as explained above. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
You should remember that most often the physical write is asyncronous from the write statement ( logical write )
if You have a FB dataset the physical write will take place only after the block has been filled...
for an FB dataset with LRECL 80 BLKSISZE 27920 the records that You might lose are 348 ( 1 less that the records that fit in a block )
the close on the other side forces a physical write flushing the buffers
in Your case all depends on the ABEND processing ,
sometimes it forces an <orderly shutdown> flushing the buffers, sometimes it does not
IIRC mostly not ( but I do not speak COBOLESE very well ) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I suspect that there is more to the code that has not been posted. It looks like you posted what you believe is being used but if it were, there would be an "extra" write-para executed . . . ?
We need to see what is really being executed - not selected pieces. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It is only when you request the "close" of the output dataset that the last block will actually get written. If you look at the last records of a dataset from a job that abended, you are not really looking at something valid. I hope you'd never try to use the data. |
|
Back to top |
|
|
|