I have checked manuals and previous to get the answer but didn't clear still.
Regarding the resource that we mention in ENQ. As per my understanding the RESOURCE in an ENQ can be a VSAM file , a storage , etc.
The resource that is to be enqueued on must be identified by one of the following methods:
Specifying a data area that is the resource. It is the location (address) of the data area in storage that is important, not its contents. Two tasks, enqueuing on the same resource and using this method, must refer to the same location in storage. They could both, for example, refer to the same location in the Common Work Area (CWA).
EXEC CICS ENQ
Specifying a data area that contains a unique character string argument (for example, an employee name) that represents the resource. It is the contents of the data area that is important, not its location. Two tasks, enqueuing on the same resource and using this method, can refer to the same location or different locations, but the contents of the locations must be the same. The length must be supplied in the LENGTH option and can be up to 255 bytes long.
EXEC CICS ENQ
here my query is ENQ a data area which contains a character string. I have program where i ENQ a resource like
01 WS-RESOURCE PIC X 10 VALUE 'ABCDEFG'
and in my program i am ENQ uing the same
EXEC CICS ENQ
LENGTH(LENGTH OF WS-RESOURCE)
What will be the relevance of ENQ uing a data string here.? Any thoughts?
Joined: 06 Jun 2008 Posts: 8449 Location: Dubuque, Iowa, USA
From the description of ENQ in the CICS Application Programming Reference manual, 1.75, with emphasis added by me:
ENQ causes further execution of the task issuing the ENQ command to be synchronized with the availability of the specified resource; control is returned to the task when the resource is available.
A resource in the context of this command is any string of 1-255 bytes, established by in-house standards, to protect against conflicting actions between tasks, or to cause single threading within a program.
I suspect you mis-understand the resource in the ENQ command: if it is a VSAM file name, it does NOT represent the actual VSAM file that CICS has defined -- it is an 8-byte variable that happens to be the same bytes used by CICS to reference a file.
Normally you dont have use END/DEQ. The END/DEQ can be used when you want to ensure "something" isnt referenced/changed by more than one task at a time e.g. values in CWA, as the CWA is not a "protected resource" in CICS. For files etc the "protection" is handled by CICS without any special programming. This is one of the objectives of a "Transation Processing" system.
Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
If you do need to use an ENQ/DEQ Resource, it would be in your best interest to define the resource-name, using a combination of upper/lower case letters, numeric values, along with special characters in an attempt to make it as unique as possible. EG:
Doing this will reduce other creative minds in your shop from duplicating the name.
One last thought; Once you're done with accessing the resource and you're not at task termination, issue a DEQ.