REPORT RSNAPJOB MESSAGE-ID 00.

DATA:
  RDD_JOBNAME   LIKE TBTCO-JOBNAME,
  RDD_USERNAME  LIKE TBTCO-AUTHCKNAM VALUE 'DDIC',
  RDD_REPORT    LIKE SY-REPID,
  RDD_VARIANT   LIKE RALDB-VARIANT   VALUE '1',
  RDD_PRDDAYS   LIKE TBTCO-PRDDAYS,
  RDD_PRDMONTHS LIKE TBTCO-PRDMONTHS,
  RDD_STRTTIME  LIKE TBTCO-SDLSTRTTM VALUE 28800,
  RDD_STRTDATE  LIKE TBTCO-SDLSTRTDT,
  RDD_JOBCOUNT  LIKE TBTCO-JOBCOUNT,
  COUNT  LIKE TBTCO-SDLSTRTTM,
  NOVAR TYPE I.

IF SY-MANDT = '000'.                   " Client independent jobs

* SAP_REORG_ABAPDUMPS
  RDD_PRDDAYS  = 1.                    " 1 day period
  RDD_STRTDATE = SY-DATUM + 1.         " tomorrow
  RDD_JOBNAME = '#SAP_REORG_ABAPDUMPS'.
  RDD_REPORT = 'RSSNAPDL'.
  PERFORM SCHEDULE_JOB.

* SAP_REORG_JOBSTATISTIC
  RDD_PRDMONTHS = 1.                   " 1 month
  RDD_STRTDATE = SY-DATUM + 1.         " tomorrow
  RDD_JOBNAME = '#SAP_REORG_JOBSTATISTIC'.
  RDD_REPORT = 'RSBPSTDE'.
  PERFORM SCHEDULE_JOB.

* SAP_COLLECTOR_FOR_JOBSTATISTICS
  RDD_PRDDAYS  = 1.                    " 1 day period
  RDD_STRTDATE = SY-DATUM + 1.         " tomorrow
  RDD_JOBNAME = '#SAP_COLLECTOR_FOR_JOBSTATISTICS'.
  RDD_REPORT = 'RSBPCOLL'.
  NOVAR = 1.
  PERFORM SCHEDULE_JOB.
  CLEAR NOVAR.

* SAP_COLLECTOR_FOR_PERFMONITOR
  NOVAR = 1.
  COUNT = 28800.
  DO 12 TIMES.
    RDD_PRDDAYS  = 1.                  " 1 day period
    RDD_STRTDATE = SY-DATUM + 1.       " tomorrow
    RDD_STRTTIME = COUNT.              " 1 am
    RDD_JOBNAME = '#SAP_COLLECTOR_FOR_PERFMONITOR'.
    RDD_REPORT = 'RSCOLL00'.
    PERFORM SCHEDULE_JOB.
    COUNT = COUNT + 3600.
  ENDDO.
  CLEAR NOVAR.

ELSE.                                  " Client dependent jobs

* SAP_REORG_JOBS
  RDD_PRDDAYS  = 1.                    " 1 day period
  RDD_STRTDATE = SY-DATUM + 1.         " tomorrow
  RDD_JOBNAME = '#SAP_REORG_JOBS'.
  RDD_REPORT = 'RSBTCDEL'.
  PERFORM SCHEDULE_JOB.

* SAP_REORG_SPOOL
  RDD_PRDDAYS  = 1.                    " 1 day period
  RDD_STRTDATE = SY-DATUM + 1.         " tomorrow
  RDD_JOBNAME = '#SAP_REORG_SPOOL'.
  RDD_REPORT = 'RSPO0041'.
  PERFORM SCHEDULE_JOB.

* SAP_REORG_BATCHINPUT
  RDD_PRDDAYS  = 1.                    " 1 day period
  RDD_STRTDATE = SY-DATUM + 1.         " tomorrow
  RDD_JOBNAME = '#SAP_REORG_BATCHINPUT'.
  RDD_REPORT = 'RSBDCREO'.
  PERFORM SCHEDULE_JOB.
ENDIF.

