Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 6: CICS File Handling


VSAM and CICS

CICS file commands work with VSAM files. VSAM organizes records in three ways, and the organization decides how you identify the record in your EXEC CICS commands. The diagram below shows which record identifier each file type uses.

VSAM file types CICS uses

  • KSDS (key-sequenced data set) - records are stored and retrieved in key order. Each record has a unique primary key, for example a customer number.
  • ESDS (entry-sequenced data set) - records are stored in the order they are written, like a sequential file. Records are addressed by RBA (relative byte address), the byte offset of the record from the start of the file.
  • RRDS (relative record data set) - fixed-length records stored in numbered slots. Each record is addressed by RRN (relative record number), starting at 1.
  • CICS reads, writes and updates VSAM files only. That is why every FILE name in your program must be backed by a VSAM cluster defined to CICS.

How the file type changes your code

  • The RIDFLD option always carries the record identifier. What it holds depends on the file: the key for a KSDS, the RBA for an ESDS, or the RRN for an RRDS.
  • Code the RRN option on the command when the RIDFLD value is a relative record number for an RRDS.
  • Code the RBA option when the RIDFLD value is a relative byte address for an ESDS or a KSDS.
  • Code the GENERIC option only for a KSDS. It tells CICS to match only part of the key, and you pair it with KEYLENGTH to say how many bytes of the key to use.
  • To position a browse at the start of a file: move LOW-VALUE to the RIDFLD field for a KSDS with an alphanumeric key (or zero if the key is numeric), move zero for an ESDS, and move 1 for an RRDS.
  • Example of starting a browse at the beginning of each file type:-
    MOVE LOW-VALUE TO KSDS-START-KEY. EXEC CICS STARTBR FILE('CUSTMAS') RIDFLD(KSDS-START-KEY) RESP(RESPONSE-CODE) END-EXEC. MOVE 0 TO ESDS-START-RBA. EXEC CICS STARTBR FILE('TRANSLOG') RIDFLD(ESDS-START-RBA) RBA RESP(RESPONSE-CODE) END-EXEC. MOVE 1 TO RRDS-START-RRN. EXEC CICS STARTBR FILE('EMPLOYEE') RIDFLD(RRDS-START-RRN) RRN RESP(RESPONSE-CODE) END-EXEC.

RLS and file sharing

  • VSAM record-level sharing (RLS) lets a file stay open in several CICS regions at the same time, with locking managed at the record level.
  • For non-RLS files, the DISPOSITION(SHR) definition lets CICS regions share the file, but only one region can update it unless RLS is used.
  • The file definition decides recoverability: a recoverable file is backed out automatically if the task abends, so partial updates are undone.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant