点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
例如接口(PI等),使用RFC帐号,实际业务中,用户可能要求显示实际的创建人,而不是RFC帐号.
此需求可以使用后台作业方式解决. 注意USER关键字
REPORT YYY.
DATA: NUMBER TYPE TBTCJOB-JOBCOUNT,
NAME TYPE TBTCJOB-JOBNAME VALUE 'JOB_TEST',
PRINT_PARAMETERS TYPE PRI_PARAMS.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = NAME
IMPORTING
JOBCOUNT = NUMBER
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC = 0.
SUBMIT YYYY TO SAP-SPOOL
SPOOL PARAMETERS PRINT_PARAMETERS
WITHOUT SPOOL DYNPRO
USER 用户名
VIA JOB NAME NUMBER NUMBER
AND RETURN.
IF SY-SUBRC = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = NUMBER
JOBNAME = NAME
STRTIMMED = 'X'
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.
...
ENDIF.
ENDIF.
ENDIF.
REPORT YYYY.
WRITE SY-UNAME.
执行SM37 查看执行结果.
1).请注意"用户名"需要具有执行后台作业的权限.否则只会创建计划作业,并且sy-subrc = 8.
2)."用户名"必须为SAP 存在账户,否则后台将创建不完全计划作业.且作业不能释放