BeispieldokumentationProgrammbeispiel: Mit JOB_CLOSE auf Vorgänger-Job warten

 

Syntax Syntax

  1.  Start at successful completion of predecessor job. In this
    * example, the user selects the predecessor job from a list of
    * jobs. The jobs are selected with BP_JOB_SELECT and displayed
    * for selection to the user with BP_JOBLIST_PROCESSOR. 
    *
    * Important: If you specify a predecessor job directly in your 
    * program (not interactively chosen), then be sure that the 
    * predecessor job has the status Scheduled or Released when 
    * you schedule the successor job. Otherwise, the successor 
    * scheduling will fail. That is, a job that is active or 
    * already completed cannot be specified as a predecessor job. 
    *
    * Data declarations: BP_JOB_SELECT and BP_JOBLIST_PROCESSOR 
    * 
    DATA JSELECT LIKE BTCSELECT.
    DATA SEL_JOBLIST LIKE TBTCJOB OCCURS 100 WITH HEADER LINE. 
    DATA SELECTED_JOB LIKE TBTCJOB. 
    
    * Generate list of jobs as with the background processing
    * management transaction (SM37).
    
    * Sample selection criteria 
    * 
    JSELECT-JOBNAME = 'NAME OF JOB'. 
    JSELECT-JOBCOUNT = '<Job count>'. 
    JSELECT-USERNAME = SY-UNAME. 
    
    CALL FUNCTION 'BP_JOB_SELECT' 
    EXPORTING 
    JOBSELECT_DIALOG = BTC_YES " Display list to user
    JOBSEL_PARAM_IN = JSELECT " default job selection 
    " criteria
    IMPORTING 
    JOBSEL_PARAM_OUT = JSELECT " User’s job selection
    " criteria 
    TABLES 
    JOBSELECT_JOBLIST = SEL_JOBLIST 
    EXCEPTIONS 
    INVALID_DIALOG_TYPE = 1 
    JOBNAME_MISSING = 2 
    NO_JOBS_FOUND = 3 
    SELECTION_CANCELED = 4 
    USERNAME_MISSING = 5 
    OTHERS = 99. 
    *
    * Ask the user to pick a job from the list. The selected job is 
    * the predecessor job.
    * 
    call function 'BP_JOBLIST_PROCESSOR' 
    exporting 
    joblist_opcode = btc_joblist_select 
    " Starts processor in mode which 
    " allows user to pick a job from 
    " list. Selected job is returned 
    " in the joblist_sel_job parameter. 
    joblist_refr_param = jselect 
    " User's job selection parameters 
    " for Refresh function 
    importing 
    joblist_sel_job = selected_job 
    " Returns the job selected from the 
    " job list by the user. 
    tables 
    joblist = sel_joblist 
    " Input from BP_JOBLIST_SELECT 
    exceptions 
    invalid_opcode = 1 
    joblist_is_empty = 2 
    joblist_processor_canceled = 3 
    others = 4. 
    * 
    * Schedule job using the predecessor picked by the user.
    * 
    CALL FUNCTION 'JOB_CLOSE' 
    EXPORTING 
    JOBCOUNT = SELECTED_JOB-JOBCOUNT 
    " Job ID from BP_JOBLIST_PROCESSOR 
    JOBNAME = SELECTED_JOB-JOBNAME 
    " Job ID from BP_JOBLIST_PROCESSOR 
    PREDJOB_CHECKSTAT = 'X' " Start job only if 
    " predecessor job was 
    " successfully completed. 
    PRED_JOBCOUNT = SEL_JOBLIST-JOBCOUNT 
    " ID of predecessor job, 
    " from BP_JOB_SELECT. 
    PRED_JOBNAME = SEL_JOBLIST-JOBNAME 
    IMPORTING 
    JOB_WAS_RELEASED = JOB_RELEASED
    " Check: was job released? 
    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 = 99.
Ende des Codes