创建后台作业

*****创建后台作业*********************
form. create_job using p_prgnm type applname
                      p_jobnm type TBTCJOB-JOBNAME
                      p_strtdate type TBTCJOB-SDLSTRTDT
                      p_strttime type TBTCJOB-SDLSTRTTM
                      p_months type TBTCJOB-PRDMONTHS
                      p_days type TBTCJOB-PRDDAYS
                      p_strtimm type BTCH0000-CHAR1.
data: lc_jobnum like TBTCJOB-JOBCOUNT,
      lt_par_tab TYPE STANDARD TABLE OF rsparams,
      ls_par_tab TYPE rsparams,
      ls_time type TBTCJOB-SDLSTRTTM.
* Create Job
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          =  p_jobnm
*      SDLSTRTDT        = '20120316'
*      SDLSTRTTM      = ls_time
    IMPORTING
      jobcount         = lc_jobnum
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    SUBMIT (p_prgnm)
          vIA JOB p_jobnm NUMBER lc_jobnum AND RETURN.
    IF sy-subrc EQ 0.
    "CLOSE JOB DEFINITION
    CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lc_jobnum
          jobname              = p_jobnm
          SDLSTRTDT            =  p_strtdate
          SDLSTRTTM            = p_strttime
          PRDMONTHS            = p_months
          PRDDAYS              = p_days
          strtimmed            = p_strtimm
        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.
      case sy-subrc .
        when 1. message w002(zsum).
        when 2. message w003(zsum).
        when 3. message w004(zsum).
        when 4. message w005(zsum).
        when 5. message w006(zsum).
        when 6. message w007(zsum).
        when 7. message w008(zsum).
        when 8. message w009(zsum).
        when 9. message w010(zsum).
      endcase.

    ENDIF.
  endif.
endform.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26168649/viewspace-731565/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26168649/viewspace-731565/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是在SAP中创建后台作业的代码示例: ```abap REPORT ztest_job_create. DATA: jobname LIKE tbtcp-jobname, jobcount LIKE tbtcp-jobcount, jobclass LIKE tbtcp-jobclass, jobd AS tbtcp-jobdynpro, jobhead LIKE tbtcp-jobhead, jobselect LIKE tbtcp-jobselect, jobstep LIKE tbtcp-jobstep, jobevent LIKE tbtcp-jobevent, jobpara LIKE tbtcp-jobpara, jobtarget LIKE tbtcp-jobtarget, jobclose LIKE tbtcp-jobclose. * 设置作业名称和作业计数器 jobname = 'ZTEST_JOB'. jobcount = '001'. * 设置作业类别 jobclass = 'A'. * 设置作业头信息 jobhead-stepname = 'STEP_1'. jobhead-progname = 'ZTEST_PROGRAM'. jobhead-jobname = jobname. jobhead-jobcount = jobcount. jobhead-jobclass = jobclass. * 设置作业步骤 jobstep-stepname = 'STEP_1'. jobstep-progname = 'ZTEST_PROGRAM'. jobstep-jobname = jobname. jobstep-jobcount = jobcount. jobstep-jobclass = jobclass. * 设置作业关闭信息 jobclose-jobname = jobname. jobclose-jobcount = jobcount. jobclose-jobclass = jobclass. * 创建作业 CALL FUNCTION 'JOB_OPEN' EXPORTING jobname = jobname jobcount = jobcount jobclass = jobclass EXCEPTIONS cant_create_job = 1 invalid_job_data = 2 jobname_missing = 3 others = 4. * 提交作业 CALL FUNCTION 'SUBMIT' EXPORTING report = 'ZTEST_PROGRAM' variant = '' direct = 'X' jobname = jobname jobcount = jobcount jobclass = jobclass EXCEPTIONS bad_variant = 1 cant_create_job = 2 invalid_report = 3 no_authority = 4 no_batch = 5 no_spool = 6 operation_cancelled = 7 others = 8. * 关闭作业 CALL FUNCTION 'JOB_CLOSE' EXPORTING jobclose = jobclose EXCEPTIONS job_close_failed = 1 others = 2. ``` 这段ABAP代码将创建一个名为`ZTEST_JOB`的后台作业,并在其中运行`ZTEST_PROGRAM`程序。你可以根据自己的需求修改作业名称、作业类别、程序名称等参数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值