|
Thanks to everyone for all the replies!!!
----- Original Message -----
From: "Scott Klement" <klemscot@klements.com>
To: <rpg400-l@midrange.com>
Sent: Tuesday, September 10, 2002 5:53 PM
Subject: Re: Retrieve Job Number Within RPG
>
>
> On Tue, 10 Sep 2002, JJW wrote:
> >
> > Hello *ALL
> >
>
> Hello *REQUESTER
>
> > If I have an RPG-ILE program called ABC running in batch
> > and it uses the SBMJOB command from within ABC to submit
> > an RPG-ILE program called XYZ how can I determine what the
> > job number of XYZ is? I'm running on V5R1 if it matters.
> >
>
> It returns a CPC1221 message, the job info is in the first 26 bytes.
> Here's a utility that I use for this, it submits a job and then returns
> the job number:
>
> H DFTACTGRP(*NO) ACTGRP(*NEW)
>
> D util_submit PR 10I 0
> D peName 10A const varying
> D peJobQ 10A const varying
> D peCmd 400A const varying
> D peSbmName 10A options(*nopass)
> D peSbmUser 10A options(*nopass)
> D peSbmNo 6A options(*nopass)
>
> D msg s 52A
> D Job s 10A
> D User s 10A
> D Number s 6A
>
> c if util_submit('MESSAGE': 'QSYSNOMAX':
> c 'SNDMSG MSG(''Hello World!'') ' +
> c 'TOUSR(KLEMSCOT)':
> c Job: User: Number) < 0
> c eval msg = 'failed!'
> c dsply msg
> c endif
>
> c eval msg = 'Job = ' +
> c %trim(Number) + '/' +
> c %trim(User) + '/' +
> c %trim(Job)
> c dsply msg
>
> c eval *inlr = *on
>
>
> *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> * util_submit: Submit a job to a job queue
> *
> * peName = name of job to submit
> * peJobQ = Queue to submit to
> * peCmd = Command to submit
> * peSbmName = name returned by the submit job command
> * peSbmUser = user returned by the submit job command
> * peSbmNo = job number returned by the submit job command
> *
> * Returns 0 if successful, or -1 if it failed
> *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> P util_submit B export
> D util_submit PI 10I 0
> D peName 10A const varying
> D peJobQ 10A const varying
> D peCmd 400A const varying
> D peSbmName 10A options(*nopass)
> D peSbmUser 10A options(*nopass)
> D peSbmNo 6A options(*nopass)
>
> D QCMDEXC PR ExtPgm('QCMDEXC')
> D peCommand 500A const
> D peLength 15P 5 const
>
> D QMHRCVPM PR ExtPgm('QMHRCVPM')
> D MsgInfo 32766A 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 32766A options(*varsize)
>
> D dsM1 DS
> D dsM1_BytRtn 10I 0
> D dsM1_BytAvl 10I 0
> D dsM1_MsgSev 10I 0
> D dsM1_MsgID 7A
> D dsM1_MsgType 2A
> D dsM1_MsgKey 4A
> D dsM1_Reserv1 7A
> D dsM1_CCSID_st 10I 0
> D dsM1_CCSID 10I 0
> D dsM1_DtaLen 10I 0
> D dsM1_DtaAvl 10I 0
> D dsM1_Dta 256A
>
> D dsEC DS
> D dsECBytesP 1 4I 0 INZ(%size(dsEC))
> D dsECBytesA 5 8I 0 INZ(0)
> D dsECMsgID 9 15
> D dsECReserv 16 16
> D dsECMsgDta 17 256
>
> D wwMsgKey S 4A
> D wwJobNo S 26A
>
> C*******************************************
> C* Submit the job
> C*******************************************
> c callp(e) QCMDEXC('SBMJOB CMD(' + peCmd + ') ' +
> c 'JOBQ(' + peJobQ +') ' +
> c 'JOB(' + peName+ ')':
500)
> c if %error
> c return -1
> c endif
>
> C*******************************************
> C* Look for a success message
> C*******************************************
> c eval wwMsgKey = *ALLx'00'
> c dou dsECBytesA>0 or dsM1_MsgID='CPC1221'
> c callp QMHRCVPM(dsM1: %size(dsM1): 'RCVM0100':
> c '*': 0: '*PRV': wwMsgKey: 0:
'*SAME':
> c dsEC)
> c eval wwMsgKey = dsM1_MsgKey
> c enddo
>
> c if dsECBytesA>0
> c return -1
> c endif
>
> C*******************************************
> C* Grab the job info from the response
> C*******************************************
> c if dsM1_DtaAvl >= 26
> c eval wwJobNo = %subst(dsM1_Dta:1:26)
> c else
> c eval wwJobNo = *blanks
> c endif
>
> c if %parms >= 4
> c eval peSbmName = %subst(wwJobNo:1:10)
> c endif
> c if %parms >= 5
> c eval peSbmUser = %subst(wwJobNo:11:10)
> c endif
> c if %parms >= 6
> c eval peSbmNo = %subst(wwJobNo:21:6)
> c endif
>
> c return 0
> P E
>
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
> or email: RPG400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
>
>
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.