API to return status of a completed job?

 1 Replies
 0 Subscribed to this topic
 27 Subscribed to this forum
Sort:
Author
Messages
Roger French
Veteran Member
Posts: 549
Veteran Member

    Is there an existing COBOL API which can return the status of a submitted job? I looked at 900-SUBMIT-JOB and 900-CREATE-AND-SUBMIT-JOB but the status is not one of the returned fields.

     

    Norm
    Veteran Member
    Posts: 40
    Veteran Member
      There is a return code to the 900-CREATE-AND-SUBMIT-JOB API that tells you whether the submission was good or not (WSJR-ERROR), but I suspect you want to know whether the submitted job completed successfully. As far as I know, there's no way to do that using COBOL APIs.

      When we need to submit something and then query the result of the job, we use scripts.

      The wtsubmit command waits until the submitted job has completed, so that's what we use. Basic approach is to use wtsubmit -n so you can get the job number, then use jobstatus to get the result.


      $ wtsubmit -n lawson DUMMY
      The Submitted Job's Number Is 0000003853

      $ jobstatus 3853
      The status of 0000003853 is Normal Completion

      Testing the result of the jobstatus command gives you the information you need. You could use this from within a COBOL program by generating a call to a script and interrogating the results by return codes.