Previous Topic: Execute a Compiled IMOD Using SRVBATCH

Next Topic: Package IMODs as a Load Module

Example: IMOD for Processing Operator Commands

This WHOHAS IMOD processes an operator command.

Note: This IMOD is a sample only; it may not work in your environment.

#DESC Command: WHOHAS dsn
/*
This IMOD will notify the operator of current owners and waiters
for the data set. Add the next line to the CA‑GSS initialization
parameters and cycle the address space.
    COMMAND VERB WHOHAS IMOD WHOHAS
*/
   parse upper arg . dsn .
   queue 'SRV000 WHOHAS'
   queue 'DSNAME = '||dsn
   handle = dsnenq('obtain')
   if rc ^= 0 then do
      say 'dsnenq.obtain returned '||rc||' ‑ '||handle
      queue '*** Internal error 1 ***'
      queue rc||' - '||handle
      signal write2
      end
   result = dsnenq('info',handle,dsn)
   if rc ^= 0 then do
      if rc ^= 121 then do
         say 'dsnenq.obtain returned '||rc||' - '||handle
         queue '*** Internal error 2 ***'
         queue rc||' - '||result
         signal write
         end
      dsn_count = 0
      end
   if dsn_count < 1 then do
      queue = '*** Data set not in use ***'
      signal write
      end
/*  Tell operator who has data set  */
   queue 'Jobname  System   ASID Jobtype  Ownership'
   queue '-------- -------- ---- -------- --------------'
   do i = 1 to dsn_count
      queue   dsn_jobname.i||' '|| ,
              substr(dsn_sysid.i,1,8)||' '|| ,
              d2x(dsn_asid.i,4)||' '|| ,
              substr(dsn_jobtype.i,1,8)||' '|| ,
              substr(dsn_status.i,1,4)||' '|| ,
              substr(dsn_mode.i,1,4)
      end
write:
   result = dsnenq('release',handle)
write2:
   result = mlwto(,,5,imod_console)
   return

The IMOD execution process is as follows:

  1. An operator enters the WHOHAS command followed by a data set name at an operator console.
  2. ISERVE intercepts the command and executes the IMOD.
  3. The IMOD obtains the command string as a REXX argument and extracts the data set name.
  4. The DSNENQ() function issues a query to GRS about the data set.
  5. The IMOD builds a screen display, line by line, on the program stack.
  6. The MLWTO() function displays the results on the console of the operator.

    The following sample displays the current users of a data set and those users who are waiting for the data set:

    17:45:40.22          WHOHAS KBROWNE.TEST.CAICLIB
    17:45:40.88 STC05434 SRV000 WHOHAS 710
    DSNAME = KBROWNE.TEST.CAICLIB
    JOBNAME  SYSTEM   ASID JOBTYPE  OWNERSHIP
    -------- -------- ---- -------- --------------
    KBROWNE  MVSB1    00B8 TSU      OWN  SHR
    BATJOB   MVSB1    00C8 JOB      WAIT EXCL