Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
* d QUSRTVUS d d d d d d d d d d QRtvError... 256 * --- Prototype for API Retrive List Job * d QUSLJOB d pr extpgm( 'QUSLJOB' ) QRtvReceiverVariable... 32048 QRtvLengthOfData... 10i 0 QRtvStartingPosition... 10i 0 pr extpgm( 'QUSRTVUS' ) UsrSpc ExtAttr InitialSize InitialVal PublicAuth Text Replace ErrorCode pr 20A 10A extpgm('QUSCRTUS') const const
10I 0 const 1A 10A 50A 10A 32766A const const const const options(*nopass: *varsize)
QRtvUserSpace... 20
QJobUserSpace...
d d d d d d d d d d d d d d d * d qcmdexc d d * * Defined variables * d emailaddress d size d UsrSpcName * s s s os400_cmd cmdlength pr QKeyFldRtn... QNbrFldRtn... QJobType... QFldError... QFldStatus... QJobJobName... QJobFormatName...
20
26
10
256
10i 0
24 10I 0 20
inz('alert@abcdomain.com')
inz( 'DSPJOB
QTEMP
' )
ds
qualified
10
11
20
21
26
27
36
37
46
d UserName... d d JobNumber... d d InternalJobId... d d Status... d d JobType... d d JobSubType... d d Reserved01... d * dLJOB200 d JobName... d d UserName... d d JobNumber... d d InternalJobId... d d Status... d d JobType... d d JobSubType... d 54 54 53 53 43 52 27 42 21 26 11 20 1 10 ds qualified 55 56 54 54 53 53 43 52 27 42 21 26 11 20
d NumberOfFieldsReturned... d d ReturnedData... d * dLJOB200KEY d KeyNumber01... d***** d d NumberOfKeys... d***** d * dLJOBKEYINFO ds qualified 5 8B 0 10i 0 1 4B 0 10i 0 ds qualified 65 1064 61 64B 0
d APIErrorProvied... d d d APIErrorAvailble... d d APIErrorMessageID... d d APIErrorReserved... d d APIErrorInformation... d 240A *----------------------------------------------------------------* program status dataarea *----------------------------------------------------------------LIKE( ErrorReserved ) LIKE( ErrorExceptionId ) LIKE( ErrorBytesAvailble ) LIKE( ErrorBytesProvided ) INZ( %LEN( APIError ) )
*--------------------------------------------------------------* d Variables d d d d d d d d d d d d d d d d d d d d d d d ReceiverVariable... KeyLengthOfData... 8B 0 inz KeyStartingPosition... 8B 0 inz LengthOfData... 10i 0 inz JobStatus JobType NbrOfFldRtn KeyFldRtn StartingPosition... 10i 0 inz Q Count KeyCount EndPos JobbStatus Subsystem ReturnCode FormatName QualifedJobName... 26 10 1 inz inz inz ds 1 inz('''')
size = 10000; QUSCRTUS(UsrSpcName: 'USRSPC': size: x'00': '*ALL': 'Temp User Space for QUSLJOB API': '*YES': APIError); exsr CheckStatusOfJob;
*inlr = *on;
begsr CheckStatusOfJob;
// run API to fill user space with information about all iSeries job FormatName = 'JOBL0200'; QualifedJobName = '*ALL JobStatus = '*ACTIVE'; JobType = '*'; NbrOfFldRtn = 2; KeyFldRtn( 1 ) = 0101; KeyFldRtn( 2 ) = 1906; QUSLJOB( UsrSpcName : FormatName : QualifedJobName : ' + '*ALL ' + '*ALL ';
: );
: NbrOfFldRtn : KeyFldRtn
// if error message from the retrieve job API then dump program if APIErrorMessageID <> ' '; dump; ReturnCode = True; leavesr; endif; // run API to get user space attribute StartingPosition = 125; LengthOfData = 16; callp QUSRTVUS( UsrSpcName : StartingPosition :
LengthOfData : ReceiverVariable : APIError QUSA0100 = ReceiverVariable; // error message from the retrieve user space API then dump program if APIErrorMessageID <> ' '; dump; ReturnCode = True; leavesr; endif; );
// preperation to read from user space StartingPosition = QUsrSpcOffset + 1; LengthOfData = QUsrSpcEntrieSize; // read from user space for count = 1 to QUsrSpcEntries; QUSRTVUS( UsrSpcName : StartingPosition :
LJOB200 = ReceiverVariable; if APIErrorMessageID <> ' '; dump; ReturnCode = True; leavesr; endif;
// check status of job JobbStatus = ' '; Subsystem = ' '; LJobKeyInfo = LJob200.ReturnedData; KeyStartingPosition = 1; KeyLengthOfData = LJobKeyInfo.LengthOfInformation;
KeyLengthOfData = LJobKeyInfo.LengthOfInformation;
KeyStartingPosition = KeyStartingPosition + KeyLengthOfData; endfor; // job in message wait then email message to address in // variable email address if Jobbstatus = 'MSGW'; Subsystem = %trim( %subst( Subsystem : 11 : 10 ) ) + '/' + %trim( %subst( Subsystem : 1 : 10 ) ); os400_cmd = 'snddst type(*lmsg) ' + 'tointnet((' + Q + %trim(EmailAddress) + Q + ')) dstd(' + Q 'Job is in *MSGW' + +
Q + ') longmsg(' + Q + 'Job (' + %trim( LJob200.JobName ) + '/' + %trim( LJob200.UserName ) + '/' + %trim( LJob200.JobNumber ) + ') subsystem ' + %trim( Subsystem ) + ' in status *MSGW' + Q + ')'; monitor; // qcmdexc ( os400_cmd : %size ( os400_cmd ) ); on-error; dump; endmon; endif;
endfor;
endsr; /end-free