Displaying a list of All Jobs Using built in Function Modules Through Coding

 

  • Whenever we schedule / create any background job , it gets stored into TBTCO table.



  • Now If I see the contents of this table for the job which I have created in the previous part, I will be able to see all of its details.



  • Now, Suppose If someone asks you that, he wants to see all the job status that have been created till now in your SAP system without using TBTCO table.


Function modules that we can use to get JOB Status of all the background jobs :-

  • We have two function modules that we can use for the same purpose.

1. BP_JOB_SELECT

  • It will return us an internal table of al the jobs.


2. BP_JOBLIST_PROCESSOR

  • Then we can use BP_JOBLIST_PROCESSOR to display the status of all the jobs.

Solution :-

  • Step 1 :- Create a executable program in ABAP Editor.

  • Step 2 :- Call the BP_JOB_SELECT function module and pass all the necessary details, It will return the complete data from the TBTCO table.



  • Now you can use BP_JOBLIST_PROCESSOR function module to show the status of all these jobs in a list format.

  • For displaying jobs the JOBLIST_OPCODE = 22.




Code :-

*&---------------------------------------------------------------------*
*& Report ZAR_BACKGROUND
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZAR_BACKGROUND.

DATA : lt_jobs type table of TBTCJOB.

DATA : ls_jobselect type BTCSELECT.

ls_jobselect-jobname = '*'.
ls_jobselect-username = '*'.

CALL FUNCTION 'BP_JOB_SELECT'
  EXPORTING
    jobselect_dialog          = 'N'
   JOBSEL_PARAM_IN           = ls_jobselect
*   ENDDATE                   = '        '
*   NR_OF_JOBS_FOUND          =
  tables
    jobselect_joblist         = lt_jobs
*   JOBNAME_EXT_SEL           =
*   USERNAME_EXT_SEL          =
* CHANGING
*   ERROR_CODE                =
 EXCEPTIONS
   INVALID_DIALOG_TYPE       = 1
   JOBNAME_MISSING           = 2
   NO_JOBS_FOUND             = 3
   SELECTION_CANCELED        = 4
   USERNAME_MISSING          = 5
   OTHERS                    = 6
          .

CALL FUNCTION 'BP_JOBLIST_PROCESSOR'
  EXPORTING
    joblist_opcode                   = '22'
*   JOBLIST_REFR_PARAM               = ' '
* IMPORTING
*   JOBLIST_SEL_JOB                  =
  tables
    joblist                          = lt_jobs
* EXCEPTIONS
*   INVALID_OPCODE                   = 1
*   JOBLIST_IS_EMPTY                 = 2
*   JOBLIST_PROCESSOR_CANCELED       = 3
*   OTHERS                           = 4
          .

Execute the Program :-



Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Unlocking SAP ABAP Secrets: Interactive Classical Reports with GET CURSOR, At User Command, and a Comparison of HIDE Statements

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming