This is a simplification of to focus on the main points. During a part of the 
day we run a procedure that was developed offshore. This procedure provides 
certain secure services and when a violation is detected it must write a data 
record for later analysis. This requirement was discovered later and for the 
time being can not be built into the product. These violations do not happen 
very often, and sometimes not for extended periods. 

We have different processing cycles and different things running, so if a 
message that should never happen in a particular cycle is detected we send an 
email to get human intervention and fix the error. If a violation is detected 
during the time we are supposed to be running the process, then a subtask is 
started to write a data record to a logging file.  This is the simplest 
procedure I have come up with. It uses two queues, and I was wondering if it 
was profligate use of resources to enable a simple programmed solution, because 
I am using a Queue as little more than a switch. I would appreciate any 
comments on that and anything that might make it simpler or more efficient.

During A4_SHIFT the procedure cannot be running, so if any messages from it are 
detected an email is sent to get human intervention. 

During B4_SHIFT the procedure can be running and a specific violation message 
is checked for. When that message is detected, a piece of user information is 
extracted and passed to a subtask to write it to a dataset. 

*
* Console Message intercept statements
*
SECTION A4_SHIFT
MSG='MMW1'
   VAR &MSGID POS 1 LEN 8 LOCAL
   EMAIL TO [email protected]
         SUBJECT 'Time Violation'
          '&MSGID detected out of cycle'
ENDSECTION


SECTION B4_SHIFT
MSG=MMW1431S
   VAR &USID POS 21 LEN 8 LOCAL
   RUN XMNOTIF (&USID) ASYNCH  

MSG=. . . .
. . . 
ENDSECTION


The subtask XMNOTIF uses a Queue (JMXALLOC) to indicate the state of the 
recording dataset. When the dataset is allocated the queue is held exclusively. 
If the queue is unused, the exclusive lock is taken and the dataset is 
allocated. If the queue is in any other state but UNUSED, we know the dataset 
is allocated so we just write the record. Asynchronous processes that want to 
access the dataset at the same time are locked by another enqueue on 
JMXQUEUENAME. This prevents tasks from trying to alloc, write or dealloc at the 
same time.


/* XMNOTIF Command list subtask */ 
VAR &USERID LEN 8 LOCAL
*
PARSE ARGS INTO &USERID /* get userid passed as arg */
* 
ENQUEUE EXCL 'JMXQUEUENAME' 
IF QUEUE(JMXALLOC)= UNUSED DO
   ENQUEUE EXCL 'JMXALLOC' 
   ALLOC DDNAME(VIOLRECD) DSN(DATA.SET.NAME) MOD 
END 
*
WRITE DDNAME(VIOLRECD) ‘&DATE &TIME Violation(&VNUM) &USERID'
DEQUEUE 'JMXQUEUENAME' 
*                                                                   
--------------------------------------------------------------

During the shift change the first thing is to disable message sections that 
respond to the violation messages. When this is done there will be no more 
subtasks. So we take exclusive lock on the queue and check the allocated queue. 
If it is in use we dealloc the data file. Both queues are then deleted and the 
new shift message intercepts enabled.

/* Changeover procedure */
. . .
DISABLE SCHED (B4_SHIFT)  /* stop scheduling    */
DISABLE MSGID(B4_SHIFT)   /* stop proc this way */
* 
ENQUEUE EXCL 'JMXQUEUENAME' 
*
IF QUEUE(JMXALLOC)= HELDEXCL 
   DEALLOC DDNAME(VIOLRECD)
*
DELETE QUEUE 'JMXALLOC' 
DELETE QUEUE 'JMXQUEUENAME'  
*
ENABLE MSGID(A4_SHIFT)   /* start proc this way */
ENABLE SCHED (A4_SHIFT)  /* start scheduling    */

                 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to