× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Use the List jobs API  (QUSLJOB) and dump to a file

This program checks for an active job, but could be adapted to write to an output file.

    100 ***************************************************** 01/03/18
    200       * Check for an Active Job using 01/03/18
    300       * List Jobs API (QUSLJOB) prototype 01/03/18
    400 ***************************************************** 01/03/18
    500      D QUSLJOB         PR ExtPgm('QUSLJOB') 01/03/18
    600      D   UserSpace                   20A const 01/03/18
    700      D   Format                       8A const 01/03/18
    800      D   QualJob                     26A const 01/03/18
    900      D   Status                      10A const 01/03/18
   1000       * optional group 1: 01/03/18
   1100      D   ErrorCode                 8000A options(*varsize: *nopass)                                           01/03/18
   1200       * optional group 2: 01/03/18
   1300      D   JobType                      1A   const options(*nopass) 01/03/18
   1400      D   NbrKeyFld                   10I 0 const options(*nopass) 01/03/18
   1500      D   KeyFlds                     10I 0 const dim(1000) 01/03/18
   1600      D options(*varsize: *nopass)                                           01/03/18
   1700       * optional group 3: 01/03/18
   1800      D   ContHandle                  48A   const options(*nopass) 01/03/18
1900 01/03/18
   2000 ***************************************************** 01/03/18
   2100       * API error code data structure 01/03/18
   2200 ***************************************************** 01/03/18
   2300      D MyErrCode DS 01/03/18
   2400      D  BytesProv                    10I 0 inz(%size(MyErrCode)) 01/03/18
   2500      D  BytesAvail                   10I 0 inz(0) 01/03/18
   2600      D  MsgID 7A 01/03/18
   2700      D  Reserved 1A 01/03/18
   2800      D  MessageData 1000A 01/03/18
2900 01/03/18
   3000 ***************************************************** 01/03/18
   3100       * Generic Header Format used by the "List APIs" 01/03/18
   3200 * 01/03/18
   3300       *  There is a lot of information returned in the 01/03/18
   3400       *  generic header, but all I'm interested in is 01/03/18
   3500       *  the offsets needed to access the list entries 01/03/18
   3600       * themselves. 01/03/18
   3700 ***************************************************** 01/03/18
   3800      D p_ListHeader    s * 01/03/18
   3900      D ListHeader      ds based(p_ListHeader) 01/03/18
   4000      D   DataOffset          125    128I 0 01/03/18
   4100      D   NumEntries          133    136I 0 01/03/18
   4200      D   EntrySize           137    140I 0 01/03/18
4300 01/03/18
   4400 ***************************************************** 01/03/18
   4500       * This structure is designed to match format 01/03/18
   4600       * JOBL0100 the QUSLJOB API. 01/03/18
   4700 ***************************************************** 01/03/18
   4800      D p_ListEntry     s * 01/03/18
   4900      D JOBL0100        ds based(p_ListEntry) 01/03/18
   5000      D   JobName 10A 01/03/18
   5100      D   JobUser 10A 01/03/18
   5200      D   JobNbr 6A 01/03/18
   5300      D   InternalID 16A 01/03/18
   5400      D   Status 10A 01/03/18
   5500      D   JobType 1A 01/03/18
   5600      D   JobSubtype 1A 01/03/18
5700 01/03/18
   5800 ***************************************************** 01/03/18
   5900       * Create User Space (QUSCRTUS) API 01/03/18
   6000 ***************************************************** 01/03/18
   6100      D QUSCRTUS        PR ExtPgm('QUSCRTUS') 01/03/18
   6200      D   UserSpace                   20A const 01/03/18
   6300      D   Attrib                      10A const 01/03/18
   6400      D   InitSize                    10I 0 const 01/03/18
   6500      D   InitVal                      1A const 01/03/18
   6600      D   PubAuth                     10A const 01/03/18
   6700      D   Text                        50A const 01/03/18
   6800       * optional group 1: 01/03/18
   6900      D   Replace                     10A   const options(*nopass) 01/03/18
   7000      D   ErrorCode                 8000A options(*varsize: *nopass)                                           01/03/18
   7100       * optional group 2: 01/03/18
   7200      D   Domain                      10A   const options(*nopass) 01/03/18
   7300       * optional group 3: 01/03/18
   7400      D   XferSizeReq                 10I 0 const options(*nopass) 01/03/18
   7500      D   OptAlign                     1A   const options(*nopass) 01/03/18
7600 01/03/18
   7700 ***************************************************** 01/03/18
   7800       *  Retrieve Pointer to User Space (QUSPTRUS) API 01/03/18
   7900 ***************************************************** 01/03/18
   8000      D QUSPTRUS        PR ExtPgm('QUSPTRUS') 01/03/18
   8100      D   UserSpace                   20A const 01/03/18
   8200      D   Pointer * 01/03/18
   8300      D   ErrorCode                 8000A options(*varsize: *nopass)                                           01/03/18
