1 # functions for working with jobs
   2 # jack j. woehr 2014
   3 
   4 # Show all jobs in a joblist
   5 FUNC showJobs ( joblist ) $[
   6     LOCAL @subsys LOCAL @type
   7     FOR @j in @@joblist $[
   8         put -n -s ${ job }$
   9         put -n -s -from @j
  10         job -job @j -get subsystem -to @subsys
  11         job -job @j -get type -to @type
  12         put -n -s -from @subsys put -n -s -from @type
  13         put -n -s ${ is owned by }$ job -job @j -get user
  14     ]$
  15 ]$
  16 
  17 # End all jobs on a joblist except those excluded
  18 # We preset the @isExcluded flag false in case FOR never entered
  19 FUNC endJobs ( joblist excluded ) $[
  20     FOR @j in @@joblist $[
  21         LOCAL @jobuser LOCAL @user LOCAL @isExcluded
  22         tuple -false @isExcluded
  23         job -job @j -get user -to @jobuser
  24         FOR @user in @@excluded $[
  25             test -to @isExcluded -eq @jobuser @user
  26             IF @isExcluded THEN $[ BREAK ]$
  27         ]$
  28         IF @isExcluded THEN $[
  29             put -n ${ found excluded user }$ put -n -s -from @jobuser put -n ${ in job }$ put -from @j
  30             ]$ ELSE $[
  31             job -job @j -refresh
  32             put -n ${ ending job controlled }$ put -from @j
  33             job -job @j -end -1
  34         ]$
  35     ]$
  36 ]$
  37 
  38 # End all jobs for a given user
  39 FUNC endJobsForUser ( username as400 ) $[
  40     LOCAL @joblist LOCAL @nada
  41     joblist -as400 @@as400 -to @joblist -username @@username
  42     put -to @nada ${ }$
  43     endJobs ( @joblist @nada )
  44 ]$
  45 
  46 # End all active interactive jobs except those whose users are excluded
  47 FUNC endActiveInteractiveJobs ( as400 excluded ) $[
  48      LOCAL @joblist
  49      joblist -as400 @@as400 -to @joblist -jobtype INTERACTIVE -active
  50      endJobs ( @joblist @@excluded )
  51 ]$
  52 
  53 # End all disconnected interactive jobs except those whose users are excluded
  54 FUNC endDisconnectedInteractiveJobs ( as400 excluded ) $[
  55      LOCAL @joblist
  56      joblist -as400 @@as400 -to @joblist -jobtype INTERACTIVE -disconnected
  57      endJobs ( @joblist @@excluded )
  58 ]$
  59