Skip to main content

Problem:

Programs are coded for OPEN OUTPUT and OPEN I/O

Is there a way to make them READ ONLY without changing the programs?

Resolution:

To convert all OPEN I-O statements in a given set of programs to OPEN INPUT statements can be accomplished with a user written file-handler.

The file-handler OP-CODE for OPEN I-O is x"FA02" . The user written file-handler would have to  convert this to the OP-CODE for OPEN INPUT which is x"FA00".

The file handler would contain the following:

working-storage section.

01 open-input pic xx value x"FA00".

linkage section.

01 opcode pic xx.

01 fcd.

copy "XFHFCD.CPY".

procedure division using opcode fcd.

if opcode = x"FA02"

call "EXTFH" using open-input fcd

else

call "EXTFH" using opcode fcd

end-if

exit program

.

Compile the programs using the CALLFH directive naming the user written file-handler and then any attempts to write or update the file should fail with an appropriate file-status code (wrong open mode).

Note that if the conversion of OPEN I-O needed to be limited to only certain files then  examine the file-name which can be found via a pointer in the FCD. Also implement a user written OP-CODE checking/error handling  (the OP-CODEs are documented in the File Handler section of the product documentation).

Old KB# 2332

#AcuCobol
#ServerExpress
#RMCOBOL
#netexpress
#COBOL