SAP Focused Run batch job monitoring overview

This blog will explain SAP Focused Run capabilities for batch job monitoring. The first part of the blog explains the functional capabilities. The second part covers the technical setup of batch job monitoring.

Batch job monitoring

Batch job monitoring in SAP Focused Run is part of Job and Automation monitoring:

After opening the start screen and selecting the scope you get the total overview:

Click on the top round red errors to zoom in to the details (you can’t drill down on the cards below):

Click on the job to zoom in:

Systems overview

Click on the system monitoring button:

On the screen, zoom out on the overview by clicking the blue Systems text top left:

Now you get the overview per system:

Batch job analysis

Batch job analysis is a powerful function. Select it in the menu:

Result screen shows 1 week data by default:

The default sorting is on total run time.

Useful sortings:

  1. Total run time: find the jobs that run long in your system in total. These most likely will also be the ones that cause high load, or business is waiting long for to finish to give results.
  2. Average run time: find the jobs that take on average long time to run. By optimizing the code or batch job variant, the run time can be improved.
  3. Failure rate: find the jobs that fail with a high %. Get the issues known and then address them.
  4. Total executions: some jobs might simply be planned too frequently. Reduce the run frequency.

By clicking on the job trend icon at the end of the line you jump to the trend function.

Job trend function

From the analysis screen or by selecting the Trend graph button you reach the job trend function:

Select the job and it will show the trend for last week:

You can see if execution went fine, or not, and bottom right see average time the job took to complete.

Technical setup of job monitoring

For batch job monitoring settings, open the configuration and start with the global settings:

Here you can see the data volume used and set the retention time for how long aggregated data is kept.

You can also set generic rating rules:

Activation per system

In the activation per system select the system and it will open the details:

First switch on the generic activation for each system

Activation for specific jobs to be monitored

Now you can start creating a job group. First select left Job groups, then the Plus button top right:

Add a job by clicking the plus button and search for the job:

Press Save to add the job to the monitoring.

Grouping logic

You can group jobs per logical block. For example you can group all basis jobs, all Finance jobs, etc. Or you can group jobs per system. Choice is up to you. Please read first the part on alerting. This might make you reconsider the grouping logic.

Adding alerting to job monitor

The jobs added to the group are monitored. But alerting is a separate action.

Go to the Alerting part of the job group. And an alert. First select the Alert type (critical status, delay, runtime, missing a job). Assign a notification variant (who will get the alert mail), and decide on alert grouping or atomic alerts.

If you do not specify a filter it will apply for the complete group. You can also apply a filter here to select a sub group of the job group.

Based on the alerting you might want to reconsider the grouping.

Monitoring Number of Long Running Jobs

In SAP Focused Run there is no standard way of monitoring number of long running jobs either in System Monitoring or in Job Monitoring

With Job Monitoring you can monitor if a specific job is running for more than specific amount of time, but we can’t monitor if there are more than a specific number of jobs that are running for more than a specific amount of time.

And in System monitoring we can only monitor if there are more than a specific number of cancelled jobs or job in status running but we can’t monitor long running jobs.

However, the Focused Run Guided Procedure Framework provides a pre-build plugin by which you can create a custom guided procedure to check the number of long running batch jobs in a managed system.

Setup of long running jobs

To access Guided Procedures App navigate to Advanced System Management area on the Focused Run launchpad and click on the System Management Guided Procedure App.

Then on the Guided Procedure app navigate to Guided Procedure Catalog page.

On the Catalog Page click on the + button to create a new custom guided procedure.

In the next pop-up screen provide a name and description. Optionally you need to select a package if you want to transport your guided procedures e.g. from DEV Focused Run system to PROD Focused Run system.

Then back in the Guided Procedure Catalog screen click on the guided procedure you just created to open it for editing.

In the guided procedure edit screen click on Edit button.

In the Properties section provide a name for the step and a description as shown below.

Then in the Step Content section click on New button to add a step.

In the next popup select the plugin ABAP Long Running Jobs and provide the threshold for time range as long running Job. You can also specify the graphic type as a table or as a bar chart. After selecting, click on Ok button to continue.

Then Save and Activate the custom guided procedure.

Now your custom guided procedure is available for execution.

Go back to Guided Procedures Instances page to execute your guided procedure. Click on the + button to start a new execution.

