Skip to Content

This blog post illustrates how to make an ABAP program that can display the current scheduled status of the process chains in an easy to view ALV grid format with traffic lights.The ALV Grid Control (ALV = ABAP List Viewer) is a flexible tool for displaying lists. The tool provides common list operations as generic functions and can be enhanced by self-defined options

Scenario

This program can be used in load monitoring applications where the information about the scheduled status of the process chains is very important to avoid any scenario where a process chain was scheduled or descheduled by mistake. The output of the program is in the form of an ALV grid with traffic light indicator to display the scheduling status. So if a process chain is scheduled then it will display the traffic light as green with other information like scheduled date/time and the user who scheduled it. In case the process chain is not scheduled, a red traffic light will be displayed against the process chain name.

Another advantage of having a program like this is to avoid the process of going to RSPC transaction and checking the schedule status of each chain. This work can become tedious if there are hundreds of process chains in the system to be monitored. But by using this program one can copy the list of all the process chains and paste it in the selection screen via clipboard functionality thus saving a lot of time.

Tables and function modules used in the program

Tables

1. RSPCCHAINATTR – Attributes for a Process Chain

2. TBTCO – Job Status Overview Table

3. TBTCP – Background Job Step Overview

Function Module

1. RS_VARIANT_CONTENTS

This function module checks whether any parameters or select options of the variant have changed. If they have, it outputs an error message (variant obsolete). The names of the select options and parameter are returned in the following tables:

L_SELOP : Select options

L_SELOP_NONV : Invisible select options

L_PARAMS : Parameters

L_PARAMS_NONV : Invisible parameters

Screenshots

1. Initial Screen

/wp-content/uploads/2012/02/1_89237.png

2. Multiple Selections

/wp-content/uploads/2012/02/2_89238.png

3. Output

/wp-content/uploads/2012/02/3_89239.png

Code

REPORT  ZPROCESS_CHECK.
TABLES: rspcchainattr.
TYPE-POOLS: slis.
TYPES: BEGIN OF l_s_scheduled,
       chain   TYPE rspc_chain,
       sdlstrtdt TYPE tbtco-sdlstrtdt,
       sdlstrttm TYPE tbtco-sdlstrttm,
       sdluname  TYPE tbtco-sdluname,
       jobname  TYPE tbtco-jobname,
       jobcount TYPE tbtco-jobcount,
       progname TYPE tbtcp-progname,
       variant TYPE tbtcp-variant,
  END OF l_s_scheduled.
TYPES: BEGIN OF l_s_display,
        trafic_light(1) TYPE c,
        selname TYPE rspcchainattr-chain_id,
        sdlstrtdt TYPE tbtco-sdlstrtdt,
        sdlstrttm TYPE tbtco-sdlstrttm,
        sdluname  TYPE tbtco-sdluname,
       END OF l_s_display.
DATA: l_t_scheduled TYPE STANDARD TABLE OF l_s_scheduled,
      l_w_scheduled LIKE LINE OF l_t_scheduled,
      l_t_valtab    TYPE STANDARD TABLE OF rsparams,
      l_t_valtab1   TYPE STANDARD TABLE OF rsparams,
      l_t_valtab2   TYPE STANDARD TABLE OF l_s_scheduled,
      l_w_valtab    TYPE rsparams,
      l_w_valtab1   TYPE rsparams,
      l_w_valtab2   LIKE LINE OF l_t_valtab2,
      l_t_display   TYPE STANDARD TABLE OF l_s_display WITH HEADER LINE,
      l_w_display   LIKE LINE OF l_t_display.
DATA : it_return1 LIKE ddshretval OCCURS 0 WITH HEADER LINE,
       it_return2 LIKE ddshretval OCCURS 0 WITH HEADER LINE.
DATA: l_w_fieldcat    TYPE  slis_fieldcat_alv.
DATA: l_t_fieldcat    TYPE  slis_t_fieldcat_alv.
DATA: gs_layout       TYPE slis_layout_alv.
SELECTION-SCREEN BEGIN OF BLOCK block1.
SELECT-OPTIONS: s_chain FOR rspcchainattr-chain_id.
SELECTION-SCREEN END OF BLOCK block1.
START-OF-SELECTION.
*
  IF s_chain[] IS INITIAL.
    MESSAGE 'Process Chain Name cannot be left blank' TYPE 'I'.
    EXIT.
  ELSEIF s_chain[] IS NOT INITIAL.
    SORT s_chain[] BY low high.
    DELETE ADJACENT DUPLICATES FROM s_chain[].
    PERFORM fetch.
    PERFORM display.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
