Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules | Buy Our Software DVD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Apply Write-Only

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 5468
Location: Computer

PostPosted: Thu Apr 28, 2011 2:52 pm    Post subject: Apply Write-Only
Reply with quote

From a discussion yesterday in the JCL forum, Ronald Burr, very usefully, reproduced this from the Cobol manual.

"Use the APPLY WRITE-ONLY clause to make optimum use of buffer and device space when you create a sequential file with blocked variable-length records. With APPLY WRITE-ONLY specified, a buffer is truncated only when the next record does not fit in the unused portion of the buffer. Without APPLY WRITE-ONLY specified, a buffer is truncated when it does not have enough space for a maximum-size record. The APPLY WRITE-ONLY clause has meaning only for sequential files that have variable-length records and are blocked. The AWO compiler option applies an implicit APPLY WRITE-ONLY clause to all eligible files. The NOAWO compiler option has no effect on files that have the APPLY WRITE-ONLY clause specified. The APPLY WRITE-ONLY clause takes precedence over the NOAWO compiler option. The APPLY-WRITE ONLY clause can cause input files to use a record area rather than process the data in the buffer. This use might affect the processing of both input files and output files."

What I find odd is the last two sentences:

Quote:
The APPLY-WRITE ONLY clause can cause input files to use a record area rather than process the data in the buffer. This use might affect the processing of both input files and output files."


It is one of those "tatalising Manual moments" when you feel that a sentence or two might have been lost somewhere, without anything actually being wrong.

Is anyone able to provide any explanation for the apparently sinister warning? Why would A W-O affect the processing of an input file? Why would that then affect the use of both input and output files?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 5468
Location: Computer

PostPosted: Mon May 30, 2011 12:34 pm    Post subject: Re: Apply Write-Only
Reply with quote

Bill Woodger wrote:
[...]

Quote:
The APPLY-WRITE ONLY clause can cause input files to use a record area rather than process the data in the buffer. This use might affect the processing of both input files and output files."


[...]



That's what the manual says. Does it apply to input files? Yep.

There is a PTF from IBM (a fix which can be installed) for processing zero length records in Cobol (an interesting concept). I guess these must be records which just have a RDW, with a record-length of 4 (only the RDW) and no data (how you would identify them in a Cobol program, I don't yet know).

The fix is for processing an input file when the program is compiled with AWO. Temporary fix is to compile NOAWO.

The code in error is an MVC. The fix is instead uses MVCL only in the case of a "zero length record".

Going back to the writing of files, we can link this to the reference to "record area" vs "buffer" in the manual, and we can presume:

When using Apply Write-Only (for definition of file to program) for a "flat"/QSAM/DSORG=PS variable length record, blocked file, Cobol uses two different areas. Accessible to your program is a "record area" contain which will contain the record you want to write when you issue the WRITE in your program.

Seperately, and unaccessible, is the buffer. As a new record is written, the length of that record is compared to the available space remaining in the buffer. If there is space, it is added to the buffer, if there is not enough space, the buffer is written and a new buffer is started with record in question. When the current record is going to join the existing or new buffer, the data is "moved" to the buffer.

Without Apply Write-Only, your program has access to the address of the next available space in the buffer. When you issue a WRITE, if there is no longer space in the buffer, after including the current record, for the longest possible record, then the buffer is written. There is no additional "move" to get the data into the buffer.

Going back to reading the same type of file, for some reason the buffer VS area distinction applies if compiler option AWO is used. AWO is an implicit Apply Write-Only for all "flat"/QSAM/DSORG=PS variable length record, blocked files in your program, input or output.

So, for each READ of this type of file, with compiler option AWO, at least one extra MVC is generated (there would be one for each 256 bytes, or part thereof, of your record).

Apply Write-Only is very useful if you have a wide range of record lengths on your output file. Without it, a lot of "short" blocks will be written. The cost of saved IO time is much greater than the cost of the MVCs and other code which allow this to work.

AWO, compiler option, however, causes a change to the processing of your input files of the relevant type, which has no performance benefit, in fact a minor degradation.

My recommendation, (for which I'm sure the world has been waiting with bated breath :-) ), is to use explicit Apply Write-Only, but to even bear in mind the specific characteristics of your file. If the difference between the shortest and longest possible records is less than the length of the shortest possible record, then Apply Write-Only is pointless for that file. By extension, there will be some point at which the trade-off between extra Apply Write-Only processing and the saving on IO kicks in for a specific file.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 5468
Location: Computer

PostPosted: Mon May 30, 2011 2:32 pm    Post subject: Reply to: Apply Write-Only
Reply with quote

See these two "APAR"s from IBM web site for evidence that data is additionally "moved" with AWO and not with NOAWO for both input and output:


Quote:

PQ70835: EXEC COBOL PROGRAM COMPILED WITH AWO GETS ABEND0C4 TRYING TO READ A QSAM VB FILE THAT CONTAINS SOME ZERO LENGTH RECORDS.


Quote:

PK25487: INCORRECT CODE GENERATED FOR WRITE VARIABLE LENGTH FILE, AWO
Back to top
View user's profile Send private message
PeterHolland

Moderator


Joined: 27 Oct 2009
Posts: 2247
Location: Netherlands, Amstelveen

PostPosted: Mon May 30, 2011 2:34 pm    Post subject: Re: Reply to: Apply Write-Only
Reply with quote

Bill Woodger wrote:
See these two "APAR"s from IBM web site for evidence that data is additionally "moved" with AWO and not with NOAWO for both input and output:


Quote:

PQ70835: EXEC COBOL PROGRAM COMPILED WITH AWO GETS ABEND0C4 TRYING TO READ A QSAM VB FILE THAT CONTAINS SOME ZERO LENGTH RECORDS.


Quote:

PK25487: INCORRECT CODE GENERATED FOR WRITE VARIABLE LENGTH FILE, AWO


And Bill you talk about shouting?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 5468
Location: Computer

PostPosted: Mon May 30, 2011 2:42 pm    Post subject: Reply to: Apply Write-Only
Reply with quote

Yes, we both know that it is the sources we pasted from that did the shouting for us... google doesn't care, so no problem changing, except I don't have anything handy to do it in.

Edit: Didn't see your other reply Peter. It would be nice if the paste did it, wouldn't it? Talk with your man please.
Back to top
View user's profile Send private message
PeterHolland

Moderator


Joined: 27 Oct 2009
Posts: 2247
Location: Netherlands, Amstelveen

PostPosted: Mon May 30, 2011 2:57 pm    Post subject:
Reply with quote

Bill,

steve balmer (microsoft ceo) is a shouter himself.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1

 



 
Master the Mainframes | Bookmarks | Subscriptions | Site Map | Polls | Photos | FAQ | Rules | Contact Us