8400 01/03/18
8500 01/03/18
   8600      D p_Start         s * 01/03/18
   8700      D EntryNo         s             10I 0 01/03/18
   8800      D JobFound        s 1 01/03/18
   8900      D JobCheck        s 10 01/03/18
9000 01/03/18
9100 01/03/18
   9200 ** 01/03/18
   9300       **  Create a user space that the QUSLJOB API can store it's 01/03/18
   9400       **  output into. 01/03/18
   9500 ** 01/03/18
   9600       **  The initial size of the user space will be 256k (256 * 1024) 01/03/18
   9700       **  however, the QUSLJOB API will extend it if it needs to be 01/03/18
   9800       ** larger. 01/03/18
   9900 ** 01/03/18
  10000      c     *entry plist 01/03/18
  10100      c                   parm JobCheck 01/03/18
  10200      c                   parm JobFound 01/03/18
  10300 c 01/03/18
  10400      c                   eval      JobFound = '0' 01/03/18
10500 01/03/18
  10600      c                   callp     QUSCRTUS( 'JOBLIST   QTEMP' 01/03/18
  10700      c                                     : 'MYPGMNAME' 01/03/18
  10800      c                                     : 256 * 1024 01/03/18
  10900      c                                     : x'00' 01/03/18
  11000      c                                     : '*USE' 01/03/18
  11100      c                                     : 'List of active jobs' 01/03/18
  11200      c                                     : '*YES' 01/03/18
  11300      c                                     : MyErrCode            ) 01/03/18
11400 01/03/18
  11500      c                   if        BytesAvail <> 0 01/03/18
  11600      c                   eval      *inlr = *on 01/03/18
  11700      c return 01/03/18
  11800      c endif 01/03/18
11900 01/03/18
12000 01/03/18
  12100 ** 01/03/18
  12200       **  List all active jobs on the system.  The output 01/03/18
  12300       **  will go into the user space we created (above) 01/03/18
  12400 ** 01/03/18
  12500      c                   callp     QUSLJOB( 'JOBLIST QTEMP'                                                   01/03/18
  12600      c                                    : 'JOBL0100' 01/03/18
  12700      c                                    : '*ALL      *ALL *ALL'                                          01/03/18
  12800      c                                    : '*ACTIVE' 01/03/18
  12900      c                                    : MyErrCode )                                         01/03/18
13000 01/03/18
  13100      c                   if        BytesAvail <> 0 01/03/18
  13200      c                   eval      *inlr = *on 01/03/18
  13300      c return 01/03/18
  13400      c endif 01/03/18
13500 01/03/18
  13600 ** 01/03/18
  13700       **  Get a pointer to the user space.  In this example, the 01/03/18
  13800       **  "Bytes Provided" field is zero, so the program will halt 01/03/18
  13900       **  with a "CPFxxxx" error if something goes wrong: 01/03/18
  14000 ** 01/03/18
  14100      c                   eval      BytesProv = 0 01/03/18
14200 01/03/18
  14300      c                   callp     QUSPTRUS( 'JOBLIST   QTEMP' 01/03/18
  14400      c                                     : p_ListHeader     ) 01/03/18
14500 01/03/18
  14600 ** 01/03/18
  14700       **  Use data structure that's based on a pointer to view each 01/03/18
  14800       **  entry in the list. After viewing each entry, increase 01/03/18
  14900       **  the pointer so that we view the next item. 01/03/18
  15000 ** 01/03/18
  15100      c                   eval      p_Start = p_ListHeader + DataOffset 01/03/18
15200 01/03/18
  15300      c                   for       EntryNo = 1 to NumEntries 01/03/18
15400 01/03/18
  15500      c                   eval      p_ListEntry = p_Start + 01/03/18
  15600      c                                 (EntryNo - 1) * EntrySize 01/03/18
15700 01/03/18
  15800       ** If the job is found 01/03/18
15900 01/03/18
  16000      c                   if        %trim(JobName) = %trim(Jobcheck) 01/03/18
16100 01/03/18
  16200      C                   eval      Jobfound = *on 01/03/18
16300 01/03/18
  16400 c 01/03/18
  16500      C endif 01/03/18
  16600      c endfor 01/03/18
16700 01/03/18
  16800 ** 01/03/18
  16900       **  That's all, end the program. 01/03/18
  17000 ** 01/03/18
  17100      c                   eval      *inlr = *on 01/03/18
                                  * * * *  E N D  O F  S O U R C E  * * * *

Gavin Inman


On 11/18/2020 4:58 PM, James H. H. Lampert wrote:
Ladies and Gentlemen, Fellow Geeks and Geekettes:

Got a quick question:

Suppose have I CL program that does a bunch of WRKACTJOBs, with output directed to a spool file, at one minute intervals.

Am I stuck with each one going to a new spool file, or is there a way to have them append to a single spool file?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.