How variable block buffers are handled by CA Easytrieve

Document ID : KB000054895
Last Modified Date : 14/02/2018
Show Technical Document Details


Buffers are not initialized in either release 6.4 or release r11.x of CA Easytrieve.

CA Easytrieve always had the rule that buffers are never initialized and you should never use data in a variable file's buffer beyond the value contained in RECORD-LENGTH.

Release 11.x always performs I/O using "move mode" where data is moved from the "real" buffer to the buffer created in program storage. The move is always done only for the value of RECORD-LENGTH which is why data from longer previous records is undisturbed. Again this is done by design.

Release 6.4 worked the same way when the WORKAREA parameter is coded on the FILE statement of the variable files. The WORKAREA parameter forces the product to use "move mode". "Move mode" in 6.4 works identically to r11.x.

[WORKAREA literal-14]
The WORKAREA option establishes the number of bytes to be allocated as a work area for the file. WORKAREA cannot be coded if CARD, DLI, or IDMS parameters are specified. Literal-14 specifies the number of bytes to be allocated and must be large enough to contain the longest record processed.

Using WORKAREA will ensure you won't hit protected storage. By adding WORKAREA to the FILE statements, we change mode to MOVE, where the logical record is moved from the buffer into a workarea that has been defined via the file statement, to handle the longest possible record, instead of LOC mode, which is the default. The MOVE mode is safer because it can handle CA Easytrieve moving the longest record, without hitting protected storage. MOVE MODE insures that only the current record is available and not the extraneous information contained in the input buffer.

Whether we use locate or move mode, the rules are the same: never refer to data beyond RECORD-LENGTH as it doesn't belong to the record and the value is unpredictable.

The proper and safe way to use a buffer when working with a variable file where you cannot guarantee what the record length will be (such as a fixed portion of the record) is to move the data to a work area as in this example:

REC 1 16 A 
 MYWORKAREA will always contain a safe 16 byte space filled field.