and did not end the tranasction. I was using Intertest and basically after the BASR of the ENQ command, the response code was zero.
Opening another session, with another user id, I tried to run the tranasction B, which had this code in another program
MVC SMGENFNM,=C'GCONB010'
EXEC CICS WRITE FILE(SMGENFNM) .........
And the write executed to response code zero where as I thought ENQ lock would not allow the WRITE to happen.
After some search, found out that, bascially the variable SMGENFNM only will be enqueued and not the logical FCT entry contained in the variable.
What should be my exact syntax in this case to lock the VSAM file using ENQ..?
Note:-
1) Tried EXEC CICS ENQ RESOURCE('GCONB010') UOW NOSUSPEND but got compilation error
2) The shareoption of the dataset of the FCT entry is (1,3)
review Your understanding of the ENQ/DEQ mechanism
it is based on strict conventions and tight agreement on how to behave in order to enforce ENQ/DEQ
enq/deq is based on <tokens> which are a <logical> name assigned to the resource under attempted exclusive control
all the interested parties in the process must agree on
issuing an ENQ on an agreed toked
issuing a DEQ on the same token so that other might access the resource
like in Your example
all the interested parties must agree on
ENQ
process <whatever the process>
DEQ
if one of the partners does not abide to the convention the ship will sink !
My requirement is that
1) The first transaction should lock the VSAM file
2) If any other tranasaction tries to update it, it should wait if any lock is held agains the file
3) Once the first transction releases the exclusive access, the second trasnsaction should continue.
We thought ENQ/DEQ mechanism would exactly achieve this purpose. Are we wrong on this? If no, then
Quote:
issuing a DEQ on the same token so that other might access the resource
what exactly should be the token to link it with the file if it not the FCT name ? If it is the FCT name, then how exaclty I manage the syntax in the example I had given?
(Since all these programs are in one sytem only, if there is a convention, it can be followed throughout)
Quote:
it is based on strict conventions and tight agreement
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
If even one of the processes that update the file does not first enqueue the file-token, there will be no "lock" protection. Every participant must use the same resource and every one must issue the enq and later the deq.
If there are only 2 participants and you have complete control of the code, this might work. If there are many participants, the chance of a process not following the rules increases dramatically.
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
In addition, your ENQ/DEQ name should be a unique (but well known) name. It should NOT be the same name (as in your example) of the file-name. I'm surprised you didn't get an INVREQ on one (or more) of the API's, involving this name.
As has been said, all participating programs who access this file need to use the same ENQ/DEQ name and mechanism.
Otherwise, it won't work as expected.
To centralize the ENQ/DEQ naming convention, define a VSAM file (CICS SDT) or a Static Assembler table, which contains an Resource-Name (IE: A File-Name, A Program-Name, etc) and its corresponding Site-Defined RESOURCE-ID.
EG: GCONB010,RESOURCE-ID-GCONB010
If you don't find an entry for the resource you would like to ENQ on, then just continue.
However, if there is an entry, then issue a HANDLE CONDITION ENQBUSY (YOUR-LABEL-NAME) and then ENQ on the Site-Defined RESOURCE-ID.
Resource-Id's have a maximum length of 255-Bytes.
I would recommend that as soon as you're done with the ENQ'd Resource, issue a DEQ, unless you're very close to task termination, in which case, CICS will issue an implicit DEQ.
If you're not close to task termination (IE: returning to a caller), issue a HANDLE CONDITION ENQBUSY, without a label, which essentially returns control to CICS and removes this condition from your program.
One last observation. There needs to be a compelling reason to ENQ/DEQ on ANY resource as it causes Exclusive-Control/Single-Threading. You don't want to fictitiously increase task-time. Tasks should complete as fast as possible.
Most shops are still not Threadsafe, so only the QR TCB is used for delegating work. You don't want to back it up because all sorts of "opportunities" could rear their ugly head....
To centralize the ENQ/DEQ naming convention, define a VSAM file (CICS SDT) or a Static Assembler table, which contains an Resource-Name (IE: A File-Name, A Program-Name, etc) and its corresponding Site-Defined RESOURCE-ID.
1) Is it possible to dynamically fetch the resource-id using any API/SPI commands?I tried looking something regarding the CEDA commands but got really confusing.
2) If it is not possbile, then we are looking to build the table the first time by getting information from the system guys. However, is it possible that every time the CICS region is refreshed, willl the resource-id be changed?
This might be my site-specific, but wanted to get your inputs.