In the next popup, select the guided procedure you just created and then click on + button to add managed systems for scope of execution.

After selecting the managed system click on Perform Manually to create the instance of the guided procedure for the selected scope.

Then click on the instance to start the guided procedure page.

Click on Perform to execute the guided procedure.

Now you will see the result as shown below.

For more information regarding available plugins you can refer the SAP documentation here.

Relevant OSS notes

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans and Manas Tripathy (Simac). Repost done with permission. >>

Reading content data from batch job variants

In quite some cases the basis team is asked: in which batch job variant is this company code XXXX used? Or we need to add another sales organization to all the batch jobs, can you provide us a list with jobs using sales organization YYYY?

Some hints are given in this blog.

But no real solution.

Continue reading for a custom code solution!

Custom program to scan batch job variant content

If you load the program in the next section, create texts so that the start screen looks like this:

First test program on small batch of programs with know variants.

Example search all programs starting with ZA for the variant text US:

Result is list of program and variants with the key word:

Custom program coding

*&---------------------------------------------------------------------*
*& Report ZVARSEARCH
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZVARSEARCH.

* _____________________________________________________________________
*|                              T A B L E S                            |
* Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
TABLES: trdir, tadir.

* _____________________________________________________________________
*|                              T Y P E S                              |
* Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
TYPES: BEGIN OF ty_source,
         line(255) TYPE c,
       END OF ty_source.

TYPES: BEGIN OF ty_objname,
         obj_name TYPE sobj_name,
       END OF ty_objname.

TYPES: BEGIN OF ty_variant,
         variant TYPE variant,
       END OF ty_variant.

* _____________________________________________________________________
*|              I T A B S  & W O R K A R E A S                         |
* Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
DATA: gt_selop       TYPE STANDARD TABLE OF    vanz,
      gt_params      TYPE STANDARD TABLE OF    vanz,
      gt_params_nonv TYPE STANDARD TABLE OF    vanz,
      gt_selop_nonv  TYPE STANDARD TABLE OF    vanz,
      gs_vanz        TYPE                      vanz,
      lv_text        TYPE                      string,
      gv_report      TYPE                      vari_reprt,
      mv_report      TYPE                      vari_reprt,
      gt_variant     TYPE STANDARD TABLE OF    ty_variant,
      gs_variant     TYPE                      ty_variant,
      gv_program     TYPE                      syrepid,
      gv_subrc       TYPE                      sysubrc,
      gt_reports     TYPE STANDARD TABLE OF    trdir,
      gs_reports     TYPE                      trdir,
      gt_valuetab    TYPE STANDARD TABLE OF    rsparams,
      gt_objname     TYPE STANDARD TABLE OF    ty_objname.

FIELD-SYMBOLS:
      <fs_vanz>      TYPE vanz.
* _____________________________________________________________________
*|                 S E L E C T I O N - S C R E E N                     |
* Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
SELECTION-SCREEN BEGIN OF BLOCK aa WITH FRAME.
SELECTION-SCREEN BEGIN OF BLOCK bb WITH FRAME TITLE text-t01.
PARAMETERS:     ra_srch   RADIOBUTTON GROUP a1
                             USER-COMMAND tab1 DEFAULT 'X',
                ra_srch2  RADIOBUTTON GROUP a1,
                ra_wday   RADIOBUTTON GROUP a1,
                ra_synt   RADIOBUTTON GROUP a1,
                ch_all   AS CHECKBOX  MODIF ID a2.
SELECTION-SCREEN END OF BLOCK bb.
SELECT-OPTIONS: so_prog   FOR trdir-name.
PARAMETERS:     p_string  TYPE s_text       MODIF ID a1.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK cc WITH FRAME.
PARAMETERS:     pa_prog   TYPE program,
                pa_local  AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK cc.
SELECTION-SCREEN END OF BLOCK aa.

* _____________________________________________________________________
*|           A T  S E L E C T I O N - S C R E E N  O U T P U T         |
* Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.
    CASE screen-group1.
      WHEN 'A1'.

        IF ra_srch  IS INITIAL
        AND ra_srch2 IS INITIAL.
          CLEAR p_string.
          screen-input = '0'.
        ELSE.
          screen-input = '1'.
        ENDIF.
      WHEN 'A2'.
        IF ra_synt = 'X'.
          screen-input = '1'.

        ELSE.
          CLEAR ch_all.
          screen-input = '0'.
        ENDIF.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.

