× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




I submit a job from RPG program named A.

I would like to retrieve the job number, status of the job submitted from RPG program named A and record in a file.

How will I do that. Is there any API.

When you submit a job, a message is placed into your job log that contains the identifier of the job that you just submitted. You can use the Receive Program Message (QMHRCVPM) API to receive that message from the job log, and you can get the job information from the replacement data in that message.

For example:

     D QCMDEXC         PR                  extpgm('QCMDEXC')
     D   command                  32702A   const options(*Varsize)
     D   len                         15P 5 const
     D   igc                          3A   const options(*nopass)

     D QMHRCVPM        PR                  extpgm('QMHRCVPM')
     D   RcvVar                   32767A   options(*varsize)
     D   RcvVarLen                   10I 0 const
     D   Format                       8A   const
     D   StackEnt                    10A   const
     D   StackCount                  10I 0 const
     D   MsgType                     10A   const
     D   MsgKey                       4A   const
     D   WaitTime                    10I 0 const
     D   Action                      10A   const
     D   ErrorCode                32767A   options(*varsize)

     D ErrorCode       ds                  qualified
     D    BytesProv                  10I 0 inz(0)
     D    BytesAvail                 10I 0 inz(0)

     D RCVM0100        ds                  qualified
     D   BytesRtn                    10I 0
     D   BytesAvail                  10I 0
     D   MsgSev                      10I 0
     D   MsgID                        7A
     D   MsgType                      2A
     D   MsgKey                       4A
     D                                7A
     D   conv_ind                    10I 0
     D   CCSID                       10I 0
     D   DtaLen                      10I 0
     D   DtaLenAvail                 10I 0
     D   MsgDta                   32719A

     D Job             ds                  qualified
     D   Name                        10A
     D   User                        10A
     D   Nbr                          6A

     D cmd             s           2000A   varying
     D wait            s              1A

      /free

          // submit a simple job for the sake of demonstration:

          cmd = 'SBMJOB CMD(SNDMSG MSG(''TEST'') TOUSR(KLEMSCOT)) '
                    + ' JOB(SNDMSG) JOBQ(QS36EVOKE)';
          QCMDEXC(cmd: %len(cmd));

          // retrieve the last message from the job log

          QMHRCVPM( RCVM0100: %size(RCVM0100): 'RCVM0100': '*': 0
                  : '*LAST': *blanks: -1: '*OLD': ErrorCode);

          // a CPC1221 should be in the job log and should tell
          // us the job information:

          if RCVM0100.MsgID = 'CPC1221';

             Job = RCVM0100.MsgDta;

             dsply Job.Name;
             dsply Job.User;
             dsply Job.Nbr '' wait;
          endif;

          *inlr = *on;
      /end-free

In a production program, you wouldn't want to DSPLY the job info, instead you'd want to write it to your file... But I assume you can figure that part of it out.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.