CICS DELETE provides record deletion capabilities in CICS environments. It enables programs to delete records, manage file operations, and handle record deletion for data management and maintenance purposes.
1234567EXEC CICS DELETE [FILE(file-name)] [RIDFLD(record-id)] [KEYLENGTH(key-length)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.
Specifies the name of the file from which the record will be deleted. This parameter identifies the target file for deletion operations.
Specifies the record identifier field containing the key of the record to be deleted. This parameter identifies the specific record for deletion.
Specifies the length of the key field used to identify the record. This parameter controls the key matching for record identification.
Specifies the response code variable to receive the operation result. This parameter provides error handling and status information.
Specifies the secondary response code variable for additional error information. This parameter provides extended error details when available.
DELETE removes records based on key values, enabling programs to delete specific records identified by their primary or alternate keys.
The command supports current record deletion for removing the record currently positioned by a browse operation.
Conditional deletion enables record removal based on specific business rules and data conditions for automated cleanup.
Batch deletion supports removal of multiple records efficiently in maintenance procedures and data cleanup operations.
1234567891011121314151617181920212223WORKING-STORAGE SECTION. 01 FILE-NAME PIC X(8) VALUE 'CUSTOMER'. 01 RECORD-KEY PIC X(10) VALUE 'CUST001'. 01 KEY-LENGTH PIC S9(8) COMP VALUE 10. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. PROCEDURE DIVISION. EXEC CICS DELETE FILE(FILE-NAME) RIDFLD(RECORD-KEY) KEYLENGTH(KEY-LENGTH) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Record deleted successfully' DISPLAY 'File: ' FILE-NAME DISPLAY 'Key: ' RECORD-KEY ELSE DISPLAY 'Error deleting record: ' RESPONSE-CODE END-IF.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354WORKING-STORAGE SECTION. 01 FILE-NAME PIC X(8) VALUE 'CUSTOMER'. 01 RECORD-KEY PIC X(10). 01 KEY-LENGTH PIC S9(8) COMP VALUE 10. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 DELETE-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM DELETE-CUSTOMER-001 PERFORM DELETE-CUSTOMER-002 PERFORM DELETE-CUSTOMER-003. DELETE-CUSTOMER-001. MOVE 'CUST001' TO RECORD-KEY EXEC CICS DELETE FILE(FILE-NAME) RIDFLD(RECORD-KEY) KEYLENGTH(KEY-LENGTH) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO DELETE-COUNT DISPLAY 'Customer 001 deleted' END-IF. DELETE-CUSTOMER-002. MOVE 'CUST002' TO RECORD-KEY EXEC CICS DELETE FILE(FILE-NAME) RIDFLD(RECORD-KEY) KEYLENGTH(KEY-LENGTH) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO DELETE-COUNT DISPLAY 'Customer 002 deleted' END-IF. DELETE-CUSTOMER-003. MOVE 'CUST003' TO RECORD-KEY EXEC CICS DELETE FILE(FILE-NAME) RIDFLD(RECORD-KEY) KEYLENGTH(KEY-LENGTH) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO DELETE-COUNT DISPLAY 'Customer 003 deleted' END-IF.
12345678910111213141516171819202122232425262728293031323334WORKING-STORAGE SECTION. 01 FILE-NAME PIC X(8) VALUE 'CUSTOMER'. 01 RECORD-KEY PIC X(10). 01 KEY-LENGTH PIC S9(8) COMP VALUE 10. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 PROCESSING-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM VARYING PROCESSING-COUNT FROM 1 BY 1 UNTIL PROCESSING-COUNT > 5 PERFORM BUILD-RECORD-KEY PERFORM DELETE-RECORD END-PERFORM. BUILD-RECORD-KEY. STRING 'CUST' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE INTO RECORD-KEY. DELETE-RECORD. EXEC CICS DELETE FILE(FILE-NAME) RIDFLD(RECORD-KEY) KEYLENGTH(KEY-LENGTH) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Record ' RECORD-KEY ' deleted successfully' ELSE DISPLAY 'Error deleting record ' RECORD-KEY ': ' RESPONSE-CODE END-IF.
Successful record deletion. The record has been successfully deleted from the file.
Invalid file name. The specified file name is invalid or not supported.
Record not found. The specified record does not exist in the file.
Invalid key length. The specified key length is invalid or incompatible with the file structure.
Deletion failed. The record deletion operation failed due to system conditions.
DELETE efficiently removes records, but large deletion operations may impact system performance temporarily.
Proper file management ensures efficient deletion operations and prevents file corruption and resource issues.
Key validation ensures that deletion operations target the correct records and maintain data integrity.
Always check response codes and handle errors appropriately, especially for record existence and file validation.
Validate record keys before deletion to ensure that the correct records are targeted for removal.
Implement proper deletion confirmation mechanisms to prevent accidental deletion of important records.
Ensure data integrity by implementing proper deletion strategies and maintaining referential integrity.
Imagine you have a box of cards with names on them, and you want to throw away a specific card. CICS DELETE is like finding the card with the name you want and throwing it away.
The file name is like the name of your box of cards, and the record key is like the name on the card you want to throw away. When you delete it, the card is gone forever.
Just like you need to make sure you're throwing away the right card, the program needs to make sure it's deleting the right record.
Write a program that uses DELETE to remove a record with a specific key and verify the deletion was successful.
Create a program that deletes multiple records based on specific criteria such as status or date.
Implement a record deletion system that only deletes records when specific business conditions are met.