CICS UNLOCK provides record unlocking capabilities in CICS environments. It enables programs to unlock records, manage file operations, and handle record unlocking for proper resource management and concurrent access control.
1234567EXEC CICS UNLOCK [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 unlocked. This parameter identifies the target file for unlock operations.
Specifies the record identifier field containing the key of the record to be unlocked. This parameter identifies the specific record for unlocking.
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.
UNLOCK explicitly releases record locks, enabling programs to free locked records for access by other programs and transactions.
The command supports current record unlocking for releasing locks on records currently positioned by browse operations.
Conditional unlocking enables record lock release based on specific business rules and data conditions for flexible resource management.
Resource management ensures proper lock release and prevents deadlocks and resource contention in multi-program environments.
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 UNLOCK FILE(FILE-NAME) RIDFLD(RECORD-KEY) KEYLENGTH(KEY-LENGTH) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Record unlocked successfully' DISPLAY 'File: ' FILE-NAME DISPLAY 'Key: ' RECORD-KEY ELSE DISPLAY 'Error unlocking 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 UNLOCK-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM UNLOCK-CUSTOMER-001 PERFORM UNLOCK-CUSTOMER-002 PERFORM UNLOCK-CUSTOMER-003. UNLOCK-CUSTOMER-001. MOVE 'CUST001' TO RECORD-KEY EXEC CICS UNLOCK 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 UNLOCK-COUNT DISPLAY 'Customer 001 unlocked' END-IF. UNLOCK-CUSTOMER-002. MOVE 'CUST002' TO RECORD-KEY EXEC CICS UNLOCK 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 UNLOCK-COUNT DISPLAY 'Customer 002 unlocked' END-IF. UNLOCK-CUSTOMER-003. MOVE 'CUST003' TO RECORD-KEY EXEC CICS UNLOCK 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 UNLOCK-COUNT DISPLAY 'Customer 003 unlocked' 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 UNLOCK-RECORD END-PERFORM. BUILD-RECORD-KEY. STRING 'CUST' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE INTO RECORD-KEY. UNLOCK-RECORD. EXEC CICS UNLOCK 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 ' unlocked successfully' ELSE DISPLAY 'Error unlocking record ' RECORD-KEY ': ' RESPONSE-CODE END-IF.
Successful record unlocking. The record has been successfully unlocked and is available for access by other programs.
Invalid file name. The specified file name is invalid or not supported.
Record not locked. The specified record is not currently locked by this program.
Invalid key length. The specified key length is invalid or incompatible with the file structure.
Unlock operation failed. The record unlocking operation failed due to system conditions.
UNLOCK efficiently manages record locks, but delayed unlocking may impact system performance and concurrent access.
Proper resource management ensures efficient lock operations and prevents deadlocks and resource contention issues.
Concurrent access optimization ensures proper lock release and maximizes system throughput in multi-program environments.
Always check response codes and handle errors appropriately, especially for lock validation and record existence.
Implement proper lock management by ensuring records are unlocked promptly to prevent deadlocks and improve system performance.
Ensure proper resource cleanup by unlocking all records before program termination to prevent resource leaks.
Optimize concurrent access by implementing appropriate locking strategies and ensuring timely lock release.
Imagine you have a toy that you were playing with and you put a lock on it so no one else could play with it. CICS UNLOCK is like taking the lock off the toy so other kids can play with it too.
The file name is like the name of the toy box, and the record key is like the name of the specific toy you want to unlock. When you unlock it, other programs can use that toy.
Just like you need to unlock toys when you're done playing with them so other kids can use them, the program needs to unlock records when it's done with them so other programs can use them.
Write a program that uses UNLOCK to release a record lock and verify the unlocking was successful.
Create a program that manages multiple record locks and unlocks them appropriately.
Implement a resource management system that ensures all records are properly unlocked before program termination.