理由:
ABAP开发异步RFC本来用的就少所以都不是很熟悉,而且异步RFC注意点较多特别是同时多次异步BUG更是数不胜数,
如上都是经验所谈,所以考虑抛转到后台JOB执行,
后台JOB的好处:
可以清楚的查看执行结果及执行内容代码很好简单
如下代码即可
DATA:g_number TYPE tbtcjob-jobcount,
g_name TYPE tbtcjob-jobname,
g_print_parameters TYPE pri_params VALUE ‘LP01’.
"创建已计划状态的JOB
CALL FUNCTION ‘JOB_OPEN’
EXPORTING
jobname = ‘后台JOB名称’
IMPORTING
jobcount = g_number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
"JOB内容
SUBMIT XXXXX 程序名称
WITH p_mat = '' "
WITH p_so = 'X'
WITH s_sonum IN it_vbeln[]
TO SAP-SPOOL "打印机参数设置
SPOOL PARAMETERS g_print_parameters "打印机格式
WITHOUT SPOOL DYNPRO
USER syst-uname
VIA JOB '后台JOB名称' NUMBER g_number
AND RETURN.
IF sy-subrc = 0.
"释放已计划的JOB,JOB状态为活动
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = g_number
jobname = '后台JOB名称'
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.