The initial status of a file is determined by the FILESTAT parameter in the DFHFCT macro. A typical entry in the FCT table will be as follows:


For a CICS transaction to access a file, it must be Opened and Enabled. Otherwise the NOTOPEN condition will occur. So the file should be opened and enabled when the transaction wants it and should be closed and disabled as soon as the file is no longer required because, keeping a file open requires a large amount of resources.

But CICS version 1.7 onwards, the NOTOPEN conditions is removed, because CICS will automatically open the file and execute the file access commands. So the application programs need not worry about the file status. Even though the automatic file opening by CICS gives some amount of convenience in application programming, it increases resource consumption. The ideal situation is to open the file when it is needed and close it as soon as possible.

As discussed in the above section the file can be opened by using the CEMT transaction by issuing an open command. Changing the file open/close status through CEMT transaction involves a human intervention. But for certain CICS applications, it is more desirable if a CICS program can dynamically close or open the files under CICS. This process is called Dynamic File Open/Close (DFOC) and can be accomplished by using a LINK command, SET command or by a batch job.

When a VSAM file is closed under the CICS system, this file could be accessed by other batch systems or TSO jobs, even while CICS is up. In order to make this possible two things must be done. First, in the VSAM cluster definition the SHAREOPTION must be specified as SHAREOPTION (2,3). This option indicates how a VSAM file is to be shared among the systems or regions. The first parameter is the cross-region parameter and a value of 2 indicates that one user can 'write into the file while other users can read from it.

The second parameter is the cross system parameter and the value of 3 means that the file can be fully shared among the systems. Second, in the JCL of the CICS job DISP=SHR (which allows more than one user to share the file simultaneously) must be specified for the DD card of this file as follows:

Where ddname is the name registered in the FCT and dataset-name is the VSAM cluster name. The DFOC can be achieved by using the LINK command. Here the application program links the Master terminal Program (DFHEMTP) and passes the CEMT parameter data required for the file open/close through the COMMAREA. The DFHEMTP opens/closes the files specified and after that control is returned to the application program. In effect, the application program appears to be opening and closing the files although it is actually done by the DFHEMTP program. The DFOC can also be achieved through the SET command by issuing a set command as follows:

set command

The command opens/closes the file specified. Another method of achieving DFOC is by using a batch job, which issues the CEMT transaction as the data for the JES modify (F) command against the system console terminal. A prerequisite for this is that the MVS system console must be defined in the TCT as the system console for CICS, by specifying the TRMTYP=CONSOLE and CONSLID=00 in the DFHTCT. Once this is done a batch job with a dummy program (IEFBR14), which does nothing, must be created. The JCL should however contain the JES Modify (F) command against the system console terminal and accompanying data for the CEMT as shown in the example:

set command

The file specified will be opened for the CICS region and the message will be displayed from the console.

Applications of DFOC

It is not practically possible for the systems programmer or administrator to open and close the files whenever and application program or end user wants it. But the CEMT transaction is a restricted transaction it should not be given to the users for opening and closing of files. The DFOC approach is a solution for this problem. By coding the DFOC logic in the user's online transactions and batch jobs thus enabling the application programs to open and close the file they want this problem can be solved. Another beauty of this approach is that the opening and closing of the files will be transparent to the user.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM Mainframe Topics