Problem solve Get help with specific problems with your technologies, process and projects.

Saving the scheduler entries

This tip teaches you how to save the scheduler entries.

I think that by now the AS/400 scheduler (WRKJOBSCDE) is quite familiar.

In many organizations a lot of processing is done using the scheduler and the importance of it grew.

In the AS/400 we save important stuff, Yet there is no support to save the scheduler data.

Happily, there is an API to come to the rescue. The List Job Schedule Entries (QWCLSCDE) API is quite easy to use, and it allows us to store the scheduler entries data in a file.

The next logical step would be to write a program to go through the file and do ADDJOBSCDE in case some thing goes wrong.

Another benefit would be to analyze the scheduler entries by the regular file processing method (Query,SQL etc.)

Note: This API is part of OS/400 Work Management API more info can be found at IBM.


                R LSTSCDENTR

                  STAT01         1

                  JNAM01        10
                                            COLHDG('Job' 'Name')
                  ENTNBR        10

                  SDAT01        10
                                            COLHDG('Schd' 'Date')
                  SDAY01        10
                                            COLHDG('Schd' 'Day')
                  SDAY02        10
                                            COLHDG('Schd' 'Day')
                  SDAY03        10
                                            COLHDG('Schd' 'Day')
                  SDAY04        10
                                            COLHDG('Schd' 'Day')
                  SDAY05        10
                                            COLHDG('Schd' 'Day')
                  SDAY06        10
                                            COLHDG('Schd' 'Day')
                  SDAY07        10
                                            COLHDG('Schd' 'Day')

                  STIM01         6
                                            COLHDG('Schd' 'Time')
                  SFREQ         10

                  SREL01        10
                  SREL02        10
                  SREL03        10
                  SREL04        10
                  SREL05        10

                  RCVACT        10
                  SDAT02        10
                  STAT02        10

                  SJOBQN        10
                  SJOBQL        10

                  UPRF01        10

                  SDAT04        10
                  STIM04         6

                  STEXT         50

                  RSRV01        23

                  STAT03        10

                  OMTD01        10          COLHDG('Dates' 'omitted')
                  OMTD02        10
                  OMTD03        10
                  OMTD04        10
                  OMTD05        10
                  OMTD06        10
                  OMTD07        10
                  OMTD08        10
                  OMTD09        10
                  OMTD10        10
                  OMTD11        10
                  OMTD12        10
                  OMTD13        10
                  OMTD14        10
                  OMTD15        10
                  OMTD16        10
                  OMTD17        10
                  OMTD18        10
                  OMTD19        10
                  OMTD20        10

                  JOBDN         10
                  JOBDL         10

                  PRF02         10

                  MSGQN         10
                  MSGQL         10

                  SAVENT        10

                  JNAM04        10
                  USRN04        10
                  JNBR04         6

                  SDAT05        10
                  STIM05         6
                  STAT05        10

                  RSRV02         2

                  CLEN           9B
                  CTXT         512
                                            COLHDG('Command String')
Program LSTSCDENTR (RPGLE)      

      * Compile parameters
     H datedit(*dmy)
      * Retrive Schedule Entries
      * Rosenberg Eitan 07/2001
     FLSTSCDENT o    e             disk
     D pgmds          sds
     D  pgmq             *proc
     D  inisiz         s              9b 0 inz(65536)
     D  l02nam         s             20    inz('RTVSCD    QTEMP     ')
     D  l02txt         s             50    inz('Schedule Entries    ')
     D  l02obj         s             10    inz('*ALL')
     D  l02fmt         s             10    inz('SCDL0200')
     D  l02hdl         s             16    inz('    ')
     D apierr          ds           512
     D  bytprv                        9b 0 inz(%size(apierr))
      * Externally described data structure
     D apircv        e ds                  extname(LSTSCDENT) inz
      * User space parameters
     D spcinf          s              9b 0 inz(0) dim(7)
     D spcini          s              1
     D spcatr          s             10
     D spcaut          s             10
     D spcqfn          s             20
     D spcrpl          s             10
     D spctxt          s             50
      * Delete user space
     C                   call      'QUSDLTUS'                                   DLTUSRSPC
     C                   parm      l02nam        spcqfn
     C                   parm                    apierr
      * Create user space
     C                   call      'QUSCRTUS'                                   CRTUSRSPC
     C                   parm                    spcqfn
     C                   parm      'SCDE   '     spcatr
     C                   parm                    inisiz
     C                   parm      ' '           spcini
     C                   parm      '*ALL'        spcaut
     C                   parm      l02txt        spctxt
     C                   parm      '*YES'        spcrpl
     C                   parm                    apierr
      * List Job Schedule Entries
     C                   call      'QWCLSCDE'                                   Entries
     C                   parm                    l02nam
     C                   parm                    l02fmt
     C                   parm                    l02obj
     C                   parm                    l02hdl
     C                   parm                    apierr
      * Get user space properties
     C                   call      'QUSRTVUS'
     C                   parm                    l02nam
     C                   parm      113           spcinf(01)                        Position
     C                   parm      028           spcinf(02)                        Length
     C                   parm                    spcinf                            Basic info
     C                   eval      spcinf(04) = spcinf(04) + 1                        First entry
      * loop over the user space entries and write to file
 B01 C     1             do        spcinf(06)
  01  *
  01 C                   call      'QUSRTVUS'
  01 C                   parm                    l02nam
  01 C                   parm                    spcinf(04)                        Position
  01 C                   parm                    spcinf(07)                        Length
  01 C                   parm                    apircv
  01  *
  01 C                   write     LSTSCDENTr
  01  *
  01 C                   eval      spcinf(04) = spcinf(04) + spcinf(07)
  01  *
 E01 C                   enddo
     C                   eval      *inlr = *on



             CLRPFM     FILE(LSTSCDENT)

             CALL       PGM(LSTSCDENTR)

This was last published in July 2001

Dig Deeper on Performance

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.