* _____________________________________________________________________
*|                 S T A R T - O F - S E L E C T I O N                 |
* Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
START-OF-SELECTION.
  IF ( NOT ra_srch  IS INITIAL OR NOT ra_srch2 IS INITIAL )
  AND p_string IS INITIAL.
    MESSAGE e001(00) WITH 'No string entered'.
  ENDIF.

  PERFORM select_programs.
  PERFORM select_variants.

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Form  SELECT_PROGRAMS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM select_programs.

  DATA: lv_tabix   TYPE   sytabix,
        lv_lines   TYPE   i.

*-Only executable programs are taken into account
  IF ch_all IS INITIAL.
    SELECT * FROM trdir
       INTO TABLE gt_reports
         WHERE name IN so_prog
                     AND subc = '1'.

*-For syntax checking you can also include other program types
  ELSE.
    SELECT * FROM trdir
      INTO TABLE gt_reports
        WHERE name IN so_prog.
  ENDIF.

  SORT gt_reports BY name.
  DESCRIBE TABLE gt_reports LINES lv_lines.

*-check if the user wants to start from a certain program
*-(so skip all preceding programs)
  IF NOT pa_prog IS INITIAL.

    READ TABLE gt_reports WITH KEY name = pa_prog
     TRANSPORTING NO FIELDS.
    IF sy-subrc = 0.
      lv_tabix = sy-tabix + 1.
      IF lv_tabix < lv_lines.
*-      Delete all preceding reports including the start from report
        DELETE gt_reports FROM 1 TO lv_tabix.
      ENDIF.
    ENDIF.

  ENDIF.

  IF gt_reports[] IS INITIAL.
    MESSAGE s001(00) WITH 'No reports selected'.
    WRITE:/ 'No reports selected'.
  ENDIF.

ENDFORM.                    " SELECT_PROGRAMS
*&---------------------------------------------------------------------*
*&      Form  SELECT_VARIANTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM select_variants .

  DATA: lt_results     TYPE STANDARD TABLE OF rsvobs,
        lv_found       TYPE                   flag.

  REFRESH gt_objname.

  CHECK NOT gt_reports[] IS INITIAL.

*-retrieve already all details for quicker reading
  IF pa_local = 'X'.                         "Exclude local programs
    SELECT obj_name INTO TABLE gt_objname
      FROM tadir
      FOR ALL ENTRIES IN gt_reports
      WHERE pgmid = 'R3TR'
        AND object = 'PROG'
        AND obj_name = gt_reports-name.
  ELSE.                                      "Include local programs
    SELECT obj_name INTO TABLE gt_objname
      FROM tadir
      FOR ALL ENTRIES IN gt_reports
      WHERE pgmid = 'R3TR'
        AND object = 'PROG'
        AND obj_name = gt_reports-name
        AND devclass <> '$TMP'.
  ENDIF.

  LOOP AT gt_reports INTO gs_reports.

    READ TABLE gt_objname
      WITH KEY obj_name = gs_reports-name
        TRANSPORTING NO FIELDS.
    CHECK sy-subrc = 0.

    gv_program = gv_report = gs_reports-name.

*=====================================================================*
*-  PERFORM A SYNTAX CHECK FOR PROGRAM
*=====================================================================*
*-  Get the source code of the report for syntax checking
    PERFORM program_syntax_check USING    gv_program
                                 CHANGING gv_subrc.

*-  Skip programs with syntax errors for further variant checking
    IF gv_subrc <> 0.
      IF ra_synt = 'X'.
        MESSAGE s000(3w) WITH 'SYNTAX ERROR==>' gv_report.
        WRITE:/      gv_report,
                  50 'CONTAINS SYNTAX ERROR'.
      ELSE.
        CONTINUE.
      ENDIF.
    ENDIF.

*---------------------------------------------------------------------*
*-  Only process variants for select-options search and working days
*---------------------------------------------------------------------*
    CHECK ra_srch = 'X' OR ra_srch2 = 'X' OR ra_wday = 'X'.

