Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

WRITE not working before the abend routine in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
komal

New User


Joined: 09 May 2005
Posts: 18

PostPosted: Thu May 26, 2011 7:10 pm    Post subject: WRITE not working before the abend routine in COBOL
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10275
Location: italy

PostPosted: Thu May 26, 2011 7:18 pm    Post subject: Reply to: WRITE not working before the abend routine in COBO
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

Site Director


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

PostPosted: Thu May 26, 2011 7:19 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu May 26, 2011 7:22 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 4 Wed Jul 26, 2017 7:35 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Restart=Step not working ALAK SAHA JCL & VSAM 6 Fri Jun 30, 2017 6:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us