Skip to Content

Ok, I know it needs a bit of cleaning up!  I’ll get to that.  In the meantime, I wanted the OP to have it available…

FORM create_job .

  DATA : jobname TYPE tbtcjob-jobname VALUE ‘Z_RDC_867_LOAD ‘,

         jobclass TYPE tbtcjob-jobclass VALUE ‘C’,

         jobcount TYPE tbtcjob-jobcount,

         lv_startdate LIKE sy-datum,

         lv_starttime LIKE sy-uzeit,

         authcknam TYPE tbtcjob-authcknam,

*         lv_varname TYPE rsvar-variant,

         lwa_vardesc TYPE varid .

  DATA: BEGIN OF gt_varid.

          INCLUDE STRUCTURE varid.

  DATA: END OF gt_varid.

  DATA: BEGIN OF gt_varit OCCURS 2.

          INCLUDE STRUCTURE varit.

  DATA: END OF gt_varit.

  DATA: BEGIN OF gt_rsparams OCCURS 0.

          INCLUDE STRUCTURE rsparams.

  DATA: END OF gt_rsparams.

  DATA  wa_recipient LIKE swotobjid.

*  break nwilhite.

  PERFORM get_distribucion_list USING    ‘Z_XXXXXXX’   ” name of List of distribution

                                CHANGING wa_recipient.

  authcknam = sy-uname.

  lv_startdate = sy-datum.

  lv_starttime = sy-uzeit + 300.

*  CONCATENATE  ‘ABAP’ lv_starttime INTO lv_varname.

  lwa_vardesc-report = ‘Z_YYYYYYYYYY’.

  CALL FUNCTION ‘JOB_OPEN’

    EXPORTING

      jobname          = jobname

      jobclass         = jobclass

    IMPORTING

      jobcount         = jobcount

    EXCEPTIONS

      cant_create_job  = 1

      invalid_job_data = 2

      jobname_missing  = 3

      OTHERS           = 4.

  IF sy-subrc = 0.

    CALL FUNCTION ‘JOB_SUBMIT’

      EXPORTING

        authcknam               = ‘BATCH_JOBS’ “authcknam

        jobcount                = jobcount

        jobname                 = jobname

        report                  = ‘Z_YYYYYYYYYY’

        variant                 = ‘INITIAL_LOAD’

      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.

    IF sy-subrc = 0.

* Jobstep to update Margin prices

      CALL FUNCTION ‘JOB_CLOSE’

        EXPORTING

          jobcount             = jobcount

          jobname              = jobname

          strtimmed            = ‘X’

*         sdlstrtdt            = ‘99991231’

*         sdlstrttm            = ‘010000’

          recipient_obj        = wa_recipient

        EXCEPTIONS

          cant_start_immediate = 1

          invalid_startdate    = 2

          jobname_missing      = 3

          job_close_failed     = 4

          job_nosteps          = 5

          job_notex            = 6

          lock_failed          = 7

          invalid_target       = 8

          OTHERS               = 9.

     ENDIF.

  ENDIF.

ENDFORM.                    ” CREATE_JOB

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply