The List Job (QUSLJOB) API will list jobs for a specific job number in a user space. An simple example of calling the API:
CALL PGM( QSYS/QUSLJOB ) PARM('LSTAJOBNBRMYLIB '
'*ALL *ALL 321654'
That will place the list into a user space named MYLIB/LSTAJOBNBR. (The user space must be created first.) The format of the list entries will be JOBL0100 which is only the basic information for each list entry. The example qualified job name is 321654/*ALL/*ALL (most likely only a single job will be listed.) And the example asks only for *ACTIVE jobs.
Naturally, those values would probably be in variables rather than literals.
Comparison against the API documentation should illuminate how to request other kinds of lists. Instead of ‘*ACTIVE ‘, you might want to specify ‘*ALL ‘ in order to list all jobs with that job number, regardless of status. That is, you might not know if your particular job number is active or if it’s finished and has output on an *OUTQ.
For a specific job number, you would normally get zero or one list entry. It’s possible to get more than one if your job numbers have wrapped.
Of course, this API isn’t much use without the Create User Space (QUSCRTUS), Retrieve User Space (QUSRTVUS) (or better, Retrieve Pointer to User Space (QUSPTRUS)) and Delete User Space (QUSDLTUS) APIs. When learning about user spaces, you probably should also become familiar with the DMPOBJ command because you’re likely to do a lot of byte counting the first couple times.
Also, you’ll need to check the QALWUSRDMN system value to verify that you can create a user space in the library of your choice. That includes QTEMP.