*-  Select variants for a program
*-  (exclude the very old ones and also the standard SAP ones)
    SELECT variant INTO TABLE gt_variant
      FROM varid
          WHERE report = gv_report
            AND ( edat > 20100101  OR  aedat > 20100101 )
            AND ( ename <> 'SAP'   AND aename <> 'SAP'  ).

    CHECK NOT gt_variant[] IS INITIAL.
    REFRESH lt_results.

*-  Process all variants
    LOOP AT gt_variant INTO gs_variant.
      CLEAR lv_found.

*-    Give a message to indicate which program/variant is being checked
*-    (comes in handy in case the program cancels during the check as
*-    you can then restart this program starting from the object that
*-    dumped)
      MESSAGE s000(3w) WITH 'Checking' gv_report '-' gs_variant-variant.

      CALL FUNCTION 'RS_VARIANT_CONTENTS'
        EXPORTING
          report                      = gv_report
          variant                     = gs_variant-variant
          no_import                   = ' '
          execute_direct              = ''
        TABLES
          l_params                    = gt_params
          l_params_nonv               = gt_params_nonv
          l_selop                     = gt_selop
          l_selop_nonv                = gt_selop_nonv
          valutab                     = gt_valuetab
       EXCEPTIONS
         variant_non_existent        = 1
         variant_obsolete            = 2
         OTHERS                      = 3.

      CHECK sy-subrc = 0.

*=====================================================================*
*-    SEARCH VARIANTS FOR A CERTAIN FIELD VALUE
      IF ra_srch = 'X'.
*=====================================================================*
        FIND FIRST OCCURRENCE OF p_string
        IN TABLE gt_valuetab
        IN CHARACTER MODE.
        IF sy-subrc = 0.
          CONCATENATE 'String' p_string 'found'
             INTO lv_text SEPARATED BY space.
          MESSAGE s000(3w) WITH 'FOUND:' gv_report
                                gs_variant-variant lv_text.

          WRITE:/   'FOUND:',
                  7 gv_report,
                 50 gs_variant-variant,
                 80 lv_text.
        ENDIF.

*=====================================================================*
*-    SEARCH VARIANTS FOR A CERTAIN FIELD NAME OR FIELD DESCRIPTION
      ELSEIF ra_srch2 = 'X'.
*=====================================================================*
*-      Check select-options field names and descriptions for a
*-      certain string
        LOOP AT gt_selop ASSIGNING <fs_vanz>.
          FIND FIRST OCCURRENCE OF  p_string
          IN <fs_vanz>-name IN CHARACTER MODE.
          IF sy-subrc = 0.
            lv_found ='X'.
            EXIT.
          ENDIF.
        ENDLOOP.

        IF lv_found IS INITIAL.
          LOOP AT gt_selop_nonv ASSIGNING <fs_vanz>.
            FIND FIRST OCCURRENCE OF  p_string
            IN <fs_vanz>-name IN CHARACTER MODE.
            IF sy-subrc = 0.
              lv_found ='X'.
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.

        IF lv_found IS INITIAL.
          LOOP AT gt_params  ASSIGNING <fs_vanz>.
            FIND FIRST OCCURRENCE OF p_string
            IN <fs_vanz>-name IN CHARACTER MODE.

            IF sy-subrc = 0.
              lv_found ='X'.
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.

        IF lv_found IS INITIAL.
          LOOP AT gt_params_nonv  ASSIGNING <fs_vanz>.
            FIND FIRST OCCURRENCE OF p_string
            IN <fs_vanz>-name IN CHARACTER MODE.

            IF sy-subrc = 0.
              lv_found ='X'.
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.

        IF lv_found = 'X'.
          CONCATENATE 'String' p_string 'found'
                      INTO lv_text SEPARATED BY space.
          MESSAGE s000(3w) WITH 'FOUND:' gv_report
                                gs_variant-variant lv_text.
          WRITE:/   'FOUND:',
                  7 gv_report,
                 50 gs_variant-variant,
                 80 lv_text.
        ENDIF.

*=====================================================================*
*-    SEARCH VARIANTS FOR VARIABLES THAT REQUIRE CALENDAR ENTRY
      ELSEIF ra_wday = 'X'.
