Friday, May 01, 2009

QUSRJOBI API (Retrieve Job Information) as400

The Retrieve Job Information (QUSRJOBI) API as400 retrieves specific information about a as400 job

Heres an example from the "Big Dummy's Guide to the As400" that using QUSRJOBI API to determine if the current job is interactive or batch

* 
*-------------------------------------------------------- 
fSOMEDSP   cf   e             workstn 
* 
* Variable Definition 
* 
d Format          s              8 
d RcvVarLen       s             10i 0 

d dsJobDta        ds 
d  dsJobBytesRtn                10I 0 
d  dsJobBytesAvl                10I 0 
d  dsJobName                    10A 
d  dsJobUser                    10A 
d  dsJobNumber                   6A 
d  dsJobIntern                  16A 
d  dsJobStatus                  10A 
d  dsJobType                     1A 
d  dsJobSubtype                  1A 
d  dsJobReserv1                  2A 
d  dsJobRunPty                  10I 0 
d  dsJobTimeSlc                 10I 0 
d  dsJobDftWait                 10I 0 
d  dsJobPurge                   10A 

// 
//  external as400 calls 
// 

d $jobinfo        pr                  extpgm('QUSRJOBI') 
d   DsJob                             like(DsJobDta) 
d   Length                      10i 0 const 
d   APIFormat                    8    const 
d   ApiJob                      26    const 
d   InternJob                   16    const 


/Free 

//-------------------------------------------------------- 
// MAIN PROGRAM 
//-------------------------------------------------------- 

exsr  Hskpg; 


*inlr = *on; 

//-------------------------------------------------------- 
// Hskpg - one time run subroutine 
//-------------------------------------------------------- 

begsr Hskpg; 


// determine if this as400 job is interactive or batch 

RcvVarLen = %Size(DsJobDta); 
Format = 'JOBI0100'; 

$jobinfo(dsjobdta : rcvvarlen : Format : '*' : ' '); 

if DSJOBTYPE = 'I'; 
if not%open(SOMEDSP); 
open SOMEDSP; 
endif; 
else; 
// do batch stuff 
endif; 



endsr; 
/End-Free 



http://www.scottklement.com/rpg/socktut/intjobid.html

v5r1 - http://publib.boulder.ibm.com/iseries/v5r1/ic2924/index.htm?info/apis/qusrjobi.htm

v6r1 - http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/apis/qusrjobi.htm

More as400 api job information to follow

No comments:

Post a Comment