You are here: DBG/400>DBG400 Web>SourceCodeList>RpgleSource>RpgleRTVJOBCNT (revision 1)EditAttach
     H DATEDIT(*YMD) DEBUG(*YES) OPTION(*NODEBUGIO : *SRCSTMT) DFTACTGRP(*NO)
     H COPYRIGHT('Copyright (C) 2005  Martin Rowe   <martin@dbg400.net>')
      **********************************************************************************************
      * RTVJOBCNT: Retrieve Job Count
      * Copyright (C) 1997  Martin Rowe   <martin@dbg400.net>
      *
      * This program is free software; you can redistribute it and/or modify
      * it under the terms of the GNU General Public License as published by
      * the Free Software Foundation; either version 2 of the License, or
      * (at your option) any later version.
      *
      * This program is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      * GNU General Public License for more details.
      *
      * You should have received a copy of the GNU General Public License
      * along with this program; if not, write to the Free Software
      * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      **********************************************************************************************
      **********************************************************************************************
      * RTVJOBCNT: Retreive job count
      * This program retrieves details of the input job and returns the number of matching jobs
      * The user space header provides the number of entries returned - if this is zero,
      * then no matching jobs were found. If jobs are found, then their details are pulled out of
      * the user space. Currently the job details are not used.
      * Note:
      * Qualified job name INPUT; CHAR(26)
      *
      * The name of the job to be included in the list. The qualified job name has three parts:
      *
      * Job name CHAR(10). A specific job name, a generic name, or one of the following special
      *                     values
      * *            Only the job that this program is running in.
      *               The rest of the qualified job name parameter must be blank.
      * *CURRENT     All jobs with the current job's name.
      * *ALL         All jobs. The rest of the job name parameter must be specified.
      *
      * User name CHAR(10). A specific user profile name, a generic name, or one of the following
      *                     special values:
      * *CURRENT     Jobs with the current job's user profile.
      * *ALL         Jobs with the specified job name, regardless of the user  name.
      *               The rest of the job name parameter must be specified.
      *
      * Job number CHAR(6). A specific job number or the following special value:
      * *ALL         Jobs with the specified job name and user name, regardless of the job number.
      *               The rest of the job name parameter must be specified.
      **********************************************************************************************
      *  Data Structures
      **********************************************************************************************
      *  Standard error code DS for API error handling
     D Error_Code      DS
     D  BytesProvd             1      4B 0 Inz(0)
     D  BytesAvail             5      8B 0 Inz(0)
     D  Except_ID              9     15
     D  Reserved              16     16
     D  Exception             17    272
      *  Receiver value DS for user space header info (used in first call to QUSRTVUS)
     D GenRcvrDS       DS
     D  UserArea               1     64
     D  GenHdrSize            65     68B 0
     D  StrucLevel            69     72
     D  FormatName            73     80
     D  APIused               81     90
     D  CreateStamp           91    103
     D  InfoStatus           104    104
     D  SizeUSused           105    108B 0
     D  InpParmOff           109    112B 0
     D  InpParmSiz           113    116B 0
     D  HeadOffset           117    120B 0
     D  HeaderSize           121    124B 0
     D  ListOffset           125    128B 0
     D  ListSize             129    132B 0
     D  ListNumber           133    136B 0
     D  EntrySize            137    140B 0
      *****************************************************************
      *Type Definition for the JOBL0100 format.
      *****************************************************************
     D ListDataDS      DS
     D  L_JobName              1     10
     D  L_UserName            11     20
     D  L_JobNbr              21     26
     D  L_JobIdent            27     42
     D  L_Status              43     52
     D  L_JobType             53     53
     D  L_JobSubTy            54     54
     D  L_Reserved            55     56
      *
     D SystemDS       SDS
     D  SDSPgm                       10    Overlay(SystemDS:1)
      **********************************************************************************************
      *  Field definitions
      **********************************************************************************************
     D DataLength      S             10I 0 Inz(140)
     D CurrentEnt      S              5P 0 Inz(1)
     D peJobCount      S              5P 0
     D ExtendAttr      S             10    Inz('USRSPC    ')
     D Future          S              7    Inz('Not yet')
     D InitialSiz      S             10I 0 Inz(1024)
     D InitialVal      S              1    Inz(X'00')
     D peJobStatus     S             10
     D ListFormat      S              8    Inz('JOBL0100')
     D PublicAut       S             10    Inz('*ALL      ')
     D peQualJob       S             26
     D ReplaceSpc      S             10    Inz('*YES      ')
     D StartPos        S             10I 0 Inz(1)
     D TextDescrp      S             50    Inz('User space for List Job API')
     D UserSpace       S             20    Inz('RTVJOBCNT QTEMP     ')
      **********************************************************************************************
      *  ENTRY PARAMETERS
      **********************************************************************************************
     C     *Entry        PList
     C                   Parm                    peQualJob
     C                   Parm                    peJobStatus
     C                   Parm                    peJobCount
      **********************************************************************************************
      * MAINLINE PROGRAM
      **********************************************************************************************
      *  Create a user space to hold the job list entries
     C                   Call      'QUSCRTUS'
     C                   Parm                    UserSpace
     C                   Parm                    ExtendAttr
     C                   Parm                    InitialSiz
     C                   Parm                    InitialVal
     C                   Parm                    PublicAut
     C                   Parm                    TextDescrp
     C                   Parm                    ReplaceSpc
     C                   Parm                    Error_Code
      *  List all the jobs with the name passed in (generic okay)
     C                   Call      'QUSLJOB'
     C                   Parm                    UserSpace
     C                   Parm                    ListFormat
     C                   Parm                    peQualJob
     C                   Parm                    peJobStatus
     C                   Parm                    Error_Code
      *  Get the header info for this space
     C                   Call      'QUSRTVUS'
     C                   Parm                    UserSpace
     C                   Parm                    StartPos
     C                   Parm                    DataLength
     C                   Parm                    GenRcvrDS
     C                   Parm                    Error_Code
      *  Check to see how many entries returned
     C                   Eval      peJobCount = ListNumber
      *  The status of the requested job(s) has now been determined, so bounce round the following
      *  unless detailed job info is required at some future point.
B001 C                   If        Future = 'Now'
      *  Set the initial offset for the start of the list entries
     C                   Eval      ListOffset = ListOffset + 1
      *  Loop through the entries held in the list section of the user space
B002 C                   DoW       CurrentEnt <= ListNumber
      *  Get the header info for this space
     C                   Call      'QUSRTVUS'
     C                   Parm                    UserSpace
     C                   Parm                    ListOffset
     C                   Parm                    EntrySize
     C                   Parm                    ListDataDS
     C                   Parm                    Error_Code
      *  Bump up the counter & offset for the next entry
     C                   Eval      ListOffset = ListOffset + EntrySize
     C                   Eval      CurrentEnt = CurrentEnt + 1
E002 C                   EndDo
E001 C                   EndIf
      *
     C                   Eval      *INLR = *On
     C                   Return
      **********************************************************************************************

-- MartinRowe - 04 Aug 2005
Edit | Attach | Print version | History: r2 < r1 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r1 - 04 Aug 2005 - 19:39:51 - MartinRowe
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding DBG/400? Send feedback