*=====================================================================*
        LOOP AT gt_selop INTO gs_vanz
             WHERE vname <> ''.
          IF gs_vanz-vname CS 'XWD' OR gs_vanz-vname CS 'WDAY'.
            lv_found ='X'.
            EXIT.
          ENDIF.
        ENDLOOP.
        IF lv_found IS INITIAL.
          LOOP AT gt_selop_nonv INTO gs_vanz
               WHERE vname <> ''.
            IF gs_vanz-vname CS 'XWD' OR gs_vanz-vname CS 'WDAY'.
              lv_found ='X'.
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.
        IF lv_found IS INITIAL.
          LOOP AT gt_params INTO gs_vanz
               WHERE vname <> ''.
            IF gs_vanz-vname CS 'XWD' OR gs_vanz-vname CS 'WDAY'.
              lv_found ='X'.
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.
        IF lv_found IS INITIAL.
          LOOP AT gt_params_nonv INTO gs_vanz
               WHERE vname <> ''.
            IF gs_vanz-vname CS 'XWD' OR gs_vanz-vname CS 'WDAY'.
              lv_found ='X'.
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.

        IF lv_found = 'X'.
          MESSAGE s000(3w) WITH 'FOUND:' gv_report gs_variant-variant
                                'Calendar logic present'.
          WRITE:/   'FOUND:',
                  8 gv_report,
                 50 gs_variant-variant,
                 80 'Calendar logic present'.

        ENDIF.

      ENDIF.

    ENDLOOP.

  ENDLOOP.

ENDFORM.                    " SELECT_VARIANTS
*&---------------------------------------------------------------------*
*&      Form  PROGRAM_SYNTAX_CHECK
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_LV_SUBRC  text
*----------------------------------------------------------------------*
FORM program_syntax_check   USING    p_program
                            CHANGING p_subrc.

  DATA: lt_source    TYPE STANDARD TABLE OF    ty_source.

  CLEAR p_subrc.
  REFRESH lt_source.

  READ REPORT gv_program INTO lt_source.

  CALL FUNCTION 'RS_SYNTAX_CHECK'
    EXPORTING
      i_program        = p_program
    IMPORTING
      o_error_subrc    = p_subrc
    TABLES
      i_source         = lt_source.

ENDFORM.                    " PROGRAM_SYNTAX_CHECK

Find batch jobs with deleted or locked step users

If a batch job step user is locked or deleted, that step will fail. To find batch jobs with deleted or locked step users, start program BTCAUX09:

This will give a full list of jobs that you might want to start analyzing for deletion:

Why clean up? You will most likely find a lot of jobs in Scheduled status that never ran and are planned very long time ago. All batch job related transactions will have to plough through this irrelevant data.

OSS notes

Notes:

Batch job result distribution

When a batch job finishes, there are use cases where you want to be informed on the results.

Questions that will be answered in this blog are:

  • How can I mail the spool result of a batch job?
  • How can I mail if the job went ok or not?

Mailing job status

As of version S4HANA 1709 (basis version 7.52), you can mail the batch job result for cancelled jobs, or in all cases when it finishes. In SM37 after job is planned goto change mode of the job and push the E-mail Notification button:

In case of issues check OSS note 2951767 – E-mail notifications are not sent.

Mailing spool result

For mailing spool results use the Spool List Recipient button:

On older systems there might be a cutoff after 1000 lines in the mail. See OSS note 329537 – Spool cut off at 1000 lines when sent to recipient. In case of issues, you can check OSS note 760838 – Spool lists are not sent and 930570 – Problems with sent OTF documents.

Mailing spool result to multiple mail addresses

In transaction SO15 create a distribution list:

Hit the create button to create a distribution list:

Goto the tab Dist. list content to enter the e-mail addresses:

Save the list.

Now you can go to SM37 and change the job:

In the recipient field hit F4 or the selection button and switch to the distribution list. Search the correct one and press ok:

In case somebody by accident deleted a shared distribution list, check OSS note 2477819 – Distribution Lists have been deleted for recovery options.

Bug fixes

Bug fix OSS notes:

S4HANA standard batch jobs

In S4HANA standard jobs are scheduled in a different way.

This blog will answer the following questions:

  • How to see then new standard jobs via transaction SJOBREPO?
  • Where to find more information on more advanced functions?
  • Which background OSS notes can I read on the S4HANA stand batch job repository?
  • I have done a change to SJOBREPO and it is not visible? (it takes up to 1 hour!)

Viewing the job repository

Start transaction SJOBREPO to view the job repository:

