SAP JOB_CLOSE Function Module for Close Background Request With COMMIT WORK
JOB_CLOSE is a standard job close SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Close Background Request With COMMIT WORK processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for job close FM, simply by entering the name JOB_CLOSE into the relevant SAP transaction such as SE37 or SE38.
Function Group: BTCH
Program Name: SAPLBTCH
Main Program: SAPLBTCH
Appliation area:
Release date: 08-May-1996
Mode(Normal, Remote etc): Normal Function Module
Update:
Function JOB_CLOSE pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'JOB_CLOSE'"Close Background Request With COMMIT WORK.
EXPORTING
* AT_OPMODE = ' ' "Job Start for Operation Mode: Operation Mode Name
* LASTSTRTTM = NO_TIME "No Start After: Time
* PRDDAYS = 0 "Day Portion of Job Repetition Period
* PRDHOURS = 0 "Minute Portion of Job Repetition Period
* PRDMINS = 0 "Hour Portion of Job Repetition Period
* PRDMONTHS = 0 "Month Portion of Job Repetition Period
* PRDWEEKS = 0 "Week Portion of Job Repetition Period
* PREDJOB_CHECKSTAT = ' ' "Start Job Only if Predecessor Runs Without Error
* PRED_JOBCOUNT = ' ' "Job Start After Predecessor Job: Predecessor Job Count
* PRED_JOBNAME = ' ' "Job Start After Predecessor Job: Predecessor Job Name
* SDLSTRTDT = NO_DATE "Start Date of Background Job
* AT_OPMODE_PERIODIC = ' ' "Job Start is Periodic According to Operation Mode
* SDLSTRTTM = NO_TIME "Time of Start Date of Background Job
* STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS "Restrictions for Start Date
* STRTIMMED = ' ' "Immediate Execution of Background Job
* TARGETSYSTEM = ' ' "Target System of Job
* START_ON_WORKDAY_NOT_BEFORE = SY-DATUM "Earliest Start Date for Start 'On Workday'
* START_ON_WORKDAY_NR = 0 "Number of Workday on Which Job is to Start
* WORKDAY_COUNT_DIRECTION = 0 "Direction of Workday Count
* RECIPIENT_OBJ = "The Mail Recipient of the Spool Lists
* TARGETSERVER = ' ' "Target Application Server for Job
* DONT_RELEASE = ' ' "Job Not Released in Spite of Start Condition
* CALENDAR_ID = ' ' "Factory Calendar ID for Start Date Restriction
* TARGETGROUP = ' ' "Target Application Server Group for Job
* DIRECT_START = "'X' - Start Without Converting to Time-Based Job
* EVENT_ID = ' ' "Job Start After Event: Event Name
* EVENT_PARAM = ' ' "Job Start After Event: Event Parameter
* EVENT_PERIODIC = ' ' "Job Start is Periodic According to Event
JOBCOUNT = "Job number
JOBNAME = "Job Name
* LASTSTRTDT = NO_DATE "No Start After: Date
IMPORTING
JOB_WAS_RELEASED = "= 'X', if Job Was Released
CHANGING
* RET = "Special Additional Error Code
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
IMPORTING Parameters details for JOB_CLOSE
AT_OPMODE - Job Start for Operation Mode: Operation Mode Name
Data type: SPFBA-BANAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
LASTSTRTTM - No Start After: Time
Data type: TBTCJOB-LASTSTRTTMDefault: NO_TIME
Optional: Yes
Call by Reference: No ( called with pass by value option)
PRDDAYS - Day Portion of Job Repetition Period
Data type: TBTCJOB-PRDDAYSOptional: Yes
Call by Reference: No ( called with pass by value option)
PRDHOURS - Minute Portion of Job Repetition Period
Data type: TBTCJOB-PRDHOURSOptional: Yes
Call by Reference: No ( called with pass by value option)
PRDMINS - Hour Portion of Job Repetition Period
Data type: TBTCJOB-PRDMINSOptional: Yes
Call by Reference: No ( called with pass by value option)
PRDMONTHS - Month Portion of Job Repetition Period
Data type: TBTCJOB-PRDMONTHSOptional: Yes
Call by Reference: No ( called with pass by value option)
PRDWEEKS - Week Portion of Job Repetition Period
Data type: TBTCJOB-PRDWEEKSOptional: Yes
Call by Reference: No ( called with pass by value option)
PREDJOB_CHECKSTAT - Start Job Only if Predecessor Runs Without Error
Data type: TBTCSTRT-CHECKSTATDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
PRED_JOBCOUNT - Job Start After Predecessor Job: Predecessor Job Count
Data type: TBTCJOB-JOBCOUNTDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
PRED_JOBNAME - Job Start After Predecessor Job: Predecessor Job Name
Data type: TBTCJOB-JOBNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
SDLSTRTDT - Start Date of Background Job
Data type: TBTCJOB-SDLSTRTDTDefault: NO_DATE
Optional: Yes
Call by Reference: No ( called with pass by value option)
AT_OPMODE_PERIODIC - Job Start is Periodic According to Operation Mode
Data type: BTCH0000-CHAR1Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
SDLSTRTTM - Time of Start Date of Background Job
Data type: TBTCJOB-SDLSTRTTMDefault: NO_TIME
Optional: Yes
Call by Reference: No ( called with pass by value option)
STARTDATE_RESTRICTION - Restrictions for Start Date
Data type: TBTCJOB-PRDBEHAVDefault: BTC_PROCESS_ALWAYS
Optional: Yes
Call by Reference: No ( called with pass by value option)
STRTIMMED - Immediate Execution of Background Job
Data type: BTCH0000-CHAR1Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
TARGETSYSTEM - Target System of Job
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
START_ON_WORKDAY_NOT_BEFORE - Earliest Start Date for Start 'On Workday'
Data type: TBTCSTRT-NOTBEFOREDefault: SY-DATUM
Optional: Yes
Call by Reference: No ( called with pass by value option)
START_ON_WORKDAY_NR - Number of Workday on Which Job is to Start
Data type: TBTCSTRT-WDAYNOOptional: Yes
Call by Reference: No ( called with pass by value option)
WORKDAY_COUNT_DIRECTION - Direction of Workday Count
Data type: TBTCSTRT-WDAYCDIROptional: Yes
Call by Reference: No ( called with pass by value option)
RECIPIENT_OBJ - The Mail Recipient of the Spool Lists
Data type: SWOTOBJIDOptional: Yes
Call by Reference: No ( called with pass by value option)
TARGETSERVER - Target Application Server for Job
Data type: BTCTGTSRVR-SRVNAMEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
DONT_RELEASE - Job Not Released in Spite of Start Condition
Data type: BTCH0000-CHAR1Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
CALENDAR_ID - Factory Calendar ID for Start Date Restriction
Data type: TBTCJOB-CALENDARIDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
TARGETGROUP - Target Application Server Group for Job
Data type: BPSRVGRPDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
DIRECT_START - 'X' - Start Without Converting to Time-Based Job
Data type: BTCH0000-CHAR1Optional: Yes
Call by Reference: No ( called with pass by value option)
EVENT_ID - Job Start After Event: Event Name
Data type: TBTCJOB-EVENTIDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EVENT_PARAM - Job Start After Event: Event Parameter
Data type: TBTCJOB-EVENTPARMDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EVENT_PERIODIC - Job Start is Periodic According to Event
Data type: BTCH0000-CHAR1Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
JOBCOUNT - Job number
Data type: TBTCJOB-JOBCOUNTOptional: No
Call by Reference: No ( called with pass by value option)
JOBNAME - Job Name
Data type: TBTCJOB-JOBNAMEOptional: No
Call by Reference: No ( called with pass by value option)
LASTSTRTDT - No Start After: Date
Data type: TBTCJOB-LASTSTRTDTDefault: NO_DATE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for JOB_CLOSE
JOB_WAS_RELEASED - = 'X', if Job Was Released
Data type: BTCH0000-CHAR1Optional: No
Call by Reference: No ( called with pass by value option)
CHANGING Parameters details for JOB_CLOSE
RET - Special Additional Error Code
Data type: IOptional: Yes
Call by Reference: Yes
EXCEPTIONS details
CANT_START_IMMEDIATE - Cannot Start Immediately
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
INVALID_STARTDATE - Start Condition is Invalid
Data type:Optional: No
Call by Reference: Yes
JOBNAME_MISSING - Job Name Missing (Wildcards Allowed)
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
JOB_CLOSE_FAILED - Error During JOB_CLOSE, See SYSLOG
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
JOB_NOSTEPS - Job Specified Does Not Contain Any Steps
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
JOB_NOTEX - Specified Job Does Not Exist
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
LOCK_FAILED - Lock Attempt Failed
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
INVALID_TARGET - Target Server or Group is Invalid
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for JOB_CLOSE Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.DATA: | ||||
lv_ret | TYPE I, " | |||
lv_at_opmode | TYPE SPFBA-BANAME, " SPACE | |||
lv_job_was_released | TYPE BTCH0000-CHAR1, " | |||
lv_cant_start_immediate | TYPE BTCH0000, " | |||
lv_laststrttm | TYPE TBTCJOB-LASTSTRTTM, " NO_TIME | |||
lv_prddays | TYPE TBTCJOB-PRDDAYS, " 0 | |||
lv_prdhours | TYPE TBTCJOB-PRDHOURS, " 0 | |||
lv_prdmins | TYPE TBTCJOB-PRDMINS, " 0 | |||
lv_prdmonths | TYPE TBTCJOB-PRDMONTHS, " 0 | |||
lv_prdweeks | TYPE TBTCJOB-PRDWEEKS, " 0 | |||
lv_predjob_checkstat | TYPE TBTCSTRT-CHECKSTAT, " SPACE | |||
lv_pred_jobcount | TYPE TBTCJOB-JOBCOUNT, " SPACE | |||
lv_pred_jobname | TYPE TBTCJOB-JOBNAME, " SPACE | |||
lv_sdlstrtdt | TYPE TBTCJOB-SDLSTRTDT, " NO_DATE | |||
lv_invalid_startdate | TYPE TBTCJOB, " | |||
lv_at_opmode_periodic | TYPE BTCH0000-CHAR1, " SPACE | |||
lv_sdlstrttm | TYPE TBTCJOB-SDLSTRTTM, " NO_TIME | |||
lv_startdate_restriction | TYPE TBTCJOB-PRDBEHAV, " BTC_PROCESS_ALWAYS | |||
lv_strtimmed | TYPE BTCH0000-CHAR1, " SPACE | |||
lv_targetsystem | TYPE BTCH0000, " SPACE | |||
lv_start_on_workday_not_before | TYPE TBTCSTRT-NOTBEFORE, " SY-DATUM | |||
lv_start_on_workday_nr | TYPE TBTCSTRT-WDAYNO, " 0 | |||
lv_workday_count_direction | TYPE TBTCSTRT-WDAYCDIR, " 0 | |||
lv_recipient_obj | TYPE SWOTOBJID, " | |||
lv_targetserver | TYPE BTCTGTSRVR-SRVNAME, " SPACE | |||
lv_dont_release | TYPE BTCH0000-CHAR1, " SPACE | |||
lv_calendar_id | TYPE TBTCJOB-CALENDARID, " SPACE | |||
lv_jobname_missing | TYPE TBTCJOB, " | |||
lv_targetgroup | TYPE BPSRVGRP, " SPACE | |||
lv_direct_start | TYPE BTCH0000-CHAR1, " | |||
lv_event_id | TYPE TBTCJOB-EVENTID, " SPACE | |||
lv_job_close_failed | TYPE TBTCJOB, " | |||
lv_event_param | TYPE TBTCJOB-EVENTPARM, " SPACE | |||
lv_job_nosteps | TYPE TBTCJOB, " | |||
lv_job_notex | TYPE TBTCJOB, " | |||
lv_event_periodic | TYPE BTCH0000-CHAR1, " SPACE | |||
lv_jobcount | TYPE TBTCJOB-JOBCOUNT, " | |||
lv_lock_failed | TYPE TBTCJOB, " | |||
lv_jobname | TYPE TBTCJOB-JOBNAME, " | |||
lv_invalid_target | TYPE TBTCJOB, " | |||
lv_laststrtdt | TYPE TBTCJOB-LASTSTRTDT. " NO_DATE |
  CALL FUNCTION 'JOB_CLOSE' "Close Background Request With COMMIT WORK |
EXPORTING | ||
AT_OPMODE | = lv_at_opmode | |
LASTSTRTTM | = lv_laststrttm | |
PRDDAYS | = lv_prddays | |
PRDHOURS | = lv_prdhours | |
PRDMINS | = lv_prdmins | |
PRDMONTHS | = lv_prdmonths | |
PRDWEEKS | = lv_prdweeks | |
PREDJOB_CHECKSTAT | = lv_predjob_checkstat | |
PRED_JOBCOUNT | = lv_pred_jobcount | |
PRED_JOBNAME | = lv_pred_jobname | |
SDLSTRTDT | = lv_sdlstrtdt | |
AT_OPMODE_PERIODIC | = lv_at_opmode_periodic | |
SDLSTRTTM | = lv_sdlstrttm | |
STARTDATE_RESTRICTION | = lv_startdate_restriction | |
STRTIMMED | = lv_strtimmed | |
TARGETSYSTEM | = lv_targetsystem | |
START_ON_WORKDAY_NOT_BEFORE | = lv_start_on_workday_not_before | |
START_ON_WORKDAY_NR | = lv_start_on_workday_nr | |
WORKDAY_COUNT_DIRECTION | = lv_workday_count_direction | |
RECIPIENT_OBJ | = lv_recipient_obj | |
TARGETSERVER | = lv_targetserver | |
DONT_RELEASE | = lv_dont_release | |
CALENDAR_ID | = lv_calendar_id | |
TARGETGROUP | = lv_targetgroup | |
DIRECT_START | = lv_direct_start | |
EVENT_ID | = lv_event_id | |
EVENT_PARAM | = lv_event_param | |
EVENT_PERIODIC | = lv_event_periodic | |
JOBCOUNT | = lv_jobcount | |
JOBNAME | = lv_jobname | |
LASTSTRTDT | = lv_laststrtdt | |
IMPORTING | ||
JOB_WAS_RELEASED | = lv_job_was_released | |
CHANGING | ||
RET | = lv_ret | |
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 | ||
. " JOB_CLOSE |
ABAP code using 7.40 inline data declarations to call FM JOB_CLOSE
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8."SELECT single BANAME FROM SPFBA INTO @DATA(ld_at_opmode). | ||||
DATA(ld_at_opmode) | = ' '. | |||
"SELECT single CHAR1 FROM BTCH0000 INTO @DATA(ld_job_was_released). | ||||
"SELECT single LASTSTRTTM FROM TBTCJOB INTO @DATA(ld_laststrttm). | ||||
DATA(ld_laststrttm) | = NO_TIME. | |||
"SELECT single PRDDAYS FROM TBTCJOB INTO @DATA(ld_prddays). | ||||
"SELECT single PRDHOURS FROM TBTCJOB INTO @DATA(ld_prdhours). | ||||
"SELECT single PRDMINS FROM TBTCJOB INTO @DATA(ld_prdmins). | ||||
"SELECT single PRDMONTHS FROM TBTCJOB INTO @DATA(ld_prdmonths). | ||||
"SELECT single PRDWEEKS FROM TBTCJOB INTO @DATA(ld_prdweeks). | ||||
"SELECT single CHECKSTAT FROM TBTCSTRT INTO @DATA(ld_predjob_checkstat). | ||||
DATA(ld_predjob_checkstat) | = ' '. | |||
"SELECT single JOBCOUNT FROM TBTCJOB INTO @DATA(ld_pred_jobcount). | ||||
DATA(ld_pred_jobcount) | = ' '. | |||
"SELECT single JOBNAME FROM TBTCJOB INTO @DATA(ld_pred_jobname). | ||||
DATA(ld_pred_jobname) | = ' '. | |||
"SELECT single SDLSTRTDT FROM TBTCJOB INTO @DATA(ld_sdlstrtdt). | ||||
DATA(ld_sdlstrtdt) | = NO_DATE. | |||
"SELECT single CHAR1 FROM BTCH0000 INTO @DATA(ld_at_opmode_periodic). | ||||
DATA(ld_at_opmode_periodic) | = ' '. | |||
"SELECT single SDLSTRTTM FROM TBTCJOB INTO @DATA(ld_sdlstrttm). | ||||
DATA(ld_sdlstrttm) | = NO_TIME. | |||
"SELECT single PRDBEHAV FROM TBTCJOB INTO @DATA(ld_startdate_restriction). | ||||
DATA(ld_startdate_restriction) | = BTC_PROCESS_ALWAYS. | |||
"SELECT single CHAR1 FROM BTCH0000 INTO @DATA(ld_strtimmed). | ||||
DATA(ld_strtimmed) | = ' '. | |||
DATA(ld_targetsystem) | = ' '. | |||
"SELECT single NOTBEFORE FROM TBTCSTRT INTO @DATA(ld_start_on_workday_not_before). | ||||
DATA(ld_start_on_workday_not_before) | = SY-DATUM. | |||
"SELECT single WDAYNO FROM TBTCSTRT INTO @DATA(ld_start_on_workday_nr). | ||||
"SELECT single WDAYCDIR FROM TBTCSTRT INTO @DATA(ld_workday_count_direction). | ||||
"SELECT single SRVNAME FROM BTCTGTSRVR INTO @DATA(ld_targetserver). | ||||
DATA(ld_targetserver) | = ' '. | |||
"SELECT single CHAR1 FROM BTCH0000 INTO @DATA(ld_dont_release). | ||||
DATA(ld_dont_release) | = ' '. | |||
"SELECT single CALENDARID FROM TBTCJOB INTO @DATA(ld_calendar_id). | ||||
DATA(ld_calendar_id) | = ' '. | |||
DATA(ld_targetgroup) | = ' '. | |||
"SELECT single CHAR1 FROM BTCH0000 INTO @DATA(ld_direct_start). | ||||
"SELECT single EVENTID FROM TBTCJOB INTO @DATA(ld_event_id). | ||||
DATA(ld_event_id) | = ' '. | |||
"SELECT single EVENTPARM FROM TBTCJOB INTO @DATA(ld_event_param). | ||||
DATA(ld_event_param) | = ' '. | |||
"SELECT single CHAR1 FROM BTCH0000 INTO @DATA(ld_event_periodic). | ||||
DATA(ld_event_periodic) | = ' '. | |||
"SELECT single JOBCOUNT FROM TBTCJOB INTO @DATA(ld_jobcount). | ||||
"SELECT single JOBNAME FROM TBTCJOB INTO @DATA(ld_jobname). | ||||
"SELECT single LASTSTRTDT FROM TBTCJOB INTO @DATA(ld_laststrtdt). | ||||
DATA(ld_laststrtdt) | = NO_DATE. | |||
Search for further information about these or an SAP related objects