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

Module 6: CICS File Handling


CICS File Control

CICS File Control is the part of CICS that lets your application programs read, write, update and delete records in VSAM files. Your program never touches the file directly. Instead, you code EXEC CICS commands, and File Control carries out the request against the file on your behalf.

What File Control does

  • File Control is the CICS service that handles all file input/output for application programs.
  • It takes your EXEC CICS file commands and turns them into VSAM requests.
  • It places each retrieved record into the INTO area you name in the command.
  • It raises exceptional conditions such as NOTFND, DUPREC and ENDFILE when something goes wrong, so your program can handle them instead of abending.
  • Most CICS file work is done against VSAM key-sequenced (KSDS), entry-sequenced (ESDS) or relative record (RRDS) files.

The file commands File Control supports

  • READ - reads one record by key, relative record number (RRN) or relative byte address (RBA).
  • WRITE - adds a new record to a file.
  • REWRITE - updates a record that was previously read with the UPDATE option.
  • DELETE - deletes a record from the file.
  • STARTBR, READNEXT, READPREV, ENDBR and RESETBR - browse a file sequentially, one record at a time.
  • UNLOCK - releases a record that was held for update.
  • Every one of these commands names the file in the FILE option. That name must be defined in the File Control Table (FCT), or the FILENOTFOUND condition occurs.

Exclusive control and the UPDATE option

  • When you read a record with the UPDATE option, File Control holds that record for your task until you issue REWRITE, DELETE or UNLOCK, or until the task ends.
  • While the record is held, other tasks cannot update it. This is called exclusive control.
  • Code READ with UPDATE only when you really intend to change or delete the record. A plain READ is faster and does not hold a lock.
  • A record held for update is released automatically when the task terminates, but coding UNLOCK explicitly makes your intent clear.
  • Example of reading a record for update and then rewriting it:-
    EXEC CICS READ FILE('CUSTMAS') INTO(CUSTOMER-MASTER-RECORD) RIDFLD(CM-CUSTOMER-NUMBER) UPDATE RESP(RESPONSE-CODE) END-EXEC. IF RESPONSE-CODE = DFHRESP(NORMAL) MOVE 'INACTIVE' TO CM-STATUS EXEC CICS REWRITE FILE('CUSTMAS') FROM(CUSTOMER-MASTER-RECORD) RESP(RESPONSE-CODE) END-EXEC END-IF.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant