| 
 | 
Thanks Scott. As always, you have provied me with the tools I need. Also thanks to everyone who suggested the QMHRCVPM API. Jeff Young Sr. Programmer Analyst Dynax Solutions, Inc. A wholly owned subsidiary of enherent Corp. IBM -e(logo) server Certified Systems Exper - iSeries Technical Solutions V5R2 IBM Certified Specialist- e(logo) server i5Series Technical Solutions Designer V5R3 IBM Certified Specialist- e(logo)server i5Series Technical Solutions Implementer V5R3 ----- Original Message ---- From: Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> Sent: Tuesday, January 2, 2007 2:40:11 PM Subject: Re: Retreive job number for SBMJOB Hello,
Using either the _system function, or QCMDEXC to issue a SBMJOB command from an RPGLE program, can I retreive the job number of the submitted job? If so, what do I need to do?
I agree with David. After the SBMJOB command is processed, it'll send you 
a CPC1221 completion message. If you retrieve it with the QMHRCVPM API, 
the first 26 bytes of the message data should contain the job identifier.
Here's a quick example, if it saves you some time:
      H DFTACTGRP(*NO)
      D QCMDEXC         PR                  ExtPgm('QCMDEXC')
      D   command                  32702a   const options(*varsize)
      D   length                      15p 5 const
      D   igc                          3a   const options(*nopass)
      D QMHRCVPM        PR                  ExtPgm('QMHRCVPM')
      D   MsgInfo                  32767A   options(*varsize)
      D   MsgInfoLen                  10I 0 const
      D   Format                       8A   const
      D   StackEntry                  10A   const
      D   StackCount                  10I 0 const
      D   MsgType                     10A   const
      D   MsgKey                       4A   const
      D   WaitTime                    10I 0 const
      D   MsgAction                   10A   const
      D   ErrorCode                32767A   options(*varsize)
      D Msg             DS                  qualified
      D  BytesRtn                     10I 0
      D  BytesAvail                   10I 0
      D  Severity                     10I 0
      D  Id                            7A
      D  Type                          2A
      D  Key                           4A
      D                                7A
      D  CCSID_ind                    10I 0
      D  CCSID                        10I 0
      D  Len                          10I 0
      D  Avail                        10I 0
      D  Data                       1024A
      D ErrorNull       ds                  qualified
      D    BytesProv                  10i 0 inz(0)
      D    BytesAvail                 10i 0 inz(0)
      D cmd             s            500A   varying
      D JobName         s             10a
      D JobUser         s             10a
      D JobNbr          s              6a
      D wait            s              1a
       /free
             cmd = 'SBMJOB CMD(CALL SOMEPGM)';
             QCMDEXC(cmd: %len(cmd));
             QMHRCVPM( Msg
                     : %size(Msg)
                     : 'RCVM0100'
                     : '*'
                     : 0
                     : '*LAST'
                     : *blanks
                     : 0
                     : '*SAME'
                     : ErrorNull );
             if (Msg.Id<>'CPC1221' or Msg.Avail<26);
                // TODO: Report error message properly instead of DSPLY
                //       (This isn't supposed to happen!)
                dsply 'HELP!' '' wait;
                return;
             endif;
             JobName = %subst(Msg.Data: 1: 10);
             JobUser = %subst(Msg.Data:11: 10);
             JobNbr  = %subst(Msg.Data:21:  6);
             // TODO: Do whatever needs to be done with these fields,
             //       instead of just displaying them...
             dsply ('job ' +JobName+ ' User ' +JobUser+ ' Nbr ' +jobNbr)
                   '' wait;
             *inlr = *on;
       /end-free
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.