FORM display .
  PERFORM field_cat.
  PERFORM output.
ENDFORM.                    " DISPLAY
*&---------------------------------------------------------------------*
*&      Form  FIELD_CAT
*&---------------------------------------------------------------------*
FORM field_cat .
  gs_layout-lights_fieldname = 'TRAFIC_LIGHT'.
  l_w_fieldcat-fieldname = 'TRAFIC_LIGHT'.
  l_w_fieldcat-tabname = 'L_T_DISPLAY'.
  l_w_fieldcat-outputlen = 3.
  l_w_fieldcat-seltext_m = 'STATUS' .
  l_w_fieldcat-col_pos = 1.
  APPEND l_w_fieldcat TO l_t_fieldcat.
  CLEAR l_w_fieldcat.
  l_w_fieldcat-fieldname = 'SELNAME'.
  l_w_fieldcat-tabname = 'L_T_DISPLAY'.
  l_w_fieldcat-outputlen = 40.
  l_w_fieldcat-seltext_m = 'CHAIN NAME' .
  l_w_fieldcat-col_pos = 2.
  APPEND l_w_fieldcat TO l_t_fieldcat.
  CLEAR l_w_fieldcat.
  l_w_fieldcat-fieldname = 'SDLSTRTDT'.
  l_w_fieldcat-tabname = 'L_T_DISPLAY'.
  l_w_fieldcat-outputlen = 10.
  l_w_fieldcat-seltext_m = 'DATE' .
  l_w_fieldcat-col_pos = 3.
  APPEND l_w_fieldcat TO l_t_fieldcat.
  CLEAR l_w_fieldcat.
  l_w_fieldcat-fieldname = 'SDLSTRTTM'.
  l_w_fieldcat-tabname = 'L_T_DISPLAY'.
  l_w_fieldcat-outputlen = 10.
  l_w_fieldcat-seltext_m = 'TIME' .
  l_w_fieldcat-col_pos = 4.
  APPEND l_w_fieldcat TO l_t_fieldcat.
  CLEAR l_w_fieldcat.
  l_w_fieldcat-fieldname = 'SDLUNAME'.
  l_w_fieldcat-tabname = 'L_T_DISPLAY'.
  l_w_fieldcat-outputlen = 10.
  l_w_fieldcat-seltext_m = 'NAME' .
  l_w_fieldcat-col_pos = 4.
  APPEND l_w_fieldcat TO l_t_fieldcat.
  CLEAR l_w_fieldcat.
ENDFORM.                    " FIELD_CAT
*&---------------------------------------------------------------------*
*&      Form  OUTPUT
*&---------------------------------------------------------------------*
FORM output .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      is_layout     = gs_layout
      it_fieldcat   = l_t_fieldcat
    TABLES
      t_outtab      = l_t_display
    EXCEPTIONS
      program_error = 1
      OTHERS        = 2.
