Sunday, December 21, 2008

Files and databases

CICS transactions can access files and databases, which can be on either a local or remote system. Files are processed by the CICS file control program, which allows you to read, add, update, delete (VSAM only), and browse records in VSAM and BDAM data sets. When you access files through the file control program, you do not have such considerations as buffer management, blocking and De-blocking, and access method dependencies.

DL/I databases give you a greater degree of data independence than file control does. You are presented with a logical view of the database in terms of hierarchy of segments. DL/I offer you facilities for manipulating these segments and you do not need to know how they are organized.

CICS has two programming interfaces to DL/I: the EXEC DLI interface, and the DL/I CALL interface.

You identify records in VSAM data sets by key, by relative byte address (RBA), or by relative record number (RRN).
To distinguish which format of record identification is to be used, the RBA and RRN options can be used on most file commands that access VSAM data sets. The options effectively define the format of the record identification field (RIDFLD). If neither the RBA nor the RRN option is specified, the RIDFLD option should contain a key to be used for accessing a VSAM KSDS, or a VSAM KSDS or ESDS by way of a path.

The RBA option specifies that the RIDFLD contains the relative byte address of the record to be accessed. A relative byte address is used to access a VSAM ESDS, and it may also be used to access a VSAM KSDS. However, if a KSDS is accessed in this way, the RBA of the record may change during the transaction as a result of another transaction adding records to, or deleting records from, the same data set.

The RRN option specifies that the RIDFLD contains the relative record number (the first record in a data set being numbered 1) of the record to be retrieved.

Operations involving use of VSAM keys may specify either a complete key or a generic (partial) key. (The one exception to this rule is when a record is written to a SAM KSDS. In this instance, the complete key must be specified in the RIDFLD option of the command.) When a generic key is used, its length must be specified in the KEY LENGTH option, and the GENERIC option must also be specified on the command. A generic key cannot have a key length equal to the full key length. That is, a generic key is defined to be of a length that is strictly less than that of the complete key.

For both complete and generic keys, the GTEQ option may also be specified on certain commands. The command then positions at, or applies to, the record in the data set with the next higher key if a matching key cannot be found. When a data set is being accessed by way of an alternate index path, the record identified is the one with the next higher alternative when a matching record cannot be found.

The application programmer should always, even when using generic keys, use an area of storage for the RIDFLD whose length is equal to the length of the complete key. This is because during a browse operation, after retrieving a record, CICS copies into the RIDFLD area the actual identifier of the record retrieved. In some cases, CICS will return to the application program a complete key, even when a generic key was specified on the command. An example of this is a generic browse through a VSAM KSDS where the complete key is returned to the application program on each READNEXT and READPREV command.

No comments:

Post a Comment