Sie sind auf Seite 1von 7

*=================================================== * PROGRAM * PURPOSE * WRITTEN * AUTHOR * * PROGRAM DESCRIPTION * * * * INPUT PARAMETERS * Description Type Size How Used * --------------

----------* * INDICATOR USAGE * *=================================================== * * Program Info * d SDS d @PGM 1 10 d @PARMS 37 39 0 d @JOB 244 253 d @USER 254 263 d @JOB# 264 269 0 * * Field Definitions. * d AllText s 10 Inz('*ALL') d bOvr s 1a inz('0') d CmdString s 256 d CmdLength s 15 5 d Count s 4 0 d CRLF c CONST(X'0d25') d CYMD s 7 0 d emailaddress s 50 inz('helpdesk@xxxxxxxxx.com') d Fmt s 8a inz('MBRD0200') d fnd s 4 0 d Format s 8 d GenLen s 8 d heldjobq s 10 dim(100) d heldjobqst s z dim(100) d hj# s 3 0 d Howmany s 8 0 d InLibrary s 10 d InObject s 10 d InType s 10 d ISoDate s D d jj# s 3 0 d jobqlibrary s 20 d jobqjobs s 10 dim(100) d jobqjobsst s z dim(100) d Low c CONST('abcdefghijklmnopqrstuvwxyz') d memberName s 10 inz('*FIRST') d message s 512 varying d ObjectLib s 20 d OS400_Cmd s 2000 inz d OutNumber s 10 d P1deleted s 8 0

d d d d d d d d d d d d d d d d d d d d d * *

P1created P1changed P1desc P1Records Q SpaceVal SpaceAuth SpaceText SpaceRepl SpaceAttr subject subsystem subsystemStamp sb# Up USA UserSpaceOut * GenHdr * GenHdr OffSet NumEnt Lstsiz

s s s s s s s s s s s s s s c s s