ENDFORM.                    " OUTPUT
*&---------------------------------------------------------------------*
*&      Form  FETCH
*&---------------------------------------------------------------------*
FORM fetch .
  FIELD-SYMBOLS  <l_f_scheduled> TYPE l_s_scheduled.
  FIELD-SYMBOLS  <l_f_chain> TYPE rspcchainattr-chain_id.
  SELECT a~jobname a~jobcount a~sdlstrtdt a~sdlstrttm a~sdluname b~progname b~variant
  INTO CORRESPONDING FIELDS OF TABLE l_t_scheduled
     FROM tbtco AS a JOIN tbtcp AS b
                ON a~jobname = b~jobname AND
                   a~jobcount = b~jobcount
  WHERE a~jobname = 'BI_PROCESS_TRIGGER' AND
        a~status = 'S'. "Scheduled
  LOOP AT l_t_scheduled ASSIGNING <l_f_scheduled>.
    REFRESH l_t_valtab.
    CALL FUNCTION 'RS_VARIANT_CONTENTS'
      EXPORTING
        report               = <l_f_scheduled>-progname
        variant              = <l_f_scheduled>-variant
      TABLES
        valutab              = l_t_valtab
      EXCEPTIONS
        variant_non_existent = 1
        variant_obsolete     = 2
        OTHERS               = 3.
    SORT l_t_valtab BY selname.
    IF sy-subrc = 0.
      READ TABLE l_t_valtab INTO l_w_valtab
      WITH KEY selname = 'CHAIN' BINARY SEARCH.
      IF sy-subrc = 0.
        <l_f_scheduled>-chain = l_w_valtab-low.
      ENDIF.
      MOVE-CORRESPONDING l_w_valtab TO l_w_valtab1.
      APPEND l_w_valtab1 TO l_t_valtab1.
    ENDIF.
  ENDLOOP.
  SORT l_t_valtab1 BY low.
  CLEAR: l_w_valtab1, l_w_display, l_w_scheduled.
  LOOP AT s_chain.
    READ TABLE l_t_valtab1 INTO l_w_valtab1 WITH KEY low = s_chain-low BINARY SEARCH.
    IF sy-subrc = 0.
      l_w_display-trafic_light = 3.
      l_w_display-selname = l_w_valtab1-low.
      READ TABLE l_t_scheduled INTO l_w_scheduled WITH KEY chain = l_w_valtab1-low.
      IF sy-subrc = 0.
        l_w_display-sdlstrtdt = l_w_scheduled-sdlstrtdt.
        l_w_display-sdlstrttm = l_w_scheduled-sdlstrttm.
        l_w_display-sdluname  = l_w_scheduled-sdluname.
      ELSE.
        l_w_display-sdlstrtdt = ' '.
        l_w_display-sdlstrttm = ' '.
        l_w_display-sdluname  = ' '.
      ENDIF.
    ELSE.
      l_w_display-trafic_light = 1.
      l_w_display-selname = s_chain-low.
      READ TABLE l_t_scheduled INTO l_w_scheduled WITH KEY chain = l_w_valtab1-low BINARY SEARCH.
      IF sy-subrc = 0.
        l_w_display-sdlstrtdt  = l_w_scheduled-sdlstrtdt.
        l_w_display-sdlstrttm  = l_w_scheduled-sdlstrttm.
        l_w_display-sdluname  = l_w_scheduled-sdluname.
      ELSE.
        l_w_display-sdlstrtdt = ' '.
        l_w_display-sdlstrttm = ' '.
        l_w_display-sdluname  = ' '.
      ENDIF.
    ENDIF.
    APPEND l_w_display TO l_t_display.
    CLEAR: l_w_display, l_w_valtab1,l_w_scheduled .
  ENDLOOP.
  SORT l_t_display BY trafic_light.
ENDFORM.                    " FETCH


To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Tobias Haas
    Hi,
    do you know transaction ST13 –> BW-TOOLS –> Process Chain Analysis.
    That is one of the best bw administration tools.
    You can see all process chains with runtime, status, start time, end time, and so on.
    You may also jump into the a detail view with information about the runtine of each step.

    Kind regards,
    Tobias

    (0) 
    1. Kush Kashyap Post author
      Hi Tobias,
      Yes i do know but the purpose of the above program is to display the scheduling status of the process chains and not the run-time information. e.g say if you want to check when will a particular process chain run in future then you can use this program.
      ST13 however will give you information on the process chains that are running or have run in the past.
      Thanks
      (0) 
  2. Otto Gold
    Hi,
    interesting topic. But maybe the format of your blog should be little different? At first I was going to suggest you to move the coding to a wiki, but since I don`t use wikis myself, I can`t tell others to do that.
    But make the code neat and easily readable would be nice. Meaningless automatically added FORM description comments or REUSE*ALV*GRID without useless parts of the call being removed are rather tacky.
    Other than that it`s nice content.
    Cheers Otto
    (0) 
    1. Kush Kashyap Post author
      Hi Otto,
      Thanks for your valuable suggestions :-). Since it was my first post so i will take care of the things pointed out by you in future posts as well.
      Thanks
      (0) 
  3. GERVY GARCIA

    Hi,

    Can we copy the code contents so that we can use it on our end? We will study it and we will notify you if we found and enhancement/bugs.

    Thanks!

    (0) 
        1. Kush Kashyap Post author

          Hi Gervy,

          You can create multiple variants just like in ST13. Once you have added the chains in the selection screen and before executing the program, click on the Save button on the top. This will open a prompt for saving the variant.

          Thanks

          (0) 

Leave a Reply