CICS - DELETE



DELETE command is used to delete a record that is 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 of Delete command is as follows −

Syntax

EXEC CICS DELETE
   FILE('name')
END-EXEC.

Following is the syntax to delete a record directly without reading it with Update option −

Syntax

EXEC CICS DELETE
   FILE('name')
   RIDFLD(data-value)
END-EXEC.

Example

Following is the example for Group Delete. This can be done using Generic option, where all the records that satisfy the generic criteria will be deleted. NUMREC will hold the number of records deleted. The field mentioned here should be a S9(4) comp.

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).
01 WS-NUM-REC-DEL    PIC S9(4).
PROCEDURE DIVISION.
MOVE '11'       TO WS-STD-REC-KEY.
MOVE 2          TO WS-STD-KEY-LEN.
EXEC CICS READ
   FILE ('FL001')
   RIDFLD (WS-STD-REC-KEY)
   KEYLENGTH (WS-STD-KEY-LEN)
   GENERIC
   NUMREC (WS-NUM-REC-DEL)
END-EXEC.

Delete Command Exceptions

The following table shows the list of exceptions that arise during a DELETE statement −

Sr.No Exception & Description
1

NOTOPEN

File is not open.

2

NOTFND

Record that is being searched doesn't exist in the dataset (DELETE with RIDFLD).

3

NOTAUTH

If the user does not have enough permissions to use the file.

4

INVREQ

Rewrite without prior READ with UPDATE.

5

FILENOTFOUND

File entry is not made in FCT.

cics_file_handling.htm
Advertisements