IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

WRITE not working before the abend routine in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
komal

New User


Joined: 09 May 2005
Posts: 17

PostPosted: Thu May 26, 2011 7:10 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu May 26, 2011 7:18 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 26, 2011 7:19 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 26, 2011 7:22 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top