
- CICS Tutorial
- CICS - Home
- CICS - Overview
- CICS - Environment
- CICS - Basic Terms
- CICS - Nucleus
- CICS - Transactions
- CICS - COBOL Basics
- CICS - BMS
- CICS - MAP
- CICS - Interface Block
- CICS - Pseudo Programming
- CICS - Aid Keys
- CICS - File Handling
- CICS - Error Handling
- CICS - Control Operations
- CICS - Temporary Storage
- CICS - Intercommunication
- CICS - Status Codes
- CICS - Interview Questions
- CICS Useful Resources
- CICS - Quick Guide
- CICS - Useful Resources
- CICS - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
CICS - REWRITE
REWRITE command is used to modify a record that is already present in a file. Prior to this command, the record must be read with a READ UPDATE command. The parameters are same as described before. The syntax for the Rewrite command is as follows −
Syntax
EXEC CICS REWRITE FILE (name) FROM (data-area) LENGTH (data-value) END-EXEC.
Example
The following example shows how to write a record in 'FL001' file where Studentid is the primary key. A new record with 101 student id will be written in the file −
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-STD-REC-LEN PIC S9(4) COMP. 01 WS-STD-KEY-LEN PIC S9(4) COMP. 01 WS-STD-REC-KEY PIC 9(3). 01 WS-STD-REC PIC X(70). PROCEDURE DIVISION. MOVE +70 TO WS-STD-REC-LEN. MOVE ‘101’ TO WS-STD-REC-KEY. MOVE 3 TO WS-STD-KEY-LEN. EXEC CICS READ FILE ('FL001') INTO (WS-STD-REC) LENGTH (WS-STD-REC-LEN) RIDFLD (WS-STD-REC-KEY) KEYLENGTH (WS-STD-KEY-LEN) UPDATE END-EXEC. MOVE '100Mohtahim M TutorialsPnt' TO WS-STD-REC. EXEC CICS REWRITE FILE ('FL001') FROM (WS-STD-REC) LENGTH (WS-STD-REC-LEN) END-EXEC.
Rewrite Command Exceptions
The following table lists the exceptions that arise during a REWRITE statement −
Sr.No | Exception & Description |
---|---|
1 | NOTOPEN File is not open. |
2 | LENGERR Mismatch between the length specified in command and actual length of the record. |
3 | NOTAUTH If the user does not have enough permissions to use the file. |
4 | INVREQ Rewrite without prior READ with UPDATE. |
5 | NOSPACE There is not enough space in the dataset. |