Published on System iNetwork (http://systeminetwork.com)
WRKJOB Enhanced to Run Commands in other Jobs
By bradforde
Created May 6 2008 - 19:39

By:
Carsten Flensburg [1]

In my recent utilities, I have presented the RUNJOBCMD (Run Job Command) [2] that allows you to send a command to run in another job. This utility was updated from my 2005 article so that it would work with the i5/OS V5R4 restrictions on interrupting a job. In conjunction, I also presented the utilities to Query and Change a Job's Interrupt Status(RTVJOBIPTS and CHGJOBITPS) [3] at V5R4 and above.

In V5R4, a job must be tweaked to allow an interrupt to run a command sent from another job. CHGJOBITPS does the tweak.

Soon after I began using the RUNJOBCMD command heavily, it became evident to me that I really needed to provide a front-end to this utility to help me quickly locate the correct job in which to run a command as well as easily submit that command without having to note and specify the fully qualified job name.

But I hadn't spent much time at the drawing board when I realized that I had already written a command allowing a user to select specific jobs based on a set of criteria: The WRKJOBS (Work with Jobs) command that I created some time ago and that had served as an example of how to take advantage of Open List APIs, in an article published in the September 2006 issue of System iNEWS [4]. So, I simply decided to adapt the WRKJOBS command to include an option 14, enabling a user to run the RUNJOBCMD command for a selected job or jobs.

The WRKJOBS command has the following command prompt:


                          Work with Jobs (WRKJOBS)

 

Type choices, press Enter.

 

Job name . . . . . . . . . . . .   *ALL          Name, generic*, *ALL...

User name  . . . . . . . . . . . > DAN           Name, generic*, *ALL...

Job status . . . . . . . . . . .   *ACTIVE       *ACTIVE, *JOBQ,
*OUTQ... 
Job type . . . . . . . . . . . .   *ALL          *ALL, *AUTO, *BATCH...

Current user . . . . . . . . . .   *NOCHK        Character value, *NOCHK

Completion status  . . . . . . .   *ALL          *ALL, *NORMAL,
*ABNORMAL 
 

Running the WRKJOBS command as specified above will list all currently active jobs for the user profile DAN, resulting in a work-with display panel similar to the one below:


                                 Work with Jobs MYSYSTEM                                                          23-04-08
17:48:29
 Type options, press Enter.

   2=Change     3=Hold   4=End   5=Work with   6=Release   8=Spooled
files     
   10=Job log   12=Work with user jobs   13=Disconnect     14=Run job
command  
 

                  Current                                   Function/

 Opt  Job         User        Job date  Type  ---Status---  Completion

      DSP001      DAN         23-04-08  INT   ACTIVE  DSC   MNU-MAIN

 14   DSP002      DAN         23-04-08  INT   ACTIVE  DSPW  MNU-SECTOOLS

      DSP003      DAN         23-04-08  INT   ACTIVE  DSPW  MNU-SECURITY

      DSP004      DAN         23-04-08  INT   ACTIVE  DSPW  MNU-SECBATCH

 

 
Bottom
 Parameters or command

 ===>

 F3=Exit   F4=Prompt   F5=Refresh   F6=Submit job   F9=Retrieve
F11=View 2   
 F12=Cancel   F21=Print list        F22=Work with active jobs

From there, you simply select option 14 for the job in which you want to run a command and fill out the resulting command prompt -- and, of course, you can also run the other available options against the selected job or jobs as well.

The new WRKJOBS command consists of the following source code:


CBX977  -- RPGLE  -- Work with Jobs - CCP                      
CBX977E -- RPGLE  -- Work with Jobs - UIM General Exit Program 
CBX977H -- PNLGRP -- Work with Jobs - Help                     
CBX977L -- RPGLE  -- Work with Jobs - UIM List Exit Program    
CBX977P -- PNLGRP -- Work with Jobs - Panel Group              
CBX977V -- RPGLE  -- Work with Jobs - VCP                      
CBX977X -- CMD    -- Work with Jobs                            

CBX977M -- CLP    -- Work with Jobs - Build command            
 

You'll find compilation instructions in the individual source headers. But as a quick create path, compiling and running the CBX977M CL program will build all the command objects for you, just supply the compile library as the only parameter when you call the program. Follow the instructions in the CBX977M source header for more information.

You can download a zip file containing all the source code from the URL
http://systeminetwork.com/files/wrkjobs_0.zip

Note: As with all new programs, test these routines thoroughly before placing them into a production environment. No warranty is expressed or implied.

Copyright © Penton Media

Source URL: http://systeminetwork.com/article/wrkjob-enhanced-run-commands-other-jobs

Links:
[1] http://systeminetwork.com/author/carsten-flensburg
[2] http://systeminetwork.com/article/sending-commands-another-job-revisited-i5os-v5r4
[3] http://systeminetwork.com/article/query-and-change-your-v5r4-job-interrupt-status-attribute
[4] http://systeminetwork.com/article/apis-work-jobs