Topic
  • 5 replies
  • Latest Post - ‏2014-07-11T01:28:34Z by tomliotta
Damery
Damery
71 Posts

Pinned topic API to get subsystem name of active job

‏2014-07-09T14:50:15Z |

If I have JOBA running under 2 subsystems SUBSYS1 and SUBSYS2, how can I use an API to make sure JOBA is running under SUBSYS2 so that I can restart it if it is NOT?

I had been using QUSLJOB to find JOBA but it doesn't tell me which subsystem it is running under. I don't want to restart JOBA under SUBSYS1 just JOBA under SUBSYS2.

Any ideas?

  • barbara_morris
    barbara_morris
    450 Posts
    ACCEPTED ANSWER

    Re: API to get subsystem name of active job

    ‏2014-07-09T15:22:39Z  

    According to the documentation for QUSLJOB http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qusljob.htm?lang=en, you should be able to get the subsystem name. In the "Valid Keys" section, it says that key 1906 is for "Subsystem description name - qualified".

    It points to "Work Management API Attribute Descriptions (WMAttrDesc)" http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/WMAttrDesc.htm?lang=en for the descriptions of the keys

    "Subsystem description name - qualified. The qualified name of the subsystem in which an active job is running. The format of the qualified name is a 10-character simple object name followed by a 10-character library name. This value is only for jobs whose status is *ACTIVE. For jobs with status of *OUTQ or *JOBQ, the value for this field is blank."

    Or you could call QUSRJOBI to get the subsystem name of a particular job from the QUSLJOB list.

  • barbara_morris
    barbara_morris
    450 Posts

    Re: API to get subsystem name of active job

    ‏2014-07-09T15:22:39Z  

    According to the documentation for QUSLJOB http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qusljob.htm?lang=en, you should be able to get the subsystem name. In the "Valid Keys" section, it says that key 1906 is for "Subsystem description name - qualified".

    It points to "Work Management API Attribute Descriptions (WMAttrDesc)" http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/WMAttrDesc.htm?lang=en for the descriptions of the keys

    "Subsystem description name - qualified. The qualified name of the subsystem in which an active job is running. The format of the qualified name is a 10-character simple object name followed by a 10-character library name. This value is only for jobs whose status is *ACTIVE. For jobs with status of *OUTQ or *JOBQ, the value for this field is blank."

    Or you could call QUSRJOBI to get the subsystem name of a particular job from the QUSLJOB list.

  • Damery
    Damery
    71 Posts

    Re: API to get subsystem name of active job

    ‏2014-07-09T20:56:35Z  

    According to the documentation for QUSLJOB http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qusljob.htm?lang=en, you should be able to get the subsystem name. In the "Valid Keys" section, it says that key 1906 is for "Subsystem description name - qualified".

    It points to "Work Management API Attribute Descriptions (WMAttrDesc)" http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/WMAttrDesc.htm?lang=en for the descriptions of the keys

    "Subsystem description name - qualified. The qualified name of the subsystem in which an active job is running. The format of the qualified name is a 10-character simple object name followed by a 10-character library name. This value is only for jobs whose status is *ACTIVE. For jobs with status of *OUTQ or *JOBQ, the value for this field is blank."

    Or you could call QUSRJOBI to get the subsystem name of a particular job from the QUSLJOB list.

    I see it can be done but Whoa a few more hoops.

    too bad the API's don't return an XML document of values like a result set so you don't have to create various data structures to catch the returning data. 

    Just call your API getJobSystemInfo(Result.Xml)

    where

    <RESULT>

    <SUBSYSTEM_DESCRIPTION_NAME>SUBSYS2</SUBSYSTEM_DESCRIPTION_NAME>

    </RESULT>

    Just saying....

  • tomliotta
    tomliotta
    29 Posts

    Re: API to get subsystem name of active job

    ‏2014-07-10T11:25:39Z  

    Something isn't quite clear. If jobs are running and need to be restarted, it generally means they need to be ended and resubmitted. In order to submit a job to run in a particular subsystem, you should be more concerned about how the job is routed.

    And that usually means that you need to know the job queue rather than the subsystem since submitted jobs will go to whatever subsystem is servicing that queue. You don't submit jobs to a subsystem.

    So, won't it be easier to retrieve the job queue that the job entered the system through? In that case, all you should need is format JOBI0300 for the QUSRJOBI API.

    Tom

  • Damery
    Damery
    71 Posts

    Re: API to get subsystem name of active job

    ‏2014-07-10T20:56:18Z  
    • tomliotta
    • ‏2014-07-10T11:25:39Z

    Something isn't quite clear. If jobs are running and need to be restarted, it generally means they need to be ended and resubmitted. In order to submit a job to run in a particular subsystem, you should be more concerned about how the job is routed.

    And that usually means that you need to know the job queue rather than the subsystem since submitted jobs will go to whatever subsystem is servicing that queue. You don't submit jobs to a subsystem.

    So, won't it be easier to retrieve the job queue that the job entered the system through? In that case, all you should need is format JOBI0300 for the QUSRJOBI API.

    Tom

    I have a list of JobNames that can run in Multiple JobQ's/Subsystem's.

    I wanted to create a program to start the list of jobs in the JobQ if they are not already active.

    and then a program to shut the list of jobs down in a particular JobQ /Subsystem if active.

    I wanted to only run each job once in each jobq, no duplicates per jobq. But I could have a duplicate job in another jobq.

    If an error were to shut down one of the jobs in a set then I wanted to be able to start that one job and skip the jobs that are already running in that jobq/subsystem.

  • tomliotta
    tomliotta
    29 Posts

    Re: API to get subsystem name of active job

    ‏2014-07-11T01:28:34Z  
    • Damery
    • ‏2014-07-10T20:56:18Z

    I have a list of JobNames that can run in Multiple JobQ's/Subsystem's.

    I wanted to create a program to start the list of jobs in the JobQ if they are not already active.

    and then a program to shut the list of jobs down in a particular JobQ /Subsystem if active.

    I wanted to only run each job once in each jobq, no duplicates per jobq. But I could have a duplicate job in another jobq.

    If an error were to shut down one of the jobs in a set then I wanted to be able to start that one job and skip the jobs that are already running in that jobq/subsystem.

    Submitted jobs have a message queue (by default) that receives messages about the job's completion. The SBMJOB MSGQ() parameter names the message queue where completion status messages should be sent.

    Create a message queue for these jobs and specify that message queue name on your SBMJOB commands. When a CPF1240 *COMP message arrives that indicates one of the jobs ended abnormally, use either the message sender info or the message data to get the qualified job name. Use the qualified job name to pass to the QUSRJOBI API to retrieve format JOBI0300 for the job queue.

    With the job name and job queue name, you can run SBMJOB again. Of course, you can also send notices that job failures occurred if someone should be notified.

    If you want to do it manually, you can use DSPJOB with parameter OPTION(*DFNA) to see the job's job queue name.

    If the job has ended, it's no longer associated with any subsystem. Trying to determine which subsystem the job was in when it failed can be very tricky, much more than finding its job queue. A system can change, and a job queue and subsystem might not be associated the same way by the time a job status is retrieved. It'd be very difficult for the system to keep track of all of its jobs for that level of detail. It's usually possible to rebuild the routing path to determine 'Subsystem', but sticking with job queue is almost always best.

    ...then a program to shut the list of jobs down in a particular JobQ /Subsystem if active.

    That's a separate problem. Is it simply running ENDJOB against each job in named subsystems?

    Tom