Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Job Monitoring within a Program

Status
Not open for further replies.

jsplice

Programmer
Jun 3, 2003
88
US
Hello all. I have a menu screen I am developing as sort of a "test menu". It will run different parts of an entire process we have, but will run it in pieces for testing purposes. I'd like to create a "final report" that will run at the end of the job that is executed to provide record counts of outfiles and to give some performance statistics. I have the part finished that is showing record counts. However, I'm not sure how to handle the job statistics part of it. I could easily record the job start time by storing the system time when the job is submitted from the menu. However, how do I get the job end time, and other statistics such as CPU time? Will this require some type of job monitor, and if so, how can I automate the monitor and get statistics from it for a report?

Thanks
 
RTVJOBA has a DATETIME parameter (20A). Do that first ting and last thing, and compute the difference.

RTVJOBA command help said:
The local job date and time is returned in the format YYYYMMDDHHNNSSXXXXXX where YYYY is the year, MM is the month, DD is the day, HH is the hours, NN is the minutes, SS is the seconds, and XXXXXX is the microseconds.

This is on V5R3.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
For the processor seconds used, have you tried to do a RCVMSG for CPF1164 (the job completion message)?

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
I like the idea of the RTVJOBA. However, how is the program going to receive the CPF1164 message if it is stuck on a program line while waiting for user input? It wouldn't have a change to execute the RCVMSG until after the user presses enter. And what if the user exits out of the menu before the job that was submitted by it finishes?
 
jsplice said:
However, how is the program going to receive the CPF1164 message if it is stuck on a program line while waiting for user input? It wouldn't have a change to execute the RCVMSG until after the user presses enter.

What's the point doing this for an interactive job? Maybe I'm missing something...

jsplice said:
And what if the user exits out of the menu before the job that was submitted by it finishes?

If the user exits, the CL you have wrapping the RPG program will still execute (unless they end the job abnormally by closing the emulator session or something).

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
The programs being called from the menu are submitted with SBMJOB; they are not run interactively. This is why I thought it would be hard in the first place to track the job that was submitted. At the very least I can get the job start time by getting the current time just before the program is submitted via SBMJOB in the CL. But I'm still unclear on how to get the job end time, and other stats such as CPU time. Isn't it also true that RTVJOBA can only be used to get attributes about the current (interactive) job?
 
RTVJOBA works for any job. I use it in batch programs all the time.

Here's another idea. In your interactive program:

Code:
DSPLOG LOG(QHST) PERIOD((*AVAIL *BEGIN)) +
OUTPUT(*PRTWRAP) JOB(031471/F_LAPEYRE/WO_SBAL_EO) +
MSGID(CPF1124 CPF1164)

That will produce a spool file listing:
Code:
 5722SS1 V5R3M0 040528                                   History Log                                                   Page  0001 
MSGID    SEV MSG TYPE                                                                                                             
CPF1124  00  INFO         Job 031471/F_LAPEYRE/WO_SBAL_EO started on 09/19/06 at 11:07:27 in subsystem QPGMR in QSYS. Job entered 
                          system on 09/19/06 at 11:07:27.                                                                         
                                                                                   X                                              
                      WO_SBAL_EO F_LAPEYRE  031471                   09/19/06 11:07:27.163584 F_LAPEYRE                           
CPF1164  00  COMPLETION   Job 031471/F_LAPEYRE/WO_SBAL_EO ended on 09/19/06 at 11:07:36; 1 seconds used; end code 0               
                                     X.                                                                                           
                      WO_SBAL_EO F_LAPEYRE  031471                   09/19/06 11:07:36.340248 F_LAPEYRE

You have the start and end times (down to the microsecond), and the number of seconds used. You just copy that into a 133-byte PF and parse it.

I'm sure there are APIs that can give you what you want, also.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
I like the idea of parsing the data out of the copied spool file. However, I still don't know how to do this when the submitted job is completed. The menu CL program will submit a program to batch when an option is selected from the menu. If the user exits out of the menu, what is then running on the system that will recognize when the submitted job completes in order to run this final report with job statistics? Maybe it isn't possible to do what I want here....
 
Perhaps the solution is to copy the data to a trigger file.

You then have a trigger problem that is called when a write to this file occurs.

So, the last task that your program performs is to perform the DSPJOB command (as flapeyre stated), but output it to a file that has been defined with a trigger program.

The batch program will end, and OS/400 will perform the rest via the trigger program that you wrote.
 
I actually have another idea that might work. Say in my menu CL program, for option 1 it is doing a submit job for a program named PROG1. Instead of calling PROG1 directly, I can write another program, perhaps called CALLPROG1. The menu CL will call CALLPROG1, and within CALLPROG1, it submits the job for PROG1. After this, it goes into a loop and keeps checking for the PROG1 job to complete. After it completes, it runs the final report to get job statistics and then exits. Any opinions on this and/or suggestions?
 
Another question: after my CALLPROG1 submits the job for PROG1, how do I get the job number and user from within the program? Isn't it true that RTVJOBA only works for the current interactive job? And suppose RTVJOBA does work for submitted jobs, how do I get the job number after the SBMJOB command?
 
Well according to the help for RTVJOBA:

The Retrieve Job Attributes (RTVJOBA) command is used in a CL
program or REXX procedure to retrieve the values of one or more job attributes and place the values into the specified variable. The attributes are retrieved for the job in which this command is used.

So apparently I can't use RTVJOBA to get job attributes for a different job that was submitted and is running on the system. I'm beginning to think that this isn't possible. Didn't think it would be this difficult.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top