|
> > I need a quick, down & dirty way to determine the number of jobs running in > a specific subsystem, then displaying the information on the screen. I was > looking at calling a command from the RPG program, sending the output to a > spooled file & processing it, but I did not want to have to process a > spooled file in that way. Anyone else have any ideas and/or examples? > That's a good choice! Processing a spooled file is a bad idea, because IBM can change the format of a spooled file at any time, breaking your program. Using an API protects you from that. Here's a sample that uses the QUSLJOB API. The QGYOLJOB API might also work, but I don't have a sample of that that I can send you. H DFTACTGRP(*NO) * * List jobs API * D QUSLJOB PR ExtPgm('QUSLJOB') D UsrSpc 20A const D Format 8A const D QualJob 26A const D Status 10A const D ErrorCode 32767A options(*varsize) D JobType 1A const options(*nopass) D NumFldsToRtn 10I 0 const options(*nopass) D FldsToRtn 10I 0 const options(*nopass) * * Create User Space API * D QUSCRTUS PR ExtPgm('QUSCRTUS') D UserSpc 20A const D ExtAttr 10A const D InitSize 10I 0 const D InitVal 1A const D PublicAuth 10A const D Text 50A const D Replace 10A const D ErrorCode 32766A options(*varsize) * * retrieve pointer to user space API * D QUSPTRUS PR ExtPgm('QUSPTRUS') D UserSpc 20A CONST D Pointer * * * API error code structure * (we inz to 0 to cause the APIs to return errors using normal * OS/400 error handling) * D dsEC DS D dsECBytesP 10I 0 INZ(0) D dsECBytesA 10I 0 INZ(0) D***************************************************** D* List API header data structure D***************************************************** D p_UsrSpc S * D dsLH DS BASED(p_UsrSpc) D* Filler D dsLHFill1 103A D* Status (I=Incomplete,C=Complete D* F=Partially Complete) D dsLHStatus 1A D* Filler D dsLHFill2 12A D* Header Offset D dsLHHdrOff 10I 0 D* Header Size D dsLHHdrSiz 10I 0 D* List Offset D dsLHLstOff 10I 0 D* List Size D dsLHLstSiz 10I 0 D* Count of Entries in List D dsLHEntCnt 10I 0 D* Size of a single entry D dsLHEntSiz 10I 0 D p_Job S * D dsJob DS based(p_Job) D dsJobName 10A D dsJobUser 10A D dsJobNbr 6A D dsJobIntID 16A D dsJobSts 10A D dsJobType 1A D dsJobSubType 1A D dsJobReserv 2A D dsJobInfSts 1A D dsJobReserv2 3A D dsJobNbrFlds 10I 0 D dsJobKeyAry 1A D p_KeyAry S * D dsKeyAry DS based(p_KeyAry) D dsKA_Len 10I 0 D dsKA_Field 10I 0 D dsKA_Type 1A D dsKA_Reserv 3A D dsKA_DtaLen 10I 0 D dsKA_Data 20A D JOBLIST C 'JOBLIST QTEMP' D SBSDNAME C 1906 D peSbsName S 10A D msg s 50A D Ent s 10I 0 * * Check parms * C *entry plist c parm peSbsName c if %parms < 1 c eval msg = 'You need to pass a subsystem name' c dsply msg c eval *inlr = *on c return c endif * * Create a user space * c callp QUSCRTUS(JOBLIST: 'USRSPC': c %size(dsJob) * 1000: *Blank: c '*ALL': 'List of jobs on system': c '*YES': dsEC) * * List jobs to the user space * c callp QUSLJOB(JOBLIST: 'JOBL0200': c '*ALL *ALL *ALL': '*ACTIVE': c dsEC: '*': 1: SBSDNAME) * * Read entries in user space * c callp QUSPTRUS(JOBLIST: p_UsrSpc) c for Ent = 0 to (dsLHEntCnt - 1) c eval p_Job = p_UsrSpc + dsLHLstOff + c (dsLhEntSiz * Ent) c eval p_KeyAry = %addr(dsJobKeyAry) c if dsKA_Field <> SBSDNAME c or dsKA_Type <> 'C' c or dsKA_DtaLen <> 20 c eval msg = 'Unknown key in key array' c dsply msg c leave c endif ** only print jobs in requested subsystem. ** and ignore subsystem monitor jobs. c if %subst(dsKA_Data: 1: 10) = peSbsName c and dsJobType <> 'M' c eval msg = %trim(dsJobNbr) + '/' + c %trim(dsJobUser) + '/' + c %trim(dsJobName) c msg dsply c endif c endfor c eval msg = 'Hit ENTER when done' c dsply msg c eval *inlr = *on
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.