SM36是设置SAP周期性运行的事务码
来测试一下,首先先写一个程序:
我有一个zzp_people2的数据表.
DATA : INT1 TYPE I.
DATA : ITAB LIKE ZZP_PEOPLE2.
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
RAN_INT_MAX =
RAN_INT_MIN =
IMPORTING
RAN_INT = INT1
EXCEPTIONS
INVALID_INPUT =
OTHERS = .
ITAB-ZID = INT1.
ITAB-ZNAME = INT1 + .
ITAB-ZPASSWORD = INT1 + .
INSERT ZZP_PEOPLE2 FROM ITAB.
这段程序的作用,就是产生随机数,然后插入到表里面。
接下来是用SM36了:
回车
然后
回退
可以“立刻”
也可以“日期/时间” 填写“预定的启动”->“日期”->“时间”
去sm37看看:
这样,就会在后台运行了~~~可以测试一下。
*&---------------------------------------------------------------------*
*& 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 =
invalid_job_data =
jobname_missing =
OTHERS = .
IF sy-subrc <> .
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 =
bad_xpgflags =
invalid_jobdata =
jobname_missing =
job_notex =
job_submit_failed =
lock_failed =
program_missing =
prog_abap_and_extpg_set =
OTHERS = .
IF sy-subrc <> .
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 =
invalid_startdate =
jobname_missing =
job_close_failed =
job_nosteps =
job_notex =
lock_failed =
OTHERS = .
IF sy-subrc <> .
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 =
jobname_missing =
job_notex =
OTHERS = .
IF sy-subrc <> .
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.