Getting Job-Start Specifications from Users

Use

You can use the BP_START_DATE_EDITOR function module to have your users specify when and how a job is to be started. The function module offers the same range of scheduling choices that a user has with the standard scheduling transaction: Immediate start, start window, predecessor job, event, and so on.

Sample Program

This section contains examples for BP_START_DATE_EDITOR and JOB_CLOSE.

* Data structure returned by BP_START_DATE_EDITOR 
* 
DATA STARTSPECS LIKE TBTCSTRT. 
DATA START_MODIFY_FLAG LIKE BTCH0000-INT4.
* 
* BP_START_DATE_EDITOR: Present user with pop-up window 
* requesting specifications for the job start. The user can 
* select from 
* - immediate start, 
* - start time and date and last time and date, 
* - start after event, 
* - start after activation of a new operating mode, 
* - start after predecessor job 
* - start on a certain workday of the month, counted from the 
* start or end of the month
* - specify how a job is to be handled if the start date falls 
* on a holiday.
* 
* All start date options are selectable by the user. To limit the 
* selection available to the user, you should program your own 
* input window. Or, you can evaluate TBTCSTRT-STRTDTTYP to see 
* if the user chose an appropriate start specification (see 
* below). 
*
* BP_START_DATE_EDITOR checks for plausibility and other errors in 
* user specifications and issues an error if any problems exist. 

* Use only the TBTCSTRT fields shown in the example below. Other 
* fields are reserved for internal use only. Do not set TBTCSTRT 
* fields directly. 
* 
CALL FUNCTION 'BP_START_DATE_EDITOR' 
EXPORTING 
STDT_DIALOG = BTC_YES " Module in interactive mode 
STDT_OPCODE = BTC_EDIT_STARTDATE " Edit mode 
STDT_INPUT = STARTSPECS " Table for user selections 
STDT_TITLE = 'Title' " Title for pop-up screen 
IMPORTING 
STDT_OUTPUT = STARTSPECS " User selections 
STDT_MODIFY_TYPE = START_MODIFY_FLAG 
" Flag: did user change start
* " specifications? Values: 
" - BTC_STDT_MODIFIED, 
" user did change specs 
" - BTC_STDT_NOT_MODIFIED, 
" user did not change specs 
EXCEPTIONS 
OTHERS = 99. 
* 
* Flag for specifying immediate start in JOB_CLOSE: For the 
* immediate-start case only, you must set a flag for communicating 
* the user selection to JOB_CLOSE. In all other cases, simply 
* pass the values returned by BP_START_DATE_EDITOR to JOB_CLOSE. 
* Those that were not set by the user have the value SPACE and 
* have no effect in JOB_CLOSE. 
* 
* Setting all JOB_CLOSE parameters is only permissible when you 
* use BP_START_DATE_EDITOR. Otherwise, you should set only the 
* required parameters in your call to JOB_CLOSE. 
* 
DATA: STARTIMMEDIATE LIKE BTCH0000-CHAR1. 

CASE STARTSPECS-STARTDTTYP. " Possible types are listed below. 
WHEN BTC_STDT_IMMEDIATE. " User selected immediate start. 
STARTIMMEDIATE = 'X'. 
WHEN BTC_STDT_DATETIME. " User entered start date and time 
WHEN BTC_STDT_EVENT. " User entered event and possibly 
" argument OR user selected start on 
" activation of a particular operation 
" mode (job start event driven in this
" case as well). 
<Optional error processing, if you wish to prevent user from 
scheduling a job dependent upon an event>

WHEN BTC_STDT_AFTERJOB. " User entered predecessor job.
<Optional error processing, if you wish to prevent user from 
scheduling a job dependent upon a predecessor job>
WHEN BTC_STDT_ONWORKDAY " User selected a job start on a 
" particular workday of the month.
ENDCASE. 
* 
* Use the start specifications provided by the user in JOB_CLOSE. 
* 
CALL FUNCTION 'JOB_CLOSE' 
EXPORTING 
JOBNAME = JOBNAME 
JOBCOUNT = JOBNUMBER 
STRTIMMED = STARTIMMEDIATE 
SDLSTRTDT = STARTSPECS-SDLSTRTDT 
SDLSTRTTM = STARTSPECS-SDLSTRTTM 
LASTSTRTDT = STARTSPECS-LASTSTRTDT 
LASTSTRTTM = STARTSPECS-LASTSTRTTM 
PRDDAYS = STARTSPECS-PRDDAYS " Non-zero values in 
PRDHOURS = STARTSPECS-PRDHOURS " any PRD* field mean 
PRDMINS = STARTSPECS-PRDMINS " that a startdate, 
PRDMONTHS = STARTSPECS-PRDMONTHS " starttime job is to 
PRDWEEKS = STARTSPECS-PRDWEEKS " be repeated 
" periodically.
TARGETSYSTEM = STARTSPECS-INSTNAME
* AT_OPMODE = Omit this parameter if you obtain user 
" specifications. It's set automatically by 
" BP_START_DATE_EDITOR. 
AT_OPMODE_PERIODIC = STARTSPECS-PERIODIC " Set with generic
" periodic flag in 
" table TBTCSTRT. 
PRED_JOBNAME = STARTSPECS-PREDJOB
PRED_JOBCOUNT = STARTSPECS-PREDJOBCNT
PREDJOB_CHECKSTAT = STARTSPECS-CHECKSTAT
EVENT_ID = STARTSPECS-EVENTID 
EVENT_PARAM = STARTSPECS-EVENTPARM 
EVENT_PERIODIC = STARTSPECS-PERIODIC " Set with generic
" periodic flag in 
" table TBTCSTRT. 
CALENDAR_ID = STARTSPECS-CALENDARID
STARTDATE_RESTRICTION = STARTSPECS-PRDBEHAV
START_ON_WORKDAY_NOT_BEFORE = STARTSPECS-NOTBEFORE 
START_ON_WORKDAY_NR = STARTSPECS-WDAYNO
WORKDAY_COUNT_DIRECTION = STARTSPECS-WDAYCDIR
" START_ON_WORKDAY jobs are scheduled 
" automatically for periodic execution if
" PRDMONTHS is set. 
IMPORTING
JOB_WAS_RELEASED = JOB_RELEASED
EXCEPTIONS 
OTHERS = 99.