[ DB2 Parameter Compare Tool ]

The purpose of the DB2 parameter tool is to provide the ability to quickly compare DB2 configuration and Manager Configuration parameters across multiple system at one time in the one location from an SAP system.

Often application server problems come down to simple database parameter issues, so this tool allows for a basis administrator to quickly troubleshoot without even logging in at the OS level.

DB2 Compare tool selection screen:

The selection screen allows for the user to select individual systems via RFC connections or they can select groups of systems via the respective radio button.

The selection screen also allows for the user to display DB configuration, DB Manager Configuration or both.

In the below example we will select two systems to compare:

After the report is run the results will be presented in an ALV list as shown below.
Entries that are different are highlighted in red.

Below in the code for the above report where the bulk of the work is completed:

    LOOP AT s_rfc.

       CALL FUNCTION 'Z_READ_DB2_CFG'
         DESTINATION s_rfc-low
         EXPORTING
           db_cfg      = p_db
           dbm_cfg     = p_dbm
         TABLES
           out_db_cfg  = gt_db_tmp_db
           out_dbm_cfg = gt_db_tmp_dbm.


       gt_output-sysid = s_rfc-low+6(3).

       LOOP AT gt_db_tmp_db.
         MOVE-CORRESPONDING gt_db_tmp_db TO gt_output.
         gt_output-config = 'DB2 db cfg'.
         APPEND gt_output.
       ENDLOOP.

       LOOP AT gt_db_tmp_dbm.
         MOVE-CORRESPONDING gt_db_tmp_dbm TO gt_output.
         gt_output-config = 'DB2 dbm cfg'.
         APPEND gt_output.
       ENDLOOP.
     ENDLOOP.



   ELSE.

     " 'One or more RFC destinations do not exist or are not valid..'

   ENDIF.

   CLEAR: s_rfc[].

sort gt_output by param.

READ TABLE gt_output INDEX 1.
gv_pre_param = gt_output-param.
gv_first = abap_true.

loop at gt_output.
   if gv_pre_param EQ gt_output-param.
     if gv_first NE abap_true.
       if gv_pre_value NE gt_output-value.
*             Colour cells
              CLEAR lt_alvcolor.
               lt_alvcolor-fieldname = 'VALUE'.
               lt_alvcolor-color-col = 6.
               lt_alvcolor-color-int = 1.
               lt_alvcolor-color-inv = 1.
               lt_alvcolor-nokeycol = 'X'.
               APPEND lt_alvcolor TO gt_output-colour.
               modify gt_output from gt_output
                 TRANSPORTING colour
                 WHERE param = gt_output-param.
       endif.
     endif.
           gv_first = abap_false.

    else.
*     gv_first = abap_true.
     clear:
       gv_pre_value,
       gv_pre_param.
    endif.

gv_pre_value = gt_output-value.
   gv_pre_param = gt_output-param.


endloop.


*   Create report
    PERFORM create_alv_report.

 

 

In order for this report to work in all system the following function module must be rolled out. The Z_READ_DB2_CFG function module in this case simply calls a unix command to read the DB2 parameters and passes the results back to the report.

There are only two input parameters. One for the DB configuration and the other for the DB Manager configuration.

The tables parameters will simply contains the DB and DB manager parameters depending on the input parameters passed.

 

Below is the complete code for the Z_READ_DB2_CFG function module

FUNCTION Z_READ_DB2_CFG.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(DB_CFG) TYPE BOOLEAN DEFAULT 'X'
*" VALUE(DBM_CFG) TYPE BOOLEAN DEFAULT 'X'
*" TABLES
*" OUT_DB_CFG TYPE ZSS_DB_CFG_TT OPTIONAL
*" OUT_DBM_CFG TYPE ZSS_DB_CFG_TT OPTIONAL
*"----------------------------------------------------------------------


DATA:
   gv_param_len TYPE i,
   gv_loop_count TYPE i,
   gv_offset TYPE i,
   gv_key_len TYPE i,
   gv_desc_len TYPE i,
   gv_unixcmd(1000) TYPE c,
   gv_tmp_string TYPE string,
   gv_db_cfg LIKE gv_unixcmd,
   gv_dbm_cfg LIKE gv_unixcmd,


  BEGIN OF gt_out OCCURS 0,
           line(200),
  END OF gt_out,

  gt_dbm_cfg TYPE ZSS_DB_CFG_TT WITH HEADER LINE,
  gt_db_cfg TYPE ZSS_DB_CFG_TT WITH HEADER LINE.


