> -----Original Message-----
> From: IBM Mainframe Discussion List On Behalf Of John Weber
>
> I appreciated all of the good and prompt responses. It was really
appreciated. I did try
> 'task' just now with the same result. But this may just be the way
our logic is coded.
>
> Now we are trying the approach of a shared resource ENQ/DEQ. We will
test two transactions
> calling a transaction that ENQ's a resource. This SHOULD cause the
one transaction to wait
> until the other is DEQ'd.
Let me see if I understand what you're really trying to do (it might be
helpful if you specify which release(s) of CICS you're working with,
too)....
You have an arbitrary number of _different_ transactions (e.g., TRN1,
TRN2, ..., TRN9), _each_ of which LINKs to a common program ('COMPROG')
that is _not_ defined as the initial program of any transaction enabled
in "this" CICS region, correct?
Now you want to allow these transactions (TRN1 - TRN9) to LINK to
'COMPROG' "whenever", _provided that_ only ONE of TRN1 - TRN9 is allowed
to LINK to 'COMPROG' at a time, subsequent LINK-ers being suspended to
wait for the current LINK-er to RETURN and DEQ if necessary, correct?
For this scenario, the code sequence you showed originally will work
_provided that_ each of TRN1 - TRN9 specifies _exactly the same_
RESOURCE name in the ENQ (and DEQ) command, AND none of TRN1 - TRN9 has
a HANDLE CONDITION ENQBUSY active at the time ENQ is issued. The
RESOURCE name you specify is arbitrary, so for simplicity let's use
'COMPROG' as the RESOURCE name, and include the LENGTH attribute even
though LENGTH apparently is not needed for "semaphore" usage:
> 000024 EXEC CICS
> 000025 ENQ RESOURCE('COMPROG')
LENGTH(LENGTH OF 'COMPROG')
> 000027 RESP (WS-CICS-RESPONSE)
> 000028 END-EXEC
>
> 000038 EXEC CICS
> 000039 LINK PROGRAM('COMPROG')
> 000040 RESP (WS-CICS-RESPONSE)
> 000041 COMMAREA (WS-PARAMETER)
> 000042 END-EXEC
>
> 000044 EXEC CICS
> 000045 DEQ RESOURCE('COMPROG')
LENGTH(LENGTH OF 'COMPROG')
> 000046 RESP (WS-CICS-RESPONSE)
> 000047 END-EXEC
Reference:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DFHP4C00/1.75
We have an "elderly" application that uses this exact technique to
serialize access to the JES INTRDR (via a transient data queue) for
submitting batch JCL from within a CICS transaction. I'm not certain
that the LENGTH attribute is required for this "semaphore" usage of ENQ,
but in our "elderly" application program "it's there, and it works".
> I'm not too CICS savvy, but how do you define a small field that is
shared between transactions
> (does anyone have an example), and do you refer to that field in the
ENQ by name and length
> (again, an example would be most helpful)?
The simplest answer to this question appears to be the CICS Common Work
Area ("CWA"), the total size of which you may specify in the DFHSIT via
the WRKAREA parameter. Default size is 512 bytes; maximum size you may
specify is 3584 bytes (at CICS TS 3.2). You may also specify the
protection key (CICS or USER) in the DFHSIT via parameter CWAKEY.
To identify a specific (sub)field within the CWA you need to define a
DSECT (in COBOL I believe the equivalent is a LINKAGE SECTION mapping)
to map the portion of the CWA you want to use. Then, to access and
serialize on a specific field within your mapping or DSECT, you would
first issue EXEC CICS ADDRESS CWA(ptr-ref) to gain addressability to the
CWA, then "connect" your DSECT or LINKAGE SECTION mapping to the address
returned. In Assembler the code might look something like this:
... CSECT ,
...
EXEC CICS ADDRESS CWA(R5)
USING My_CWA_Dsect,R5 * Connect my DSECT to the CWA pointer
EXEC CICS ENQ RESOURCE(CWA_HalfWord) LENGTH(L'CWA_HalfWord)
* * ENQ the halfword field
LH R6,CWA_HalfWord * Load current value of CWA_Halfword
LA R6,1(,R6) * Increment
STH R6,CWA_HalfWord * Store new value of CWA_HalfWord
EXEC CICS DEQ RESOURCE(CWA_HalfWord) LENGTH(L'CWA_HalfWord)
* * Release the ENQ on the halfword field
DROP R5 * Release the CWA pointer
...
My_CWA_Dsect DSECT ,
CWA_DblWord DS D * a Doubleword
CWA_FullWord DS F * a Fullword
CWA_HalfWord DS H * a Halfword
... * the rest of the DSECT
Again, in this example there is no HANDLE CONDITION ENQBUSY active in
the program, so if CWA_HalfWord is already ENQ'd by another task, "this"
task will be suspended by CICS until CWA_HalfWord is "released" by the
other task.
HTH,
-jc-
> -----Original Message-----
> From: IBM Mainframe Discussion List [mailto:[email protected]] On
Behalf Of John Weber
> Sent: Friday, July 08, 2011 12:08 PM
> To: [email protected]
> Subject: ENQ/DEQ for CICS Transaction ID
>
> We are looking to restrict a transaction from being run concurrently.
We have launched two other
> transactions (the code below) that ENQ/DEQ this one transaction.
Using displays we were
> expecting to see all of the displays of these two other transactions
to follow one after the other;
> instead they are mingled. This suggests that they didn't run one
after the other.
>
> Is the following code sufficient or even unworkable? I have read that
ENQ/DEQ can be used for
> transactions and not only with shared memory resources.
>
> Also, does some other ENQ information need to be set up?
>
> Thank you so much...
>
> XXXX refers to the transaction id and XXXXXXXX refers to the program
associated with this id.
>
> 000024 EXEC CICS
> 000025 ENQ RESOURCE(XXXX)
> 000027 RESP (WS-CICS-RESPONSE)
> 000028 END-EXEC
>
> 000038 EXEC CICS
> 000039 LINK PROGRAM('XXXXXXXX')
> 000040 RESP (WS-CICS-RESPONSE)
> 000041 COMMAREA (WS-PARAMETER)
> 000042 END-EXEC
>
> 000044 EXEC CICS
> 000045 DEQ RESOURCE(XXXX)
> 000046 RESP (WS-CICS-RESPONSE)
> 000047 END-EXEC
>
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html