The jobs running are different per release. Check the corresponding note. Example for S4HANA 2020: 2992214 – Jobs in the Technical Job Repository (SJOBREPO) in SAP S/4HANA 2020.

Use transaction SWF_JOBREPO_SLG1 to see logs of potential job issues.

To assign a standard user to job steps use transaction SJOBREPO_STEPUSER to set standard job step user:

See OSS notes

Checking the activation status of SJOBREPO

With program R_JR_UTIL_1 you can check the current status of SJOBREPO or activate it:

See OSS note 2790150 – Automatic Job Scheduling is switched off.

Activation and monitoring

In SJOBREPO, more background information can be found by clicking the button Monitor help:

A very important remark is made here that it can take up to 1 hour before changes to SJOBREPO are visible in the monitoring overview. This is a very annoying feature.

Advanced functions in SJOBREPO

All the advanced configuration functions of the S4HANA job repository can be found as PDF attachment to OSS note 2190119 – Background information about S/4HANA technical job repository.

Activation of server group for technical job repository

Apply OSS note 3057980 – Targetservergroups in SJOBREPO in Release 7.55 to get the function for server groups for the technical job repository.

Scope dependent jobs

In customizing you can activate scope dependent jobs:

See also OSS note 3085988 – Technical job is not getting schedule in S/4HANA SJOBREPO because the job is showing as ‘Not in Scope’.

Background OSS notes

Useful background OSS notes:

Bug fix notes:

Debug batch programs

This blog will explain how to debug a background batch program with real background mode (SY-BATCH is X).

Questions that will be answered are:

  • How to debug a running job?
  • How to debug a completed job?

Starting the debug mode for batch job

First we plan a single run of the batch job. In our example we run program RSWAITSEC which does nothing more than wait.

In SM37 show the job run:

Select the job and in the command line enter the background debug command JDBG:

Now the debugger starts first in the batch job part. Hit F7 a few time (F7 = jump back out of routine) until you reach the real program:

As you can see here the SY-BATCH variable is X, which means you are debugging with real background mode on.

SM50 background debugging

If you want to debug a running job, you have to goto SM50 and select the background process. Then choose the menu option Administration / Program / Debugging. Confirm the prompt:

Wait until the running SQL statement has completed and debug mode will start.

Please be very careful with this kind of debugging in a productive system. If you cancel the debug session there might be a rollback work statement triggered, which can cause database inconsistencies.

Reference notes

573128 – Debugging programs in the background

Batch jobs tips & tricks

This blog will give tips and tricks on batch jobs.

Questions that will be answered are:

  • How to check a job is not running already before starting new one?
  • How to build in a wait step into a batch job?
  • How to set the RV variables automatically in table TVARVC?
  • How to validate that the basic batch job system is working ok?
  • How to analyze the jobs running in my system?
  • How to mass stop and start batch jobs?
  • How to set up batch job interception?
  • How to ignore large spool output of batch jobs?
  • How to see the batch job delay timing?
  • How to plan standard jobs in S4HANA?
  • How do I set up batch job server groups?
  • How can I mail the spool of a batch job?
  • How can I mail if job was successful or not?
  • How to check the consistency of the batch job tables and how to repair?
  • How can I archive a print list?
  • How can I archive a job log?
  • How can I get job statistics?
  • How to read content from batch job variants?
  • How to find batch jobs with deleted or locked step users?
  • How to debug a batch job?
  • How to find who deleted a batch job?
  • How to check in case of batch job delay?
  • How to quickly check health of batch job scheduler?
  • How to trigger batch job event?

SAP FAQ note on background jobs

SAP has FAQ note on background jobs: 3008195 – FAQ: Background Processing BC-CCM-BTC-*.

Prevention of same job still running

If you want to prevent same job from starting, while a previous instance is still running, you need to add program RSBTONEJOB or RSBTONEJOB2 as first step in the batch job. This step will detect if the previous instance is still running and abort to avoid the next steps from being executed. More background in OSS note 557610. The scope of both programs is in principle limited to be used for idocs and CUA. To extend the scope or in case of issues, read the instructions in note 3225033 – Behavior of program RSBTONEJOB, RSBTONEJOB2 not as expected.

Forcing a batch program to wait

If for some reason you need a batch program to wait between steps, you can use program RSWAITSEC as a step. This program will only do a wait for x amount of seconds.

