SAP后台JOB的Submit & EVENT JOB
SM35执行一个后台作业后,想及时停止,
运行SM37后,点击ctr + F1停止活动的作业,系统根本就没反应。
解决方法:
第一步:SM50,
找到,Ty.列为BGD的(Background),然后再找到你刚运行的那个后台Job的行,选中;然后在菜单点击:Process---Cancel with core. 即可。
第二步:SM37查看Background Job,应该为“取消”状态。
第三步:SM35,选中Session Name,点击小绿旗release即可。
http://blog.sina.com.cn/s/blog_76c57b480100rumm.html
How to define event background job in SAP?
以下为操作中会用到Function和T-code:
Function: BP_EVENT_RAISE
T-code:SM62、SM36、SM37
1. 首先来定义一个Event ID。
a.执行SM62
有关Event定义没有严格的要求,只要能辨别出是你的,用来触发那个Job就行了。
2. 为被触发程式(Program2)定义Background Job。
执行SM36(这里记录的是关键步骤,有疑问请复习一下SM36的使用。)
Start condition > After event >
通过红色标记选项处先出事先定义的Event,完成后保存。
3. 在触发程式(Program1)中调用激活触发事件的Function。
"以下是在程式开始定义的一个变量,也可以是一个常量。 PARAMETERS: P_EVENT(30) TYPE C OBLIGATORY DEFAULT 'Evt_TEST'. "以下是在程式最后定义的一个Group,也可以单一调用。 FORM AUTO_CREAT_WO_BY_GROUP. DATA: WRK_TIMES(2) TYPE C . DATA: WRK_EVENT(31) TYPE C . DO P_GROUP TIMES. WRK_TIMES = WRK_TIMES + 1. CONCATENATE P_EVENT WRK_TIMES INTO WRK_EVENT . CALL FUNCTION 'BP_EVENT_RAISE' EXPORTING EVENTID = WRK_EVENT OTHERS = 1 . ENDDO. ENDFORM.
* 操作步骤3,保证程式中定义常量或者变量中已定义的或者将要定义的Event值要和你通过SM62定义的Event名称要一致
JOB_SUBMIT 示例程序:设置后台Job,更多功能请看函数组:BTCH
1 *&---------------------------------------------------------------------* 2 *& Report Z_BARRY_SET_JOB * 3 *& * 4 *&---------------------------------------------------------------------* 5 *& 设置后台Job,更多功能请看函数组:BTCH * 6 *&---------------------------------------------------------------------* 7 8 REPORT z_barry_set_job . 9 10 DATA: jobcount LIKE tbtcjob-jobcount. 11 DATA: abort TYPE c, 12 finish TYPE c, 13 prelim TYPE c, 14 ready TYPE c, 15 run TYPE c, 16 sched TYPE c. 17 18 PARAMETERS: p_name LIKE tbtcjob-jobname OBLIGATORY DEFAULT 'Z_BARRY_TEST_JOB', 19 p_date LIKE sy-datum OBLIGATORY, 20 p_time LIKE sy-uzeit OBLIGATORY. 21 SELECT-OPTIONS s_rept FOR sy-repid NO INTERVALS OBLIGATORY . 22 23 START-OF-SELECTION. 24 CALL FUNCTION 'JOB_OPEN' "定义一个Job 25 EXPORTING 26 jobname = p_name 27 IMPORTING 28 jobcount = jobcount "Job id 29 EXCEPTIONS 30 cant_create_job = 1 31 invalid_job_data = 2 32 jobname_missing = 3 33 OTHERS = 4. 34 IF sy-subrc <> 0. 35 MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 36 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 37 ENDIF. 38 39 LOOP AT s_rept . 40 CALL FUNCTION 'JOB_SUBMIT' "Scheduled 这个Job 41 EXPORTING 42 authcknam = sy-uname 43 jobcount = jobcount 44 jobname = p_name 45 report = s_rept-low 46 * VARIANT = 'TEST' 47 EXCEPTIONS 48 bad_priparams = 1 49 bad_xpgflags = 2 50 invalid_jobdata = 3 51 jobname_missing = 4 52 job_notex = 5 53 job_submit_failed = 6 54 lock_failed = 7 55 program_missing = 8 56 prog_abap_and_extpg_set = 9 57 OTHERS = 10. 58 IF sy-subrc <> 0. 59 MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 60 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 61 ENDIF. 62 ENDLOOP. 63 64 CALL FUNCTION 'JOB_CLOSE' "Release 这个Job 65 EXPORTING 66 jobcount = jobcount 67 jobname = p_name 68 sdlstrtdt = p_date 69 sdlstrttm = p_time 70 EXCEPTIONS 71 cant_start_immediate = 1 72 invalid_startdate = 2 73 jobname_missing = 3 74 job_close_failed = 4 75 job_nosteps = 5 76 job_notex = 6 77 lock_failed = 7 78 OTHERS = 8. 79 IF sy-subrc <> 0. 80 MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 81 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 82 ENDIF. 83 84 CALL FUNCTION 'SHOW_JOBSTATE' 85 EXPORTING 86 jobcount = jobcount 87 jobname = p_name 88 IMPORTING 89 aborted = abort 90 finished = finish 91 preliminary = prelim 92 ready = ready 93 running = run 94 scheduled = sched 95 EXCEPTIONS 96 jobcount_missing = 1 97 jobname_missing = 2 98 job_notex = 3 99 OTHERS = 4. 100 IF sy-subrc <> 0. 101 MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 102 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 103 ENDIF. 104 105 WRITE : / 'Canceled :' , abort , 106 / 'Finished :' , finish, 107 / 'Scheduled Temporarily :' , prelim, 108 / 'Ready for Execution :' , ready, 109 / 'Active :' , run, 110 / 'Scheduling Released :' , sched.
后台作业信息存储在透明表TBTCP(批作业步骤概述)中,试图V_OP中。
函数组BTCH中有很多方法可以处理。
* 取后台作业记录
SELECT *
INTO TABLE LI_OP
FROM V_OP
WHERE JOBNAME LIKE 'ZPSMAM_RFC%'
AND SDLUNAME = SY-UNAME
AND ( STATUS = 'A' OR STATUS = 'F' ).
PS:台作业状态(STATUS)信息和参数对照如下:
1 Active STATUS = R
2 就绪 STATUS = Y
3 已调度的 STATUS = P
4 已释放 STATUS = S
5 已取消 STATUS = A
6 已完成 STATUS = F
7 批准/暂停 STATUS = Z
* 删除后台记录
LOOP AT LI_OP INTO LW_OP.
CALL FUNCTION 'BP_JOB_DELETE'
EXPORTING
JOBCOUNT = LW_OP-JOBCOUNT
JOBNAME = LW_OP-JOBNAME
* FORCEDMODE = ' '
* COMMITMODE = 'X'
。。。。。。。。。。。
ENDLOOP.
---------------------
作者:SAP剑客
来源:CSDN
原文:https://blog.csdn.net/zhongguomao/article/details/79091618
版权声明:本文为博主原创文章,转载请附上博文链接!