FORM run_background .
DATA:
lv_jobname TYPE tbtcjob–jobname.
DATA: lv_jobcount LIKE tbtcjob–jobcount,
lv_release(1) TYPE c.
lv_jobname = ‘jobname’.
CALL FUNCTION ‘JOB_OPEN’
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy–subrc <> 0.
MESSAGE ‘Open job error’ TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ELSE.
SUBMIT zprogram_name VIA JOB lv_jobname NUMBER lv_jobcount “USER ‘SAPBATCH’
WITH p_file = p_file
WITH rb_mrp = rb_mrp
WITH rb_scm = rb_scm
WITH rb_ops = rb_ops
WITH rb_prod = rb_prod
WITH p_test = p_test
WITH p_run = p_run
WITH p_bkgr = p_bkgr
AND RETURN.
CALL FUNCTION ‘JOB_CLOSE’
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = ‘X’
* SDLSTRTDT = ‘20211008’
* SDLSTRTTM = ‘235959’
* prdmins = 15
IMPORTING
job_was_released = lv_release
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
OTHERS = 9.
IF sy–subrc <> 0.
MESSAGE ‘Close job error’ TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
MESSAGE ‘Please check job jobname’ TYPE ‘S’.
ENDFORM.