Setting current date in the TVARVC table for the RV variables

The RV variables for current date, month and year are often used in month end closing batch jobs. Running program RVSETDAT will set the current dates for RV TVARC variables.

Checking basis background job system settings and working

If you want to validate if the background job system function itself is working properly, start transaction SM65 background processing analysis tool.

SM65 start screen

Result is shown correct working, number of batches and wait time:

SM65 result screen

Bug fixes for SM65:

Background job analysis tool

Start transaction ST13 and start tool BACKGROUND_JOB_ANALYSIS. Or directly start program /SSA/BTC.

Batch job analysis tool

Pending on your selection you get a graphical overview or a full list for you to speed up your analysis.

Mass stop and start of batch jobs

Also check this note for clean up of BTCDELAY table: 3222291 – Superfluos Entries in BTCDELAY Table.

In some cases you might want to find out who manually deleted a batch job.

Unfortunately you first need to activate the logging via program BTCAUX06:

To view job deletions you need to go to transaction SM51, menu option Goto, Trace, Instance Trace, Search Trace. Then look for pattern BP_JOB_DELETE.

More information in OSS note 850885 – Logging the deletion of jobs and 3325374 – How to log job deleted in Background Processing.

A batch job is not started immediately, but with a delay. This delay is set via RZ11 parameter rdisp/btctime and default setting is 60 seconds. More information can be found in OSS note 923228 – Background job scheduler: Use of processes that have become free.

See new note 3236046 – Test report for immediate start for program BTCAUX25 that will test immediate start.

Standard batch jobs in S4HANA

Standard batch jobs in S4HANA are planned via transaction SJOBREPO. For more details read the dedicated blog.

Batch job server groups

If you have a large production system with many application servers you can setup batch job server groups to have batch jobs run on a set of dedicated application servers. To set up batch job server groups start transaction SM61 and click the button Job server groups:

Job server groups

Here you can define the job server group and assign application servers to them. Background is in OSS note 612838 – Administration of job server groups.

job statistics

This gives statistical output:

Job statistics output

Batch jobs with deleted or locked step users

If a batch job step user is locked or deleted, that step will fail. To find such batch jobs, follow the steps as described in this blog.

Batch job delay

Batch job delay can be set with parameter rdisp/btctime. Default is 60 seconds.

See also OSS notes 3080021 – Jobs are started with delay and 3148846 – Background Jobs with status “No free batch work processes available”.

And these notes:

3275278 – Background jobs are started with delay / 3355049 – Correction for Note 3275278.

How to read content from batch job variants

In quite some cases the basis team is asked: in which batch job variant is this company code XXXX used? Or we need to add another sales organization to all the batch jobs, can you provide us a list with jobs using sales organization YYYY? How to get this data is answered in this dedicated blog.

How to check health of batch job scheduler

Start transaction SM61. Now select the Time-Driven scheduler. Select the server and choose the health check tab. Now press the check button:

Batch job event triggers

Batch jobs can also be triggered using events. Read more in this blog on batch job event triggers.

Batch job monitoring

Batch job monitoring can be done with SAP Focused Run. Read more in this blog.

Background OSS notes

3008195 – FAQ: Background Processing BC-CCM-BTC-*

Stop and start batch jobs for maintenance

This blog explains how to mass stop and mass start batch jobs as admin. This especially useful putting the SAP system in maintenance mode. Maintenance mode can be needed for upgrade, support package patching or data conversion.

Questions that will be answered are:

  • How to mass stop batch jobs?
  • Can I plan new jobs I need during the suspend mode?
  • How to mass start batch jobs again?

More batch jobs tips and tricks in this blog.

Stopping all batch jobs for maintenance mode

Stop all batch jobs: start transaction SE38 and start program BTCTRNS1.

BTCTRNS1 output

All currently planned jobs will be put into a Released/Suspended mode:

Batch jobs suspended mode

This means the already planned jobs (periodically or not) will not be started.

During this suspend mode new jobs can be planned by admin. These new jobs will be executed.

Starting all batch jobs after end of maintenance

Start all batch jobs again: start transaction SE38 and start program BTCTRNS2.

BTCTRNS2 output

Background

For more background information read OSS note 79424 – How do BTCTRNS1 / BTCTRNS2 work?.