Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7189078
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-12-16 22:25:57

*&---------------------------------------------------------------------*
*& Report  Z_BARRY_SET_JOB                                             *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  设置后台Job,更多功能请看函数组:BTCH                              *
*&---------------------------------------------------------------------*

REPORT  z_barry_set_job                         .

DATA: jobcount LIKE tbtcjob-jobcount.
DATA: abort TYPE c,
      finish TYPE c,
      prelim TYPE c,
      ready TYPE c,
      run TYPE c,
      sched TYPE c.

PARAMETERS: p_name LIKE tbtcjob-jobname OBLIGATORY DEFAULT 'Z_BARRY_TEST_JOB',
            p_date LIKE sy-datum OBLIGATORY,
            p_time LIKE sy-uzeit OBLIGATORY.
SELECT-OPTIONS s_rept FOR sy-repid NO INTERVALS OBLIGATORY .

START-OF-SELECTION.
  CALL FUNCTION 'JOB_OPEN' "定义一个Job
    EXPORTING
      jobname          = p_name
    IMPORTING
      jobcount         = jobcount  "Job id
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  LOOP AT s_rept .
    CALL FUNCTION 'JOB_SUBMIT'  "Scheduled 这个Job
      EXPORTING
        authcknam               = sy-uname
        jobcount                = jobcount
        jobname                 = p_name
        report                  = s_rept-low
*        VARIANT                 = 'TEST'
      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.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'JOB_CLOSE'  "Release 这个Job
    EXPORTING
      jobcount             = jobcount
      jobname              = p_name
      sdlstrtdt            = p_date
      sdlstrttm            = p_time
    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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'SHOW_JOBSTATE'
    EXPORTING
      jobcount         = jobcount
      jobname          = p_name
    IMPORTING
      aborted          = abort
      finished         = finish
      preliminary      = prelim
      ready            = ready
      running          = run
      scheduled        = sched
    EXCEPTIONS
      jobcount_missing = 1
      jobname_missing  = 2
      job_notex        = 3
      OTHERS           = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  WRITE : / 'Canceled              :' , abort ,
          / 'Finished              :' , finish,
          / 'Scheduled Temporarily :' , prelim,
          / 'Ready for Execution   :' , ready,
          / 'Active                :' , run,
          / 'Scheduling Released   :' , sched.

阅读(11625) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-04-09 10:57:30

这个不好整吧。。。 有回TMS不好用了,发现是DDIC被锁了。。

chinaunix网友2010-04-09 10:55:03

我想请问一下白大哥 SAP的后台作业会因为帐号被锁定而无法执行 请问有什么解决办法呢? 就是说就算帐号被锁了 这个帐号下定制的后台作业仍然继续运行?