8 0 8 0 50 8 0 1 inz('''') 1 inz(*BLANKS) 10 inz('*CHANGE') 50 inz(*BLANKS) 10 inz('*YES') 10 inz(*BLANKS) 44 varying 10 dim(999) z dim(999) 3 0 CONST('ABCDEFGHIJKLMNOPQRSTUVWXYZ') 8 0 20

ds 1 9 13 4B 0 12B 0 16B 0

inz

* Data structures * d GENDS ds d OffsetHdr 1 4B d NbrInList 9 12B d SizeEntry 13 16B * * d HeaderDs ds d OutFileNam 1 10 d OutLibName 11 20 d OutType 21 25 d OutFormat 31 40 d RecordLen 10i * * API Error Data Structure * d ErrorDs DS d BytesPrv 1 4B d BytesAvl 5 8B d MessageId 9 15 d ERR### 16 16 d MessageDta 17 116 * * Create userspace datastructure * d DS d StartPosit 1 4B d StartLen 5 8B

0 0 0

INZ 0 0

0 0

d d d d d

SpaceLen ReceiveLen MessageKey MsgDtaLen MsgQueNbr

9 13 17 21 25

12B 16B 20B 24B 28B

0 0 0 0 0

* * Date structure for retriving userspace info * d InputDs DS d UserSpace 1 20 d SpaceName 1 10 d SpaceLib 11 20 d InpFileLib 29 48 d InpFFilNam 29 38 d InpFFilLib 39 48 d InpRcdFmt 49 58 * d ObjectDs ds d Object 10 d Library 10 d ObjectType 10 d InfoStatus 1 d ExtObjAttrib 10 d Description 50 d qcmdexc d os400_cmd d cmdlength d d d d d d $getjobq RECIEVER RCVRLEN FORMAT JOBQ ERROR pr extpgm( 'QCMDEXC' ) 2000A options( *varsize ) const 15P 5 const extpgm('QSPRJOBQ') 144A 10I 0 const 8A const 20A conST 116A 10i 10i 10 10 10 10 10i 10 10 10 50 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 0 0

pr

* DQSPQ020000 DS D BytesReturned D BytesAvailable D QueueName D QueueLib D Controlled D Authority D NumberJobs D Status D SubsystemName D SubsystemLib D SBSDescription D Sequence# D MaxActive D CurrentActive D MaxActiveP1 D MaxActiveP2 D MaxActiveP3 D MaxActiveP4 D MaxActiveP5 D MaxActiveP6 D MaxActiveP7 D MaxActiveP8 D MaxActiveP9

0 0 0 0 0 0 0 0 0 0 0 0

D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D

ActiveJobsP0 ActiveJobsP1 ActiveJobsP2 ActiveJobsP3 ActiveJobsP4 ActiveJobsP5 ActiveJobsP6 ActiveJobsP7 ActiveJobsP8 ActiveJobsP9 ReleaseJobs0 ReleaseJobs1 ReleaseJobs2 ReleaseJobs3 ReleaseJobs4 ReleaseJobs5 ReleaseJobs6 ReleaseJobs7 ReleaseJobs8 ReleaseJobs9 ScheduledJobs0 ScheduledJobs1 ScheduledJobs2 ScheduledJobs3 ScheduledJobs4 ScheduledJobs5 ScheduledJobs6 ScheduledJobs7 ScheduledJobs8 ScheduledJobs9 HeldJobs0 HeldJobs1 HeldJobs2 HeldJobs3 HeldJobs4 HeldJobs5 HeldJobs6 HeldJobs7 HeldJobs8 HeldJobs9 DS 1 5 9 16

10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i 10i

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

* dQUSEC d QUSBPRV d QUSBAVL d QUSEI d QUSERVED

4B 0 8B 0 15 16

d QUSED01 100A * * Standard API error data structure * d apierror ds inz d AEBYPR 1 4B 0 d AEBYAV 5 8B 0 d AEEXID 9 15 d AEEXDT 16 116 * * Create a userspace * c exsr $QUSCRTUS

B1

* * List all the objects to the user space * c eval Format = 'OBJL0200' c eval objectlib = InObject + InLibrary * c call(e) 'QUSLOBJ' c parm Userspace UserSpaceOut c parm Format c parm ObjectLib c parm InType * * Retrive header entry and process the user space * c eval StartPosit = 125 c eval StartLen = 16 * * Retrive header entry and process the user space * c call 'QUSRTVUS' c parm UserSpace UserSpaceOut c parm StartPosit c parm StartLen c parm GENDS * c eval StartPosit = OffsetHdr + 1 c eval StartLen = %size(ObjectDS) * * Do for number of fields * c z-add NbrInList HowMany c do NbrInList * * c call(e) 'QUSRTVUS' c parm UserSpace UserSpaceOut c parm StartPosit c parm StartLen c parm ObjectDs * * Object = the jobq Name - get jobq information * /Free jobqlibrary = Object + 'QGPL'; $GetJobQ(QSPQ020000:%SIZE(QSPQ020000):'JOBQ0200': jobqlibrary:apierror); // send email if any jobq in QGPL is held. // wait 15 minutes to send again if Status = 'HELD'; // see if message already sent fnd = %lookup(object : heldjobq); if fnd = *zeros or %diff(%timestamp(): heldjobqst(fnd):*minutes) >= 15; if fnd = *zeros; hj# +=1; heldjobq(hj#) = object;

heldjobqst(hj#) = %timestamp(); else; heldjobqst(fnd) = %timestamp(); endif; subject = 'JobQ ' + %trim(object) + ' is HELD ' + %char(%time()); message = 'Please logon to system and release this JobQ' + ' currently there are ' + %char(ReleaseJobs5) + ' job(s) on the queue.'; exsr $snddst; endif; endif; // send email if more than 5 jobs in jobQ. // wait 15 minutes to send again // see if message already sent fnd = %lookup(object : jobqjobs); if releaseJobs5 >= 5; if fnd = *zeros or %diff(%timestamp(): jobqjobsst(fnd):*minutes) >= 15; if fnd = *zeros; jj# +=1; jobqjobs(jj#) = object; jobqjobsst(jj#) = %timestamp(); else; jobqjobsst(fnd) = %timestamp(); endif; subject = 'More than Allowed Jobs in jobq ' + %trim(object); message = 'Please logon to system and check subsystem ' + %trim(SubsystemName) + ' currently there are ' + %char(ReleaseJobs5) + ' job(s) on the queue. ' + CRLF + %char(%timestamp); exsr $snddst; endif; endif; /end-free * c c eval enddo StartPosit = StartPosit + SizeEntry * * leave open so we can keep track of last email sent * c return *=============================================== * $QUSCRTUS - API to create user space *=============================================== c $QUSCRTUS begsr * * Create a user space named ListObjects in QTEMP. * c Eval BytesPrv = 116 c movel(p) 'LISTOBJECTS' SpaceName c movel(p) 'QTEMP' SpaceLib * * Create the user space

* c c c c c c c c c * c /free //-------------------------------------------------------// $snddst - send email to helpdesk //-------------------------------------------------------begsr $snddst; // Send email to address os400_cmd = 'snddst type(*lmsg) ' + 'tointnet((' + Q + %trim(EmailAddress) + Q + ')) dstd(' + Q + %trim(subject) + Q + ') longmsg(' + Q + %trim(message) + Q + ')'; qcmdexc ( os400_cmd : %size ( os400_cmd ) ); endsr call(e) parm parm parm parm parm parm parm parm 'QUSCRTUS' UserSpace 4096 UserSpaceOut SpaceAttr SpaceLen SpaceVal SpaceAuth SpaceText SpaceRepl ErrorDs

endsr; //-------------------------------------------------------/end-free *================================================= * *Inzsr - One time run House keeping subroutine *================================================= c *Inzsr begsr * c eval InObject = '*ALL' c eval InLibrary = 'QGPL' c eval InType = '*JOBQ' c endsr *==============================================