ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Information on Scheduled JObs/ Jobs

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

  • Information on Scheduled JObs/ Jobs

    Hello All.........

    Some stuffs came and here I am to discuss the same..

    I have i.e. say 20 scheduled jobs. I know the program Name. Now without manually verifying the Program Name in the above scheduled jobs/jobs, Can I know which Jobs is using the above said program?

    Is there any way out to know the programs in the jobs (Jobs are not active) and without checking the call stacks for the active jobs?


    This query is not a requirement but for my clarification...Pls help
    Cheers
    PKBUNU

  • #2
    Re: Information on Scheduled JObs/ Jobs

    Are you talking about the Job Schedule Entries, Prestart jobs or others?
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Information on Scheduled JObs/ Jobs

      Scheduled Jobs
      Cheers
      PKBUNU

      Comment


      • #4
        Re: Information on Scheduled JObs/ Jobs

        The List Job Schedule Entries (QWCLSCDE) API lists the entries in the job schedule, QDFTJOBSCD.
        Check out the API on the InfoCenter.
        Use SCDL0200 format. Parse the Command field (offset 644) to find out the name of the called program.
        Also there is a CL example here for changing a job schedule entry. You could arrange this CL to fit your needs.
        Philippe

        Comment


        • #5
          Re: Information on Scheduled JObs/ Jobs

          Thanks Mercury Sir !!!!!!!!

          It is really helpful. The link is very helpful.

          Can you explain in detail on SCDL0200 format pls?
          Cheers
          PKBUNU

          Comment


          • #6
            Re: Information on Scheduled JObs/ Jobs

            Originally posted by pkbunu View Post
            Thanks Mercury Sir !!!!!!!!

            It is really helpful. The link is very helpful.

            Can you explain in detail on SCDL0200 format pls?
            let me google that for you http://tinyurl.com/r3mxv5
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: Information on Scheduled JObs/ Jobs

              I already have google stuffs, but need an understanding how it is working......can't get through the google......

              Anyway thanks Mr.Tomholden for googling on behalf of me.............. :-)
              Cheers
              PKBUNU

              Comment


              • #8
                Re: Information on Scheduled JObs/ Jobs

                pkbunu...

                You need to take the example and compile it.. then put it in debug and
                walk through the code. This will help you learn what is happening.
                Philippe provided a link to the code.....

                the formats are used in all API's each format provides different/enhanced
                return information.

                Tom was saying Google the API and read IBM's definition of the formats
                on IBM's site they list all formats including what is returned when using
                each one.



                Thanks
                jamie

                Example: Changing a job schedule entry

                This CL program uses APIs to change the user for a list of job schedule entries.

                This command interface to the Change Job Schedule Entry User (CHGSCDEUSR)
                program can change the USER parameter in the job schedule entry. You may:

                * Specify a job schedule entry name
                * Specify a generic job schedule entry name
                * Specify the *ALL value

                This example uses the following APIs:

                * Create User Space (QUSCRTUS)
                * List Job Schedule Entries (QWCLSCDE)
                * Retrieve User Space (QUSRTVUS)

                The following is the command definition for the CHGSCDEUSR command:
                PHP Code:
                    CMD        PROMPT('Change Job Schedule Entry User')
                               
                /* CPP CHGSCDEUSR */
                    
                PARM       KWD(JOBTYPE(*GENERICLEN(10) +
                                 
                SPCVAL((*ALL)) +
                                 
                MIN(1PROMPT('Job name:')
                    
                PARM       KWD(OLDUSERTYPE(*NAMELEN(10) +
                                 
                MIN(1PROMPT('Old user name:')
                    
                PARM       KWD(NEWUSERTYPE(*NAMELEN(10) +
                                 
                MIN(1PROMPT('New user name:'
                To create the command, specify the following:

                PHP Code:
                CRTCMD CMD(QGPL/CHGSCDEUSRPGM(QGPL/CHGSCDEUSR) +
                  
                SRCFILE(QGPL/QCMDSRC
                The following is the command-processing program that is written in CL
                to list the job schedule entries and change the user if necessary:
                Note: By using the code examples, you agree to the terms of the Code
                license and disclaimer information.

                Code:
                 /* **************************************************************** */
                 /* PROGRAM:  CHGSCDEUSR                                             */
                 /*                                                                  */
                 /* LANGUAGE:  CL                                                    */
                 /*                                                                  */
                 /* DESCRIPTION:  THIS PROGRAM WILL CHANGE THE USER FOR A LIST OF    */
                 /*              JOB SCHEDULE ENTRIES.                               */
                 /*                                                                  */
                 /* APIs USED:  QUSCRTUS, QWCLSCDE, QUSRTVUS                         */
                 /*                                                                  */
                 /* **************************************************************** */
                             PGM        PARM(&JOBNAME &OLDUSER &NEWUSER)
                
                 /*                                                                  */
                 /* Input parameters are as follows:                                 */
                 /*                                                                  */
                
                             DCL        VAR(&JOBNAME) TYPE(*CHAR) LEN(10) /* Input +
                                          job name */
                             DCL        VAR(&OLDUSER) TYPE(*CHAR) LEN(10) /* Input +
                                          old user name */
                             DCL        VAR(&NEWUSER) TYPE(*CHAR) LEN(10) /* Input +
                                          new user name */
                
                 /*                                                                  */
                 /* Local variables are as follows:                                  */
                 /*                                                                  */
                
                             DCL        VAR(&USRSPC) TYPE(*CHAR) LEN(20) +
                                          VALUE('CHGSCDEUSRQTEMP     ') /* User +
                                          space name for APIs */
                             DCL        VAR(&CNTHDL) TYPE(*CHAR) LEN(16) +
                                          VALUE('                ') /* Continuation +
                                          handle */
                             DCL        VAR(&NUMENTB) TYPE(*CHAR) LEN(4) /* Number +
                                          of entries from list job schedule entries +
                                          in binary form */
                             DCL        VAR(&NUMENT) TYPE(*DEC) LEN(8 0) /* Number +
                                          of entries from list job schedule entries +
                                          in decimal form */
                             DCL        VAR(&HDROFFB) TYPE(*CHAR) LEN(4) /* Offset +
                                          to the header portion of the user space in +
                                          binary form */
                             DCL        VAR(&HDRLENB) TYPE(*CHAR) LEN(4) /* Length +
                                          to the header portion of the user space in +
                                          binary form */
                             DCL        VAR(&GENHDR) TYPE(*CHAR) LEN(140) /* Generic +
                                          header information from the user space */
                             DCL        VAR(&HDRINFO) TYPE(*CHAR) LEN(26) /* Header +
                                          information from the user space */
                             DCL        VAR(&LSTSTS) TYPE(*CHAR) LEN(1) /* Status +
                                          of the list in the user space */
                             DCL        VAR(&OFFSETB) TYPE(*CHAR) LEN(4) /* Offset +
                                          to the list portion of the user space in +
                                          binary form */
                             DCL        VAR(&STRPOSB) TYPE(*CHAR) LEN(4) /* Starting +
                                          position in the user space  in binary form */
                             DCL        VAR(&ELENB) TYPE(*CHAR) LEN(4) /* List job +
                                          entry length in binary 4 form */
                             DCL        VAR(&LENTRY) TYPE(*CHAR) LEN(1156) /* +
                                          Retrieve area for list job schedule entry */
                             DCL        VAR(&INFOSTS) TYPE(*CHAR) LEN(1) /* Retrieve +
                                          area for information status */
                             DCL        VAR(&JOBNAM) TYPE(*CHAR) LEN(10) /* Retrieve +
                                          area for job name */
                             DCL        VAR(&ENTRY#) TYPE(*CHAR) LEN(6) /* Retrieve +
                                          area for entry number  */
                             DCL        VAR(&USERNM) TYPE(*CHAR) LEN(10) /* Retrieve +
                                          area for user name */
                
                 /*                                                                  */
                 /* Start of code                                                    */
                 /*                                                                  */
                
                 /*                                                                  */
                 /* You may want to monitor for additional messages here.            */
                 /*                                                                  */
                
                 /*                                                                  */
                 /* This creates the user space.  The user space will be 256 bytes   */
                 /* and will be initialized to blanks.                               */
                 /*                                                                  */
                
                             CALL       PGM(QUSCRTUS) PARM(&USRSPC 'CHGSCDEUSR' +
                                          X'00000100' ' ' '*ALL      ' 'CHGSCDEUSR +
                                          TEMPORARY USER SPACE                    ')
                             MONMSG     MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
                
                 /*                                                                  */
                 /* This lists job schedule entries of the name specified.           */
                 /*                                                                  */
                
                 PARTLIST:   CALL       PGM(QWCLSCDE) PARM(&USRSPC 'SCDL0200' +
                                          &JOBNAME &CNTHDL 0)
                
                 /*                                                                  */
                 /* Retrieve the generic header from the user space.                 */
                 /*                                                                  */
                
                             CALL       PGM(QUSRTVUS) PARM(&USRSPC X'00000001' +
                                          X'0000008C' &GENHDR)
                             MONMSG     MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
                 /*                                                                  */
                 /* Get the information status for the list from the generic header. */
                 /* If it is incomplete, go to BADLIST label and send out 'Bad list' */
                 /* message.                                                         */
                 /*                                                                  */
                
                             CHGVAR     VAR(&LSTSTS) VALUE(%SST(&GENHDR 104 1))
                             IF         COND(&LSTSTS = 'I') THEN(GOTO CMDLBL(BADLIST))
                
                 /*                                                                  */
                 /* Get the number of entries returned. Convert to decimal and       */
                 /* if zero go to NOENTS label to send out 'No entries' message.     */
                 /*                                                                  */
                
                             CHGVAR     VAR(&NUMENTB) VALUE(%SST(&GENHDR 133 4))
                             CHGVAR     VAR(&NUMENT) VALUE(%BIN(&NUMENTB))
                             IF         COND(&NUMENT = 0) THEN(GOTO CMDLBL(NOENTS))
                
                 /*                                                                  */
                 /* Get the list entry length and the list entry offset.             */
                 /* These values are used to set up the starting position.           */
                 /*                                                                  */
                
                             CHGVAR     VAR(&ELENB) VALUE(%SST(&GENHDR 137 4))
                             CHGVAR     VAR(&OFFSETB) VALUE(%SST(&GENHDR 125 4))
                             CHGVAR     VAR(%BIN(&STRPOSB)) VALUE(%BIN(&OFFSETB) + 1)
                
                 /*                                                                  */
                 /* This loops for the number of entries until no more entries are   */
                 /* found and goes to the ALLDONE label.                             */
                 /*                                                                  */
                
                 STARTLOOP:  IF         COND(&NUMENT = 0) THEN(GOTO CMDLBL(PARTCHK))
                
                 /*                                                                  */
                 /* This retrieves the list entry.                                   */
                 /*                                                                  */
                             CALL       PGM(QUSRTVUS) PARM(&USRSPC &STRPOSB &ELENB +
                                          &LENTRY)
                             MONMSG     MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
                 /*                                                                  */
                 /* This copies the information status, job name, entry number, and  */
                 /* user name.                                                       */
                 /*                                                                  */
                
                             CHGVAR     VAR(&INFOSTS) VALUE(%SST(&LENTRY 1 1))
                             CHGVAR     VAR(&JOBNAM)  VALUE(%SST(&LENTRY 2 10))
                             CHGVAR     VAR(&ENTRY#)  VALUE(%SST(&LENTRY 12 10))
                             CHGVAR     VAR(&USERNM)  VALUE(%SST(&LENTRY 547 10))
                
                 /*                                                                  */
                 /* This checks to make sure the list entry contains the user name.  */
                 /* If it does, the user name is compared to the old user name       */
                 /* passed in.  If either of these checks fails, this entry will     */
                 /* be skipped.                                                      */
                 /*                                                                  */
                
                             IF         COND(&INFOSTS *NE ' ') THEN(GOTO +
                                          CMDLBL(ENDLOOP))
                
                             IF         COND(&USERNM *NE &OLDUSER) THEN(GOTO +
                                          CMDLBL(ENDLOOP))
                
                 /*                                                                  */
                 /* This code will issue the CHGJOBSCDE command for the entry.       */
                 /*                                                                  */
                
                             CHGJOBSCDE JOB(&JOBNAM) ENTRYNBR(&ENTRY#) USER(&NEWUSER)
                             MONMSG     MSGID(CPF1620) EXEC(GOTO CMDLBL(NOCHG))
                             SNDPGMMSG  MSG('Entry' *BCAT &JOBNAM *BCAT &ENTRY# +
                                          *BCAT 'was changed.')
                             GOTO       CMDLBL(ENDLOOP)
                 NOCHG:      SNDPGMMSG  MSG('Entry' *BCAT &JOBNAM *BCAT &ENTRY# +
                                          *BCAT 'was NOT changed.')
                
                 /*                                                                  */
                 /* At end of loop, set new decimal position to the next entry and   */
                 /* decrement the loop counter by one.                               */
                 /*                                                                  */
                
                 ENDLOOP:    CHGVAR     VAR(%BIN(&STRPOSB)) VALUE(%BIN(&STRPOSB) +
                                        + %BIN(&ELENB))
                             CHGVAR     VAR(&NUMENT) VALUE(&NUMENT - 1)
                             GOTO       CMDLBL(STARTLOOP)
                
                 /*                                                                  */
                 /* This sends a message that no entries were found.                 */
                 /*                                                                  */
                
                 NOENTS:     SNDPGMMSG  MSG('No entries found.')
                             GOTO       CMDLBL(ALLDONE)
                
                 /*                                                                  */
                 /* This sends a message that the list was incomplete.               */
                 /*                                                                  */
                
                 BADLIST:    SNDPGMMSG  MSG('Incomplete list in the user space. +
                                             See joblog for details.')
                             GOTO       CMDLBL(ALLDONE)
                
                 /*                                                                  */
                 /* This sends a message that an unexpected error occurred.          */
                 /*                                                                  */
                
                 ERROR:      SNDPGMMSG  MSG('Unexpected error. +
                                             See joblog for details.')
                             GOTO       CMDLBL(ALLDONE)
                
                 /*                                                                  */
                 /* This will check for a partial list in the user space and         */
                 /* finish processing the rest of the list.                          */
                 /*                                                                  */
                
                 PARTCHK:    IF         COND(&LSTSTS = 'C') THEN(GOTO CMDLBL(ALLDONE))
                 /*                                                                  */
                 /* Retrieve the header information from the user space.             */
                 /* Use this information to get the rest of the list.                */
                 /*                                                                  */
                
                             CHGVAR     VAR(&HDROFFB) VALUE(%SST(&GENHDR 121 4))
                             CHGVAR     VAR(&HDRLENB) VALUE(%SST(&GENHDR 117 4))
                             CALL       PGM(QUSRTVUS) PARM(&USRSPC &HDROFFB +
                                          &HDRLENB &HDRINFO)
                             MONMSG     MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
                             CHGVAR     VAR(&CNTHDL) VALUE(%SST(&HDRINFO 11 16))
                             GOTO       CMDLBL(PARTLIST)
                
                
                 /*                                                                  */
                 /* All done.  Now the temporary user space is deleted.              */
                 /*                                                                  */
                
                 ALLDONE:    DLTUSRSPC  USRSPC(QTEMP/%SST(&USRSPC 1 10))
                             MONMSG     MSGID(CPF0000)
                             ENDPGM
                To create the CL program, specify the following:
                PHP Code:
                CRTCLPGM PGM(QGPL/CHGSCDEUSRSRCFILE(QGPL/QCLSRC
                You can change the command to:

                * Specify different parameters that the Change Job Schedule
                Entry (CHGJOBSCDE) command can change.
                * Provide a menu to select job schedule entries to be changed.
                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


                • #9
                  Re: Information on Scheduled JObs/ Jobs

                  Thanks Jamie.........
                  Cheers
                  PKBUNU

                  Comment

                  Working...
                  X