*---------------------------------------------------------------------*
*       FORM SCHEDULE_JOB                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM SCHEDULE_JOB.
  CALL FUNCTION 'JOB_OPEN'
       EXPORTING
            JOBNAME          = RDD_JOBNAME
       IMPORTING
            JOBCOUNT         = RDD_JOBCOUNT
       EXCEPTIONS
            CANT_CREATE_JOB  = 1
            INVALID_JOB_DATA = 2
            JOBNAME_MISSING  = 3
            OTHERS           = 4.
  IF SY-SUBRC EQ 0.
    IF NOVAR IS INITIAL.
      CALL FUNCTION 'JOB_SUBMIT'
           EXPORTING
                JOBNAME                 = RDD_JOBNAME
                JOBCOUNT                = RDD_JOBCOUNT
                AUTHCKNAM               = RDD_USERNAME
                REPORT                  = RDD_REPORT
                VARIANT                 = RDD_VARIANT
           EXCEPTIONS
                BAD_PRIPARAMS           = 1
                BAD_XPGFLAGS            = 2
                INVALID_JOBDATA         = 3
                JOBNAME_MISSING         = 4
                JOB_NOTEX               = 5
                JOB_SUBMIT_FAILED       = 6
                LOCK_FAILED             = 7
                PROGRAM_MISSING         = 8
                PROG_ABAP_AND_EXTPG_SET = 9
                OTHERS                  = 10.
    ELSE.
      CALL FUNCTION 'JOB_SUBMIT'
           EXPORTING
                JOBNAME                 = RDD_JOBNAME
                JOBCOUNT                = RDD_JOBCOUNT
                AUTHCKNAM               = RDD_USERNAME
                REPORT                  = RDD_REPORT
*               variant                 = rdd_variant
           EXCEPTIONS
                BAD_PRIPARAMS           = 1
                BAD_XPGFLAGS            = 2
                INVALID_JOBDATA         = 3
                JOBNAME_MISSING         = 4
                JOB_NOTEX               = 5
                JOB_SUBMIT_FAILED       = 6
                LOCK_FAILED             = 7
                PROGRAM_MISSING         = 8
                PROG_ABAP_AND_EXTPG_SET = 9
                OTHERS                  = 10.
    ENDIF.
    IF SY-SUBRC EQ 0.
      IF RDD_PRDMONTHS IS INITIAL.
        CALL FUNCTION 'JOB_CLOSE'
             EXPORTING
                  JOBNAME              = RDD_JOBNAME
                  JOBCOUNT             = RDD_JOBCOUNT
                  PRDDAYS              = RDD_PRDDAYS
                  SDLSTRTDT            = RDD_STRTDATE
                  SDLSTRTTM            = RDD_STRTTIME
             EXCEPTIONS
                  CANT_START_IMMEDIATE = 1
                  INVALID_STARTDATE    = 2
                  JOBNAME_MISSING      = 3
                  JOB_CLOSE_FAILED     = 4
                  JOB_NOSTEPS          = 5
                  JOB_NOTEX            = 6
                  LOCK_FAILED          = 7
                  OTHERS               = 8.
        IF SY-SUBRC <> 0.
          MESSAGE S587 WITH RDD_JOBNAME.
        ENDIF.
      ELSE.
        CALL FUNCTION 'JOB_CLOSE'
             EXPORTING
                  JOBNAME              = RDD_JOBNAME
                  JOBCOUNT             = RDD_JOBCOUNT
                  PRDMONTHS            = RDD_PRDMONTHS
                  SDLSTRTDT            = RDD_STRTDATE
                  SDLSTRTTM            = RDD_STRTTIME
             EXCEPTIONS
                  CANT_START_IMMEDIATE = 1
                  INVALID_STARTDATE    = 2
                  JOBNAME_MISSING      = 3
                  JOB_CLOSE_FAILED     = 4
                  JOB_NOSTEPS          = 5
                  JOB_NOTEX            = 6
                  LOCK_FAILED          = 7
                  OTHERS               = 8.
        IF SY-SUBRC <> 0.
          MESSAGE S587 WITH RDD_JOBNAME.
        ENDIF.
        CLEAR RDD_PRDMONTHS.
      ENDIF.
    ELSE.
      MESSAGE S587 WITH RDD_JOBNAME.
    ENDIF.
  ELSE.
    MESSAGE S587 WITH RDD_JOBNAME.
  ENDIF.
ENDFORM.