Progress0 of 0 lessons

CICS DOCUMENT DELETE - Document Deletion

CICS DOCUMENT DELETE provides document deletion capabilities in CICS environments. It enables programs to delete documents, manage document operations, and handle document deletion for cleanup and maintenance purposes.

Command Syntax

cobol
1
2
3
4
5
EXEC CICS DOCUMENT DELETE [DOCUMENT(document-name)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.

Parameters

DOCUMENT(document-name)

Specifies the name of the document to be deleted. This parameter identifies the specific document for deletion operations.

RESP(response-code)

Specifies the response code variable to receive the operation result. This parameter provides error handling and status information.

RESP2(response-code-2)

Specifies the secondary response code variable for additional error information. This parameter provides extended error details when available.

Deletion Types

Single Document Deletion

DOCUMENT DELETE removes a single document from the system, freeing up storage space and removing the document from active use.

Batch Document Deletion

The command supports batch deletion operations for removing multiple documents efficiently in maintenance procedures.

Conditional Deletion

Documents can be deleted based on specific conditions such as age, status, or business rules for automated cleanup.

Secure Deletion

Secure deletion ensures that sensitive document data is properly removed and cannot be recovered after deletion.

Programming Examples

Basic Document Deletion

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'INVOICE-001'. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. PROCEDURE DIVISION. EXEC CICS DOCUMENT DELETE DOCUMENT(DOCUMENT-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Document deleted successfully' ELSE DISPLAY 'Error deleting document: ' RESPONSE-CODE END-IF.

Multiple Document Deletion

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16). 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-INVOICE-DOCUMENTS PERFORM DELETE-STATEMENT-DOCUMENTS PERFORM DELETE-REPORT-DOCUMENTS. DELETE-INVOICE-DOCUMENTS. MOVE 'INVOICE-001' TO DOCUMENT-NAME EXEC CICS DOCUMENT DELETE DOCUMENT(DOCUMENT-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO DELETE-COUNT DISPLAY 'Invoice document deleted' END-IF. DELETE-STATEMENT-DOCUMENTS. MOVE 'STATEMENT-001' TO DOCUMENT-NAME EXEC CICS DOCUMENT DELETE DOCUMENT(DOCUMENT-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO DELETE-COUNT DISPLAY 'Statement document deleted' END-IF. DELETE-REPORT-DOCUMENTS. MOVE 'REPORT-001' TO DOCUMENT-NAME EXEC CICS DOCUMENT DELETE DOCUMENT(DOCUMENT-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO DELETE-COUNT DISPLAY 'Report document deleted' END-IF.

Conditional Document Deletion

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16). 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 PROCESSING-COUNT PIC S9(8) COMP VALUE 0. 01 DELETE-THRESHOLD PIC S9(8) COMP VALUE 5. PROCEDURE DIVISION. PERFORM VARYING PROCESSING-COUNT FROM 1 BY 1 UNTIL PROCESSING-COUNT > 10 PERFORM BUILD-DOCUMENT-NAME PERFORM CHECK-DELETE-CONDITION IF DELETE-REQUIRED PERFORM DELETE-DOCUMENT END-IF END-PERFORM. BUILD-DOCUMENT-NAME. STRING 'DOC-' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE INTO DOCUMENT-NAME. CHECK-DELETE-CONDITION. IF PROCESSING-COUNT > DELETE-THRESHOLD SET DELETE-REQUIRED TO TRUE ELSE SET DELETE-NOT-REQUIRED TO TRUE END-IF. DELETE-DOCUMENT. EXEC CICS DOCUMENT DELETE DOCUMENT(DOCUMENT-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Document ' DOCUMENT-NAME ' deleted successfully' ELSE DISPLAY 'Error deleting document ' DOCUMENT-NAME ': ' RESPONSE-CODE END-IF.

Error Handling

Response Code 0

Successful document deletion. The document has been successfully deleted from the system.

Response Code 8

Invalid document name. The specified document name is invalid or not supported.

Response Code 12

Document not found. The specified document does not exist in the system.

Response Code 16

Document in use. The document is currently in use and cannot be deleted.

Response Code 20

Deletion failed. The document deletion operation failed due to system conditions.

Performance Considerations

Storage Reclamation

DOCUMENT DELETE efficiently reclaims storage space, but large document deletions may impact system performance temporarily.

Batch Operations

Batch deletion operations should be scheduled during off-peak hours to minimize impact on active business operations.

Resource Cleanup

Proper resource cleanup ensures efficient deletion operations and prevents resource leaks in the system.

Best Practices

Error Handling

Always check response codes and handle errors appropriately, especially for document existence and usage validation.

Deletion Confirmation

Implement proper deletion confirmation mechanisms to prevent accidental deletion of important documents.

Audit Trail

Maintain audit trails for document deletions to track deletion history and support compliance requirements.

Backup Considerations

Ensure proper backup procedures are in place before performing bulk deletion operations to prevent data loss.

Explain It Like I'm 5 Years Old

Imagine you have a toy box full of toys, and some toys are old or broken. CICS DOCUMENT DELETE is like throwing away those old toys to make room for new ones.

The document name is like the name of the toy you want to throw away. Once you throw it away, it's gone and you can't get it back, but you have more space in your toy box.

Just like you need to be careful not to throw away toys you still want to play with, the program needs to make sure it's only deleting documents that are safe to delete.

Exercises

Exercise 1: Basic Document Deletion

Write a program that uses DOCUMENT DELETE to remove a document with a specific name and verify the deletion was successful.

Exercise 2: Batch Document Cleanup

Create a program that deletes multiple documents based on specific criteria such as age or status.

Exercise 3: Conditional Deletion Logic

Implement a document deletion system that only deletes documents when specific business conditions are met.