form sub_bgdjob_process using i_damiid type char18
changing e_rc type i.
data l_jobname type tbtcjob-jobname.
data l_jobcount type tbtcjob-jobcount.
concatenate 'ZSAP' i_damiid into l_jobname.
condense l_jobname no-gaps.
" Create background id
call function 'JOB_OPEN'
exporting
jobname = l_jobname
jobclass = 'A'
importing
jobcount = l_jobcount
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if sy-subrc <> 0.
e_rc = 1.
else.
data: number type tbtcjob-jobcount,
print_parameters type pri_params.
" Run background job immediately
submit z06pmi0001 to sap-spool
destination space
immediately 'X'
keep in spool space
without spool dynpro
user sy-uname
via job l_jobname
number l_jobcount
and return.
" Close the background job
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = l_jobname
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.
endform. " SUB_BGDJOB_PROCESS