ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

utility to monitor a susbsystem & jobq

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: utility to monitor a susbsystem & jobq

    it wont hurt anything........It will just run or not!


    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #17
      Re: utility to monitor a susbsystem & jobq

      I got 2 messages in the job log that say it found a running job, there are quite a bit more than 2, so I'll try and tweak it and see if I can get it right

      Great code... thanks a ton
      Your future President
      Bryce

      ---------------------------------------------
      http://www.bravobryce.com

      Comment


      • #18
        Re: utility to monitor a susbsystem & jobq

        Originally posted by bryce4president View Post
        In Jamie's first example I changed the line...
        Code:
               JobType = '*';
        to
        Code:
               JobType = 'I';
        that way I would only see interactive jobs.

        Then at the bottom if JobStatus = "RUN" would give me all the actively running interactive jobs right?

        So I have this...

        Code:
                 if Jobbstatus = 'RUN';
                   dsply 'Found a running Job';
                 endif;
        This would display the message Found a running Job for each running interactive jog right?

        The code compiles, so if I run this it won't hurt anything right? I just want to double check...
        just take out the condition the API has already done the selection for you by passing the JobType = 'I'...you should just have to execute your CHGJOB on the entries (or you could use the CHGJOB API

        if you do use the condition you'll also have to check for DSPW, EVTW, etc...(do WRKACTJOB you'll see) there likely was only 2 jobs in a RUN status...
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #19
          Re: utility to monitor a susbsystem & jobq

          try this you do need to add hunk of code to only look at
          inteactive job type "I"
          Code:
          ljob200.JobType = 'I'
          also remove as400pros email address and replace it
          with yours...unless


          Code:
                *
                * CrtUsrSpc: Create User Space for OS/400 API's
                *
               d QUSCRTUS        pr                  extpgm('QUSCRTUS')
               d   UsrSpc                      20A   const
               d   ExtAttr                     10A   const
               d   InitialSize                 10I 0 const
               d   InitialVal                   1A   const
               d   PublicAuth                  10A   const
               d   Text                        50A   const
               d   Replace                     10A   const
               d   ErrorCode                32766A   options(*nopass: *varsize)
                *
                * --- Prototype for API Retrive User Space
                *
               d QUSRTVUS        pr                  extpgm( 'QUSRTVUS' )
               d   QRtvUserSpace...
               d                               20
               d   QRtvStartingPosition...
               d                                8b 0
               d   QRtvLengthOfData...
               d                                8b 0
               d   QRtvReceiverVariable...
               d                            32048
               d   QRtvError...
               d                              256
          
                * --- Prototype for API Retrive List Job
                *
               d QUSLJOB         pr                  extpgm( 'QUSLJOB' )
               d   QJobUserSpace...
               d                               20
               d   QJobFormatName...
               d                                8
               d   QJobJobName...
               d                               26
               d   QFldStatus...
               d                               10
               d   QFldError...
               d                              256
               d   QJobType...
               d                                1
               d   QNbrFldRtn...
               d                                8b 0
               d   QKeyFldRtn...
               d                                8b 0 dim( 100 )
                *
                * Defined variables
                *
               d size            s             10I 0
               d UsrSpcName      s             20    inz( 'DSPJOB    QTEMP     ' )
                ******************************************************************
          
               dQUSA0100         DS
               d QUsrSpcOffset...
               d                         1      4B 0
               d QUsrSpcEntries...
               d                         9     12B 0
               d QUsrSpcEntrieSize...
               d                        13     16B 0
          
               dLJOBINPUT        ds                           qualified
               d  JobName...
               d                         1     10
               d  UserName...
               d                        11     20
               d  JobNumber...
               d                        21     26
               d  Status...
               d                        27     36
               d  UserSpace...
               d                        37     46
               d  UserSpaceLibrary...
               d                        47     56
               d  Format...
               d                        57     64
               d  JobType...
               d                        65     65
               d  Reserved01...
               d                        66     68
               d  Reserved02...
               d                        69     72B 0
                *
               dLJOB100          ds                           qualified
               d  JobName...
               d                         1     10
               d  UserName...
               d                        11     20
               d  JobNumber...
               d                        21     26
               d  InternalJobId...
               d                        27     42
               d  Status...
               d                        43     52
               d  JobType...
               d                        53     53
               d  JobSubType...
               d                        54     54
               d  Reserved01...
               d                        55     56
                *
               dLJOB200          ds                           qualified
               d  JobName...
               d                         1     10
               d  UserName...
               d                        11     20
               d  JobNumber...
               d                        21     26
               d  InternalJobId...
               d                        27     42
               d  Status...
               d                        43     52
               d  JobType...
               d                        53     53
               d  JobSubType...
               d                        54     54
               d  Reserved01...
               d                        55     56
               d  JobInfoStatus...
               d                        57     57
               d  Reserved02...
               d                        58     60
               d  NumberOfFieldsReturned...
               d                        61     64B 0
               d  ReturnedData...
               d                        65   1064
                *
               dLJOB200KEY       ds                           qualified
               d  KeyNumber01...
               d                         1      4B 0
               d  NumberOfKeys...
               d                         5      8B 0
                *
               dLJOBKEYINFO      ds                           qualified
               d  LengthOfInformation...
               d                         1      4b 0
               d  KeyField...
               d                         5      8b 0
               d  TypeOfData...
               d                         9      9
               d  Reserved01...
               d                        10     12
               d  LengthOfData...
               d                        13     16B 0
               d  KeyData...
               d                        17   1016
                *
                *  APIErrDef     Standard API error handling structure.                  *
                *
               dQUSEC            DS
               d  ErrorBytesProvided...
               d                         1      4B 0
               d  ErrorBytesAvailble...
               d                         5      8b 0
               d  ErrorExceptionId...
               d                         9     15
               d  ErrorReserved...
               d                        16     16
                *
               dAPIError         DS
               d APIErrorProvied...
               d                                     LIKE( ErrorBytesProvided )
               d                                     INZ( %LEN( APIError ) )
               d APIErrorAvailble...
               d                                     LIKE( ErrorBytesAvailble )
               d APIErrorMessageID...
               d                                     LIKE( ErrorExceptionId )
               d APIErrorReserved...
               d                                     LIKE( ErrorReserved )
               d APIErrorInformation...
               d                              240A
                *-----------------------------------------------------------------
                * program status dataarea
                *-----------------------------------------------------------------
               d PgmSts         SDS
               d   P1User              254    263
               d   @PGM            *PROC
               d  @JOB                 244    253
                *--------------------------------------------------------------*
                * work fields                                                  *
                *--------------------------------------------------------------*
               d Variables       ds
               d   Q                            1    inz( '''' )
               d   Count                       15  0 inz(  0   )
               d   KeyCount                    15  0 inz(  0   )
               d   EndPos                      15  0 inz(  0   )
               d   JobbStatus                   4    inz( ' '  )
               d   Subsystem                   20    inz( ' '  )
               d   ReturnCode                   1    inz( ' '  )
               d   FormatName                   8    inz( ' ' )
               d   QualifedJobName...
               d                               26    inz( ' ' )
               d   JobStatus                   10    inz( ' ' )
               d   JobType                      1    inz( ' ' )
               d   NbrOfFldRtn                  8B 0 inz(  0  )
               d   KeyFldRtn                    8B 0 inz(  0  ) dim( 100 )
               d   StartingPosition...
               d                                8B 0 inz(  0  )
               d   LengthOfData...
               d                                8B 0 inz(  0  )
               d   KeyStartingPosition...
               d                                8B 0 inz(  0  )
               d   KeyLengthOfData...
               d                                8B 0 inz(  0  )
               d   ReceiverVariable...
               d                            32048
               d   OS400_Cmd                 2000    inz( ' '  )
               d   CmdLength                   15P 5 inz( %size( OS400_Cmd ) )
               d   True                         1    inz( *on  )
               d   False                        1    inz( *off )
                *
               d qcmdexc         pr                  extpgm( 'QCMDEXC' )
               d   os400_cmd                 2000A   options( *varsize ) const
               d   cmdlength                   15P 5                     const
                *
               d emailaddress    s             50    inz('as400pro@code400.com')
          
                *
                /free
          
                 //
                 // Create a user space
                 //
                    size = 10000;
          
                   // Create a user space
                   QUSCRTUS(UsrSpcName: 'USRSPC': size: x'00': '*ALL':
                    'Temp User Space for  QUSLJOB API':  '*YES': APIError);
          
          
                 exsr CheckStatusOfJob;
          
                 *inlr = *on;
                 // *************************************************************
                 // check status of an job
                 // -------------------------------------------------------------
                 begsr CheckStatusOfJob;
          
                 // run API to fill user space with information about all iSeries job
          
                 FormatName = 'JOBL0200';
                 QualifedJobName = '*ALL      ' + '*ALL      ' + '*ALL  ';
                 JobStatus = '*ACTIVE';
                 JobType = '*';
                 NbrOfFldRtn = 2;
                 KeyFldRtn( 1 ) = 0101;
                 KeyFldRtn( 2 ) = 1906;
                 callp QUSLJOB( UsrSpcName : FormatName  : QualifedJobName :
                                JobStatus  : APIError    :
                                JobType    : 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;
          
                  // if 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;
                   callp QUSRTVUS( UsrSpcName   : StartingPosition  :
                                   LengthOfData : ReceiverVariable  :
                                   APIError                           );
                   LJOB200 = ReceiverVariable;
                   if APIErrorMessageID <> ' ';
                     dump;
                     ReturnCode = True;
                     leavesr;
                   endif;
          
                   // check status of job
                   JobbStatus = ' ';
                   Subsystem = ' ';
                   LJobKeyInfo = LJob200.ReturnedData;
          
                   // Job type
                   // A  The job is an autostart job.
                   // B  The job is a batch job.
                   // I  The job is an interactive job.
                   // M  The job is a subsystem monitor job.
                   // R  The job is a spooled reader job.
                   // S  The job is a system job.
                   // W  The job is a spooled writer job.
                   // X  The job is the SCPF system job.
          
                   // Job subtype
                   // D  The job is a batch immediate job.
                   // E  The job started with a procedure start request.
                   // F  The job is an AS/400 Advanced 36 machine server job.
                   // J  The job is a prestart job.
                   // P  The job is a print driver job.
                   // T  The job is a System/36 multiple requester terminal (MRT) job.
                   // U  The job is an alternate spool user.
          
                   KeyStartingPosition = 1;
                   KeyLengthOfData = LJobKeyInfo.LengthOfInformation;
                   for keycount = 1 to LJob200.NumberOfFieldsReturned;
                     LJobKeyInfo = %subst( LJob200.ReturnedData :
                                           KeyStartingPosition :
                                           KeyLengthOfData );
                     KeyLengthOfData = LJobKeyInfo.LengthOfInformation;
                     LJobKeyInfo = %subst( LJob200.ReturnedData :
                                           KeyStartingPosition :
                                           KeyLengthOfData );
                     Endpos = LJobKeyInfo.LengthOfData;
                     if     LJobKeyInfo.KeyField = 0101;
                        JobbStatus = %subst( LJobKeyInfo.KeyData : 1 :  Endpos );
                     elseif LJobKeyInfo.KeyField = 1906;
                        Subsystem = %subst( LJobKeyInfo.KeyData : 1 : Endpos );
                     endif;
                     KeyStartingPosition = KeyStartingPosition + KeyLengthOfData;
                   endfor;
          
                   // if job in message wait then email message to address in
                   // variable email address
          
                   if Jobbstatus = 'MSGW';
          
          
                     os400_cmd = 'snddst type(*lmsg) ' +
                                 'tointnet((' + Q + %trim(EmailAddress) +
                                 Q + ')) dstd(' + Q    +
                                 'Hey Its me '     +
                                 %trim(@job)  + '  ' + %char(%time())  +
                                 Q + ') longmsg(' + Q  +
                                 'Job in Message wait:  ' +
                                 %trim(ljob200.jobname) + '  ' +
                                 %trim(ljob200.username) + '  ' +
                                 %trim(ljob200.jobnumber) + '  ' +
                                 %char(%time())   +
                                 Q + ')';
                        qcmdexc ( os400_cmd : %size ( os400_cmd ) );
          
                   endif;
          
                   StartingPosition = StartingPosition + LengthOfData;
          
                 endfor;
          
                 endsr;
          Attached Files
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #20
            Re: utility to monitor a susbsystem & jobq

            ok...i made a command CHGINTJOB that basically changes all interactive jobs based on the APIs Jamie's code has in it. you can change the job priority, run priority, job date and timeslice for all interactive job, single job or by user, etc. you can download it from my website at http://www.tommyholden.com/downloads/save%20files/
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #21
              Re: utility to monitor a susbsystem & jobq

              BAD JAMIE!!! using B data types!!!....booo...hiss...boo
              Code:
                   d   StartingPosition...
                   d                                8B 0 inz(  0  )
              try this:
              Code:
                   d   StartingPosition...
                   d                               20i 0 inz(  0  )
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #22
                Re: utility to monitor a susbsystem & jobq

                In either way, neiter 8B 0 nor 20I 0 are correct!

                According to the manual, QUSRTVUS expects the following parameters:
                1. Qualified user space name Char(20)
                2. Starting position Binary(4)
                3. Length of data Binary(4)
                4. Receiver variable Char(*)
                5. Error code I/O Char(*) (optional parameter)


                Binary 4 means: To store the maximum value as binary value 4 bytes are needed. A single byte can hold 256 different values, i.e. 0 - 256 (or with an negative range -128 to +128).

                Because the maximum value needs 3 digits, an integer field must be defined in RPG either as 3U 0 or 3I 0.

                The maximum value of a 4 Byte binary field can hold 256x256 different values (0 - 65535 or -32768 - +32768). In RPG a 2 Byte Binary value must be stored as 5I 0 or 5U 0.
                ... and so on

                In this way a 4 Byte Binary value must be stored as 10I 0 (just caluclate 256**4).

                A binary field (data type B) is always converted into a packed value. In this way a 2B 0 Field can held a value between -99 and +99. The valid range for a 1 Byte Binary Field lies between -128 and + 128.

                If you define a 4 Byte Binary field as 8B 0, the valid range is -99,999,999 and 99,999,999. The valid range for a 4 Byte binary field is -2,147,483,648 and 2,147,483,647.

                Birgitta

                Comment


                • #23
                  Re: utility to monitor a susbsystem & jobq

                  Yeah, there was some fodder in the RPG mailing list today about this idea of not using binary and instead using the 5i 0 field for the 2B 0 field.

                  I'm going to keep playing with this solution throughout the day when I take a break from the project I *should* be working on. I'll let you guys know what I make of it
                  Your future President
                  Bryce

                  ---------------------------------------------
                  http://www.bravobryce.com

                  Comment


                  • #24
                    Re: utility to monitor a susbsystem & jobq

                    Originally posted by B.Hauser View Post
                    In either way, neiter 8B 0 nor 20I 0 are correct!

                    According to the manual, QUSRTVUS expects the following parameters:
                    1. Qualified user space name Char(20)
                    2. Starting position Binary(4)
                    3. Length of data Binary(4)
                    4. Receiver variable Char(*)
                    5. Error code I/O Char(*) (optional parameter)


                    Binary 4 means: To store the maximum value as binary value 4 bytes are needed. A single byte can hold 256 different values, i.e. 0 - 256 (or with an negative range -128 to +128).

                    Because the maximum value needs 3 digits, an integer field must be defined in RPG either as 3U 0 or 3I 0.

                    The maximum value of a 4 Byte binary field can hold 256x256 different values (0 - 65535 or -32768 - +32768). In RPG a 2 Byte Binary value must be stored as 5I 0 or 5U 0.
                    ... and so on

                    In this way a 4 Byte Binary value must be stored as 10I 0 (just caluclate 256**4).

                    A binary field (data type B) is always converted into a packed value. In this way a 2B 0 Field can held a value between -99 and +99. The valid range for a 1 Byte Binary Field lies between -128 and + 128.

                    If you define a 4 Byte Binary field as 8B 0, the valid range is -99,999,999 and 99,999,999. The valid range for a 4 Byte binary field is -2,147,483,648 and 2,147,483,647.

                    Birgitta
                    that's what i get for not looking at the API documentation...i just used Jamie's code! lol...BAD TOMMY!!!

                    yet another reason i use a service program for processing user spaces...i don't have to duplicate the code (or really play with pointers much either)
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment


                    • #25
                      Re: utility to monitor a susbsystem & jobq

                      okay guys...... here is your binary lite version...

                      either way it works...

                      Code:
                            *
                            * CrtUsrSpc: Create User Space for OS/400 API's
                            *
                           d QUSCRTUS        pr                  extpgm('QUSCRTUS')
                           d   UsrSpc                      20A   const
                           d   ExtAttr                     10A   const
                           d   InitialSize                 10I 0 const
                           d   InitialVal                   1A   const
                           d   PublicAuth                  10A   const
                           d   Text                        50A   const
                           d   Replace                     10A   const
                           d   ErrorCode                32766A   options(*nopass: *varsize)
                            *
                            * --- Prototype for API Retrive User Space
                            *
                           d QUSRTVUS        pr                  extpgm( 'QUSRTVUS' )
                           d   QRtvUserSpace...
                           d                               20
                           d   QRtvStartingPosition...
                           d                               10i 0
                           d   QRtvLengthOfData...
                           d                               10i 0
                           d   QRtvReceiverVariable...
                           d                            32048
                           d   QRtvError...
                           d                              256
                      
                            * --- Prototype for API Retrive List Job
                            *
                           d QUSLJOB         pr                  extpgm( 'QUSLJOB' )
                           d   QJobUserSpace...
                           d                               20
                           d   QJobFormatName...
                           d                                8
                           d   QJobJobName...
                           d                               26
                           d   QFldStatus...
                           d                               10
                           d   QFldError...
                           d                              256
                           d   QJobType...
                           d                                1
                           d   QNbrFldRtn...
                           d                               10i 0
                           d   QKeyFldRtn...
                           d                               10i 0 dim( 100 )
                            *
                            * Defined variables
                            *
                           d size            s             10I 0
                           d UsrSpcName      s             20    inz( 'DSPJOB    QTEMP     ' )
                            ******************************************************************
                      
                           dQUSA0100         DS
                           d QUsrSpcOffset...
                           d                               10i 0
                           d QUSAreserved...
                           d                               10i 0
                           d QUsrSpcEntries...
                           d                               10i 0
                           d QUsrSpcEntrieSize...
                           d                               10i 0
                      
                           dLJOBINPUT        ds                           qualified
                           d  JobName...
                           d                               10
                           d  UserName...
                           d                               10
                           d  JobNumber...
                           d                                6
                           d  Status...
                           d                               10
                           d  UserSpace...
                           d                               10
                           d  UserSpaceLibrary...
                           d                               10
                           d  Format...
                           d                                8
                           d  JobType...
                           d                                1
                           d  Reserved01...
                           d                                3
                           d  Reserved02...
                           d                               10i 0
                            *
                           dLJOB100          ds                           qualified
                           d  JobName...
                           d                         1     10
                           d  UserName...
                           d                        11     20
                           d  JobNumber...
                           d                        21     26
                           d  InternalJobId...
                           d                        27     42
                           d  Status...
                           d                        43     52
                           d  JobType...
                           d                        53     53
                           d  JobSubType...
                           d                        54     54
                           d  Reserved01...
                           d                        55     56
                            *
                           dLJOB200          ds                           qualified
                           d  JobName...
                           d                               10
                           d  UserName...
                           d                               10
                           d  JobNumber...
                           d                                6
                           d  InternalJobId...
                           d                               16
                           d  Status...
                           d                               10
                           d  JobType...
                           d                                1
                           d  JobSubType...
                           d                                1
                           d  Reserved01...
                           d                                2
                           d  JobInfoStatus...
                           d                                1
                           d  Reserved02...
                           d                                3
                           d  NumberOfFieldsReturned...
                           d                               10i 0
                           d  ReturnedData...
                           d                             1000
                            *
                           dLJOB200KEY       ds                           qualified
                           d  KeyNumber01...
                           d                               10i 0
                           d  NumberOfKeys...
                           d                               10i 0
                            *
                           dLJOBKEYINFO      ds                           qualified
                           d  LengthOfInformation...
                           d                               10i 0
                           d  KeyField...
                           d                               10i 0
                           d  TypeOfData...
                           d                                1
                           d  Reserved01...
                           d                                3
                           d  LengthOfData...
                           d                               10i 0
                           d  KeyData...
                           d                             1000
                            *
                            *  APIErrDef     Standard API error handling structure.                  *
                            *
                           dQUSEC            DS
                           d  ErrorBytesProvided...
                           d                               10i 0
                           d  ErrorBytesAvailble...
                           d                               10i 0
                           d  ErrorExceptionId...
                           d                                7
                           d  ErrorReserved...
                           d                                1
                            *
                           dAPIError         DS
                           d APIErrorProvied...
                           d                                     LIKE( ErrorBytesProvided )
                           d                                     INZ( %LEN( APIError ) )
                           d APIErrorAvailble...
                           d                                     LIKE( ErrorBytesAvailble )
                           d APIErrorMessageID...
                           d                                     LIKE( ErrorExceptionId )
                           d APIErrorReserved...
                           d                                     LIKE( ErrorReserved )
                           d APIErrorInformation...
                           d                              240A
                            *-----------------------------------------------------------------
                            * program status dataarea
                            *-----------------------------------------------------------------
                           d PgmSts         SDS
                           d   P1User              254    263
                           d   @PGM            *PROC
                           d  @JOB                 244    253
                            *--------------------------------------------------------------*
                            * work fields                                                  *
                            *--------------------------------------------------------------*
                           d Variables       ds
                           d   Q                            1    inz( '''' )
                           d   Count                       15  0 inz(  0   )
                           d   KeyCount                    15  0 inz(  0   )
                           d   EndPos                      15  0 inz(  0   )
                           d   JobbStatus                   4    inz( ' '  )
                           d   Subsystem                   20    inz( ' '  )
                           d   ReturnCode                   1    inz( ' '  )
                           d   FormatName                   8    inz( ' ' )
                           d   QualifedJobName...
                           d                               26    inz( ' ' )
                           d   JobStatus                   10    inz( ' ' )
                           d   JobType                      1    inz( ' ' )
                           d   NbrOfFldRtn                 10i 0 inz(  0  )
                           d   KeyFldRtn                   10i 0 inz(  0  ) dim( 100 )
                           d   StartingPosition...
                           d                               10i 0 inz(  0  )
                           d   LengthOfData...
                           d                               10i 0 inz(  0  )
                           d   KeyStartingPosition...
                           d                               10i 0 inz(  0  )
                           d   KeyLengthOfData...
                           d                               10i 0 inz(  0  )
                           d   ReceiverVariable...
                           d                            32048
                           d   OS400_Cmd                 2000    inz( ' '  )
                           d   CmdLength                   15P 5 inz( %size( OS400_Cmd ) )
                           d   True                         1    inz( *on  )
                           d   False                        1    inz( *off )
                            *
                           d qcmdexc         pr                  extpgm( 'QCMDEXC' )
                           d   os400_cmd                 2000A   options( *varsize ) const
                           d   cmdlength                   15P 5                     const
                            *
                           d emailaddress    s             50    inz('someone@code400.com')
                      
                            *
                            /free
                      
                             //
                             // Create a user space
                             //
                                size = 10000;
                      
                               // Create a user space
                               QUSCRTUS(UsrSpcName: 'USRSPC': size: x'00': '*ALL':
                                'Temp User Space for  QUSLJOB API':  '*YES': APIError);
                      
                      
                             exsr CheckStatusOfJob;
                      
                             *inlr = *on;
                             // *************************************************************
                             // check status of an job
                             // -------------------------------------------------------------
                             begsr CheckStatusOfJob;
                      
                             // run API to fill user space with information about all iSeries job
                      
                             FormatName = 'JOBL0200';
                             QualifedJobName = '*ALL      ' + '*ALL      ' + '*ALL  ';
                             JobStatus = '*ACTIVE';
                             JobType = '*';
                             NbrOfFldRtn = 2;
                             KeyFldRtn( 1 ) = 0101;
                             KeyFldRtn( 2 ) = 1906;
                             callp QUSLJOB( UsrSpcName : FormatName  : QualifedJobName :
                                            JobStatus  : APIError    :
                                            JobType    : 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;
                      
                              // if 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;
                               callp QUSRTVUS( UsrSpcName   : StartingPosition  :
                                               LengthOfData : ReceiverVariable  :
                                               APIError                           );
                               LJOB200 = ReceiverVariable;
                               if APIErrorMessageID <> ' ';
                                 dump;
                                 ReturnCode = True;
                                 leavesr;
                               endif;
                      
                               // check status of job
                               JobbStatus = ' ';
                               Subsystem = ' ';
                               LJobKeyInfo = LJob200.ReturnedData;
                      
                               // Job type
                               // A  The job is an autostart job.
                               // B  The job is a batch job.
                               // I  The job is an interactive job.
                               // M  The job is a subsystem monitor job.
                               // R  The job is a spooled reader job.
                               // S  The job is a system job.
                               // W  The job is a spooled writer job.
                               // X  The job is the SCPF system job.
                      
                               // Job subtype
                               // D  The job is a batch immediate job.
                               // E  The job started with a procedure start request.
                               // F  The job is an AS/400 Advanced 36 machine server job.
                               // J  The job is a prestart job.
                               // P  The job is a print driver job.
                               // T  The job is a System/36 multiple requester terminal (MRT) job.
                               // U  The job is an alternate spool user.
                      
                               KeyStartingPosition = 1;
                               KeyLengthOfData = LJobKeyInfo.LengthOfInformation;
                               for keycount = 1 to LJob200.NumberOfFieldsReturned;
                                 LJobKeyInfo = %subst( LJob200.ReturnedData :
                                                       KeyStartingPosition :
                                                       KeyLengthOfData );
                                 KeyLengthOfData = LJobKeyInfo.LengthOfInformation;
                                 LJobKeyInfo = %subst( LJob200.ReturnedData :
                                                       KeyStartingPosition :
                                                       KeyLengthOfData );
                                 Endpos = LJobKeyInfo.LengthOfData;
                                 if     LJobKeyInfo.KeyField = 0101;
                                    JobbStatus = %subst( LJobKeyInfo.KeyData : 1 :  Endpos );
                                 elseif LJobKeyInfo.KeyField = 1906;
                                    Subsystem = %subst( LJobKeyInfo.KeyData : 1 : Endpos );
                                 endif;
                                 KeyStartingPosition = KeyStartingPosition + KeyLengthOfData;
                               endfor;
                      
                               // if job in message wait then email message to address in
                               // variable email address
                      
                               if Jobbstatus = 'MSGW';
                      
                      
                                 os400_cmd = 'snddst type(*lmsg) ' +
                                             'tointnet((' + Q + %trim(EmailAddress) +
                                             Q + ')) dstd(' + Q    +
                                             'Hey Its me '     +
                                             %trim(@job)  + '  ' + %char(%time())  +
                                             Q + ') longmsg(' + Q  +
                                             'Job in Message wait:  ' +
                                             %trim(ljob200.jobname) + '  ' +
                                             %trim(ljob200.username) + '  ' +
                                             %trim(ljob200.jobnumber) + '  ' +
                                             %char(%time())   +
                                             Q + ')';
                                    qcmdexc ( os400_cmd : %size ( os400_cmd ) );
                      
                               endif;
                      
                               StartingPosition = StartingPosition + LengthOfData;
                      
                             endfor;
                      
                             endsr;
                      Attached Files
                      All my answers were extracted from the "Big Dummy's Guide to the As400"
                      and I take no responsibility for any of them.

                      www.code400.com

                      Comment


                      • #26
                        Re: utility to monitor a susbsystem & jobq

                        Hi,

                        Just a have little fun with binary and integer:
                        PHP Code:
                        D DSBinFix        DS                  Qualified      
                        D   Int1                  1      2B 0 inz
                        (*LoVal)    
                        D   Bl1                   3      3A   inz(*Blanks)   
                        D   Int2                  4      5B 0 inz(*HiVal)    
                        D   Bl2                   6      6A   inz(*Blanks)   
                        D   Int3                  7     10B 0 inz(*LoVal)    
                        D   Bl3                  11     11A   inz(*Blanks)   
                        D   Int4                 12     15B 0 inz(*HiVal)    
                        D   Bl4                  16     16A                  
                                                                             
                        D DSIntFix        DS                  Qualified      
                        D   Int1                  1      2I 0 inz
                        (*LoVal)    
                        D   Bl1                   3      3A   inz(*Blanks)   
                        D   Int2                  4      5I 0 inz(*HiVal)    
                        D   Bl2                   6      6A   inz(*Blanks)   
                        D   Int3                  7     10I 0 inz(*LoVal)    
                        D   Bl3                  11     11A   inz(*Blanks)   
                        D   Int4                 12     15I 0 inz(*HiVal)    
                        D   Bl4                  16     16A                  
                                                                             
                         D DSBinLength     DS                  Qualified     
                        D   Int1                         4B 0 inz
                        (*LoVal)   
                        D                                1A   inz(*Blanks)  
                        D   Int2                         4B 0 inz(*HiVal)   
                        D                                1A   inz(*Blanks)  
                        D   Int3                         9B 0 inz(*LoVal)   
                        D                                1A   inz(*Blanks)  
                        D   Int4                         9B 0 inz(*HiVal)   
                        D                                1A                 
                                                                            
                        D DSIntLength     DS                  Qualified     
                        D   Int1                         5I 0 inz
                        (*LoVal)   
                        D                                1A   inz(*Blanks)  
                        D   Int2                         5I 0 inz(*HiVal)   
                        D                                1A   inz(*Blanks)  
                        D   Int3                        10I 0 inz(*LoVal)   
                        D                                1A   inz(*Blanks)  
                        D   Int4                        10I 0 inz(*HiVal)   
                        D                                1A                 
                         
                        *------------------------------------------------------------------------------&#37;
                         
                        /Free
                           Dsply 
                        (%char(DSBinFix.Int1) + ' ' + %Char(DSBinFix.Int2));           
                           
                        Dsply (%char(DSIntFix.Int1) + ' ' + %Char(DSIntFix.Int2));           
                           
                        Dsply (%char(DSBinLength.Int1) + ' ' + %Char(DSBinLength.Int2));     
                           
                        Dsply (%char(DSIntLength.Int1) + ' ' + %Char(DSIntLength.Int2));     
                           
                        Dsply (%char(DSBinFix.Int3) + ' ' + %Char(DSBinFix.Int4));           
                           
                        Dsply (%char(DSIntFix.Int3) + ' ' + %Char(DSIntFix.Int4));           
                           
                        Dsply (%char(DSBinLength.Int3) + ' ' + %Char(DSBinLength.Int4));     
                           
                        Dsply (%char(DSIntLength.Int3) + ' ' + %Char(DSIntLength.Int4));     
                           *
                        InLR = *ON;                                                         
                         /
                        End-Free 
                        Birgitta
                        Last edited by B.Hauser; July 29, 2008, 07:58 AM.

                        Comment


                        • #27
                          Re: utility to monitor a susbsystem & jobq

                          Originally posted by B.Hauser View Post
                          Hi,

                          Just a have little fun with binary and integer:
                          PHP Code:
                          D DSBinFix        DS                  Qualified      
                          D   Int1                  1      2B 0 inz
                          (*LoVal)    
                          D   Bl1                   3      3A   inz(*Blanks)   
                          D   Int2                  4      5B 0 inz(*HiVal)    
                          D   Bl2                   6      6A   inz(*Blanks)   
                          D   Int3                  7     10B 0 inz(*LoVal)    
                          D   Bl3                  11     11A   inz(*Blanks)   
                          D   Int4                 12     15B 0 inz(*HiVal)    
                          D   Bl4                  16     16A                  
                                                                               
                          D DSIntFix        DS                  Qualified      
                          D   Int1                  1      2I 0 inz
                          (*LoVal)    
                          D   Bl1                   3      3A   inz(*Blanks)   
                          D   Int2                  4      5I 0 inz(*HiVal)    
                          D   Bl2                   6      6A   inz(*Blanks)   
                          D   Int3                  7     10I 0 inz(*LoVal)    
                          D   Bl3                  11     11A   inz(*Blanks)   
                          D   Int4                 12     15I 0 inz(*HiVal)    
                          D   Bl4                  16     16A                  
                                                                               
                           D DSBinLength     DS                  Qualified     
                          D   Int1                         4B 0 inz
                          (*LoVal)   
                          D                                1A   inz(*Blanks)  
                          D   Int2                         4B 0 inz(*HiVal)   
                          D                                1A   inz(*Blanks)  
                          D   Int3                         9B 0 inz(*LoVal)   
                          D                                1A   inz(*Blanks)  
                          D   Int4                         9B 0 inz(*HiVal)   
                          D                                1A                 
                                                                              
                          D DSIntLength     DS                  Qualified     
                          D   Int1                         5I 0 inz
                          (*LoVal)   
                          D                                1A   inz(*Blanks)  
                          D   Int2                         5I 0 inz(*HiVal)   
                          D                                1A   inz(*Blanks)  
                          D   Int3                        10I 0 inz(*LoVal)   
                          D                                1A   inz(*Blanks)  
                          D   Int4                        10I 0 inz(*HiVal)   
                          D                                1A                 
                           
                          *------------------------------------------------------------------------------%
                           /
                          Free
                             Dsply 
                          (%char(DSBinFix.Int1) + ' ' + %Char(DSBinFix.Int2));           
                             
                          Dsply (%char(DSIntFix.Int1) + ' ' + %Char(DSIntFix.Int2));           
                             
                          Dsply (%char(DSBinLength.Int1) + ' ' + %Char(DSBinLength.Int2));     
                             
                          Dsply (%char(DSIntLength.Int1) + ' ' + %Char(DSIntLength.Int2));     
                             
                          Dsply (%char(DSBinFix.Int3) + ' ' + %Char(DSBinFix.Int4));           
                             
                          Dsply (%char(DSIntFix.Int3) + ' ' + %Char(DSIntFix.Int4));           
                             
                          Dsply (%char(DSBinLength.Int3) + ' ' + %Char(DSBinLength.Int4));     
                             
                          Dsply (%char(DSIntLength.Int3) + ' ' + %Char(DSIntLength.Int4));     
                             *
                          InLR = *ON;                                                         
                           /
                          End-Free 
                          Birgitta
                          a little bored today Birgitta?? LOL
                          I'm not anti-social, I just don't like people -Tommy Holden

                          Comment


                          • #28
                            Re: utility to monitor a susbsystem & jobq

                            Code:
                                  *
                                  * DSINTBIN.INT1 = -9999.
                                  * DSINTBIN.BL1 = ' '
                                  * DSINTBIN.INT2 = 9999.
                                  * DSINTBIN.BL2 = ' '
                                  * DSINTBIN.INT3 = -999999999.
                                  * DSINTBIN.BL3 = ' '
                                  * DSINTBIN.INT4 = 999999999.
                                  * DSINTBIN.BL4 = ' '
                                  *
                                 D DSIntBin        DS                  Qualified
                                 D   Int1                  1      2B 0 inz(*LoVal)
                                 D   Bl1                   3      3A   inz(*Blanks)
                                 D   Int2                  4      5B 0 inz(*HiVal)
                                 D   Bl2                   6      6A   inz(*Blanks)
                                 D   Int3                  7     10B 0 inz(*LoVal)
                                 D   Bl3                  11     11A   inz(*Blanks)
                                 D   Int4                 12     15B 0 inz(*HiVal)
                                 D   Bl4                  16     16A
                                  *
                                  *
                                  *  DSINTFIX.INT1 = -32768
                                  *  DSINTFIX.BL1 = ' '
                                  *  DSINTFIX.INT2 = 32767
                                  *  DSINTFIX.BL2 = ' '
                                  *  DSINTFIX.INT3 = -2147483648
                                  *  DSINTFIX.BL3 = ' '
                                  *  DSINTFIX.INT4 = 2147483647
                                  *  DSINTFIX.BL4 = ' '
                                  *
                                 D DSIntFix        DS                  Qualified
                                 D   Int1                  1      2I 0 inz(*LoVal)
                                 D   Bl1                   3      3A   inz(*Blanks)
                                 D   Int2                  4      5I 0 inz(*HiVal)
                                 D   Bl2                   6      6A   inz(*Blanks)
                                 D   Int3                  7     10I 0 inz(*LoVal)
                                 D   Bl3                  11     11A   inz(*Blanks)
                                 D   Int4                 12     15I 0 inz(*HiVal)
                                 D   Bl4                  16     16A
                                  *
                                  * DSBINLENGTH.INT1 = -9999.
                                  * DSBINLENGTH. = ' '
                                  * DSBINLENGTH.INT2 = 9999.
                                  * DSBINLENGTH. = ' '
                                  * DSBINLENGTH.INT3 = -999999999.
                                  * DSBINLENGTH. = ' '
                                  * DSBINLENGTH.INT4 = 999999999.
                                  * DSBINLENGTH. = ' '
                                  *
                                 D DSBinLength     DS                  Qualified
                                 D   Int1                         4B 0 inz(*LoVal)
                                 D                                1A   inz(*Blanks)
                                 D   Int2                         4B 0 inz(*HiVal)
                                 D                                1A   inz(*Blanks)
                                 D   Int3                         9B 0 inz(*LoVal)
                                 D                                1A   inz(*Blanks)
                                 D   Int4                         9B 0 inz(*HiVal)
                                 D                                1A
                                  *
                                  * DSINTLENGTH.INT1 = -32768
                                  * DSINTLENGTH. = ' '
                                  * DSINTLENGTH.INT2 = 32767
                                  * DSINTLENGTH. = ' '
                                  * DSINTLENGTH.INT3 = -2147483648
                                  * DSINTLENGTH. = ' '
                                  * DSINTLENGTH.INT4 = 2147483647
                                  * DSINTLENGTH. = ' '
                                  *
                                 D DSIntLength     DS                  Qualified
                                 D   Int1                         5I 0 inz(*LoVal)
                                 D                                1A   inz(*Blanks)
                                 D   Int2                         5I 0 inz(*HiVal)
                                 D                                1A   inz(*Blanks)
                                 D   Int3                        10I 0 inz(*LoVal)
                                 D                                1A   inz(*Blanks)
                                 D   Int4                        10I 0 inz(*HiVal)
                                 D                                1A
                                  *-------------------------------------------------------------------------------
                                  /Free
                                    Dsply (%char(DSIntBin.Int1) + ' ' + %Char(DSIntBin.Int2));
                                    Dsply (%char(DSIntFix.Int1) + ' ' + %Char(DSIntFix.Int2));
                                    Dsply (%char(DSBinLength.Int1) + ' ' + %Char(DSBinLength.Int2));
                                    Dsply (%char(DSIntLength.Int1) + ' ' + %Char(DSIntLength.Int2));
                                    Dsply (%char(DSIntBin.Int3) + ' ' + %Char(DSIntBin.Int4));
                                    Dsply (%char(DSIntFix.Int3) + ' ' + %Char(DSIntFix.Int4));
                                    Dsply (%char(DSBinLength.Int3) + ' ' + %Char(DSBinLength.Int4));
                                    Dsply (%char(DSIntLength.Int3) + ' ' + %Char(DSIntLength.Int4));
                                   *InLR = *ON;
                                  /End-Free
                            All my answers were extracted from the "Big Dummy's Guide to the As400"
                            and I take no responsibility for any of them.

                            www.code400.com

                            Comment


                            • #29
                              Re: utility to monitor a susbsystem & jobq

                              I have just downloaded the code in the OP, complied and made a few changes to select an individual job.

                              EDIT - Sorted
                              Last edited by Huddy; July 31, 2008, 02:36 AM.
                              www.midlifegamers.co.uk

                              Comment

                              Working...
                              X