Selecting and Deleting a Job

To delete a background job explicitly, use:

  • BP_JOB_SELECT to obtain the jobname and job number of the job that you wish to delete.

You can select jobs according to all of the criteria available in the interactive background processing management system:

    • Jobname: Using a well-planned naming convention for your jobs will help you to select them precisely.
    • Job number
    • Name of the user who scheduled a job
    • Specifications for the start-time window/no start time scheduled
    • Start dependent upon predecessor jobs
    • Start dependent upon an event and event argument
    • Job status (preliminary, scheduled, ready, running, finished, aborted).
  • BP_JOB_DELETE to delete the job. The job log is deleted as well, if the job has already been run.


A job cannot delete itself. Also, a job that is currently running cannot be deleted. However, you can have it deleted automatically if it is completed successfully. See the DELANFREP parameter of JOB_OPEN.

Sample Program: Deleting a Background Job

* Data declarations: BP_JOB_SELECT
*
DATA JSELECT LIKE BTCSELECT.

DATA SEL_JOBLIST LIKE TBTCJOB OCCURS 100 WITH HEADER LINE.

* Sample selection criteria
*
JSELECT-JOBNAME = 'Name of job'.
JSELECT-USERNAME = SY-UNAME.

CALL FUNCTION 'BP_JOB_SELECT'
EXPORTING
JOBSELECT_DIALOG = BTC_NO
JOBSEL_PARAM_IN = JSELECT
IMPORTING
JOBSEL_PARAM_OUT = JSELECT
TABLES
JOBSELECT_JOBLIST = SEL_JOBLIST
EXCEPTIONS NO_JOBS_FOUND = 1
SELECTION_CANCELED = 2
OTHERS = 99.
*
* In this example, the program loops over the internal table
* SEL_JOBLIST and deletes each of the jobs that was selected.
*
* Alternative: Have the user select the job to be deleted
* with BP_JOBLIST_PROCESSOR. For an example, please see
*
Sample Program: Wait for Predecessor Job with JOB_CLOSE.
*
LOOP AT SEL_JOBLIST.
CALL FUNCTION 'BP_JOB_DELETE'
EXPORTING
FORCEDMODE = 'X'
JOBNAME = SEL_JOBLIST-JOBNAME
JOBCOUNT = SEL_JOBLIST-JOBCOUNT
EXCEPTIONS
OTHERS = 99.
ENDLOOP.
*
*
* FORCEDMODE deletes the job header even if other portions of the
* job cannot be deleted from the TemSe facility, where they are
* held.

* FORCEDMODE can be used without fear of causing problems in the
* System. Any TemSe problem that affects background jobs can be
* resolved directly in the TemSe system and does not require the
* job header.

End of Content Area

No comments:

topics