gv_dbm_cfg = 'db2 get dbm cfg'.
CONCATENATE 'db2 get db cfg for' sy-sysid into gv_db_cfg
SEPARATED BY space.


if db_cfg EQ 'X'.

clear: gt_out,
        gt_out[].

   CALL 'SYSTEM' ID 'COMMAND' FIELD  gv_db_cfg
          ID 'TAB'   FIELD  gt_out-*sys*.

   LOOP AT gt_out INTO gv_tmp_string.

     gv_key_len = 0.
     gv_param_len = 0.
     gv_loop_count = 0.
     gv_desc_len = 0.

     IF gv_tmp_string CS '='.
       SPLIT gv_tmp_string AT '=' INTO gt_db_cfg-param gt_db_cfg-value.
       SHIFT gt_db_cfg-param LEFT DELETING LEADING space.
       SHIFT gt_db_cfg-value LEFT DELETING LEADING space.

       IF gt_db_cfg-param CS '('.

         gv_param_len = STRLEN( gt_db_cfg-param ).
         gv_loop_count = gv_param_len.


         DO gv_loop_count TIMES.
           gv_param_len = gv_param_len - 1.
           IF gt_db_cfg-param+gv_param_len(1) EQ '('.
             gv_offset = gv_param_len + 1.
             EXIT.
           ELSE.
             gv_key_len = gv_key_len + 1.
           ENDIF.
         ENDDO.

         gv_key_len = gv_key_len - 1.
         gv_desc_len = gv_offset - 1.

         gt_db_cfg-description = gt_db_cfg-param+0(gv_desc_len).
         SHIFT gt_db_cfg-description RIGHT DELETING TRAILING space.
         SHIFT gt_db_cfg-description LEFT DELETING LEADING space.

         gt_db_cfg-param = gt_db_cfg-param+gv_offset(gv_key_len).
         APPEND gt_db_cfg.
       ENDIF.
     ENDIF.
   ENDLOOP.

OUT_DB_CFG[] = gt_db_cfg[].

endif.

if dbm_cfg EQ 'X'.

clear: gt_out,
        gt_out[].

   CALL 'SYSTEM' ID 'COMMAND' FIELD  gv_dbm_cfg
          ID 'TAB'   FIELD  gt_out-*sys*.

   LOOP AT gt_out INTO gv_tmp_string.

     gv_key_len = 0.
     gv_param_len = 0.
     gv_loop_count = 0.
     gv_desc_len = 0.

     IF gv_tmp_string CS '='.
       SPLIT gv_tmp_string AT '=' INTO gt_dbm_cfg-param gt_dbm_cfg-value.
       SHIFT gt_dbm_cfg-param LEFT DELETING LEADING space.
       SHIFT gt_dbm_cfg-value LEFT DELETING LEADING space.

       IF gt_dbm_cfg-param CS '('.

         gv_param_len = STRLEN( gt_dbm_cfg-param ).
         gv_loop_count = gv_param_len.


         DO gv_loop_count TIMES.
           gv_param_len = gv_param_len - 1.
           IF gt_dbm_cfg-param+gv_param_len(1) EQ '('.
             gv_offset = gv_param_len + 1.
             EXIT.
           ELSE.
             gv_key_len = gv_key_len + 1.
           ENDIF.
         ENDDO.

         gv_key_len = gv_key_len - 1.
         gv_desc_len = gv_offset - 1.

         gt_dbm_cfg-description = gt_dbm_cfg-param+0(gv_desc_len).
         SHIFT gt_dbm_cfg-description RIGHT DELETING TRAILING space.
         SHIFT gt_dbm_cfg-description LEFT DELETING LEADING space.

         gt_dbm_cfg-param = gt_dbm_cfg-param+gv_offset(gv_key_len).
         APPEND gt_dbm_cfg.
       ENDIF.
     ENDIF.
   ENDLOOP.

OUT_DBM_CFG[] = gt_dbm_cfg[].

endif.



ENDFUNCTION.