You can’t. In order to retrieve any information about a job you have to already know the job number and user name. Both of those APIs you mentioned have to have the qualified job name passed to them in order to retrieve any information about a job.
One way to get this information, though, is to execute a WRKACTJOB to print, copy the spooled file to a work file, and then parse the work file looking for the job name. However, this will only work if the job name is unique.
Here are the specifics of the QUSLJOB API.
In the job name section of the the qualified job name, it appears that you could provide the name of the job you’re looking for, and specify *ALL for the user name and job number components. Or, if you are looking for a job name and a specific user name, you should be able to provide those two, and specify *ALL for the job number component. All of the matching jobs would be written to a user space, which you could access (via another API) to find the job(s) that you’re looking for and proceed accordingly with what you want to do.
<b>Qualified job name </b>
The name of the job to be included in the list. The qualified job name has three parts:
Job name CHAR(10). A specific job name, a generic name, or one of the following special values:
* Only the job that this program is running in. The rest of the qualified job name parameter must be blank.
*CURRENT All jobs with the current job’s name.
*ALL All jobs. The rest of the job name parameter must be specified.
User name CHAR(10). A specific user profile name, a generic name, or one of the following special values:
*CURRENT Jobs with the current job’s user profile.
*ALL Jobs with the specified job name, regardless of the user name. The rest of the job name parameter must be specified.
Job number CHAR(6). A specific job number or the following special value:
*ALL Jobs with the specified job name and user name, regardless of the job number. The rest of the job name parameter must be specified.</i>
Since this API requires a user space, you could create some modular service programs to manage working with a user space, so that you could re-use them with other APIs.
The Retrieve Job Information (QUSRJOBI) API does require a fully-qualified job name, but the List Job (QUSLJOB) API only needs job-name. It doesn’t need user-name nor job-number.
It will return a list of all jobs that have the specified job-name. The list will be in a user space.