Skip to end of metadata
Go to start of metadata

Overview

The plugin Prerequisite checks can be used in your own guided procedures. It offers the possibility to select at design time among a set of pre-defined prerequisite checks.  Those checks are then performed at runtime on each scope object of the guided procedure. This allows to control if predefined criteria are met before executing additional steps on the managed system. 

The prerequisite checks plugin allows also the integration of simple custom checks (refer to example section).

Examples

Following section show a concrete example of custom checks that can be implemented on your own system.

Check if no workmode is active

Description

This check can be used for following object type: Technical System, Database or Host. 

How to activate the code:

  • copy current code in your customer namespace
    define following Text Symbols for handling text

    Sym

    Text

     001No workmode defined
     002 Workmode active:
     003 Exception while reading current work mode. 

Code snapshot

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
class ZCL_CHECK_NO_WORKMODE definition
  public
  inheriting from CL_GPCR_CHECK_BASE
  final
  create public .
public section.
*"* public components of class ZCL_CHECK_NO_WORKMODE
*"* do not include other source files here!!!
  methods IF_GPCR_CHECK~GET_DESCRIPTION
    redefinition .
  methods IF_GPCR_CHECK~GET_NAME
    redefinition .
  methods IF_GPCR_CHECK~IS_VALID
    redefinition .
  methods IF_GPCR_CHECK~RUN_CHECK
    redefinition .
  methods IF_GPCR_CHECK~GET_URL
    redefinition .
protected section.
*"* protected components of class ZCL_CHECK_NO_WORKMODE
*"* do not include other source files here!!!
private section.
*"* private components of class ZCL_CHECK_NO_WORKMODE
*"* do not include other source files here!!!
  methods RUN_CHECK_4_BASE_LANDSCAPE
    importing
      !IV_BASE_LANDSCAPE_OBJ type ref to CL_DIAGLS_BASE_LANDSCAPE
    exporting
      !EV_STATUS type AGS_SISE_ACTIVITY_STATUS
      !EV_MESSAGE type STRING .
  methods GET_WORKMODE_SHORTDESCR
    importing
      !IM_WORKMODE_CODE type AC_STRING
    returning
      value(RE_WORKMODE_DESCR) type AC_STRING .
ENDCLASS.
 
CLASS ZCL_CHECK_NO_WORKMODE IMPLEMENTATION.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_CHECK_NO_WORKMODE->GET_WORKMODE_SHORTDESCR
* +-------------------------------------------------------------------------------------------------+
* | [--->] IM_WORKMODE_CODE               TYPE        AC_STRING
* | [<-()] RE_WORKMODE_DESCR              TYPE        AC_STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
method GET_WORKMODE_SHORTDESCR.
  data lt_dd07v type standard table of dd07v WITH DEFAULT KEY.
  data ls_dd07v type dd07v.
  call function 'DDIF_DOMA_GET'
    exporting
      name          = 'DSWPD_DTM_DT_TYPE'
      langu         = sy-langu
    tables
      dd07v_tab     = lt_dd07v
    exceptions
      illegal_input = 1
      others        = 2.
  " check if method is succesfull
  check sy-subrc EQ 0.
  " read table for matching code
  read table lt_dd07v with key DOMVALUE_L = im_workmode_code into ls_dd07v.
  " check if initial
  check ls_dd07v is not initial.
  re_workmode_descr = ls_dd07v-ddtext.
endmethod.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_CHECK_NO_WORKMODE->IF_GPCR_CHECK~GET_DESCRIPTION
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RE_DESCRIPTION                 TYPE        STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
method IF_GPCR_CHECK~GET_DESCRIPTION.
re_description = 'Check if no work mode are activated'.
endmethod.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_CHECK_NO_WORKMODE->IF_GPCR_CHECK~GET_NAME
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RE_NAME                        TYPE        STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
method if_gpcr_check~get_name.
  re_name = 'Check no active workmode'.
endmethod.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_CHECK_NO_WORKMODE->IF_GPCR_CHECK~GET_URL
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RE_URLAPI_URL                  TYPE REF TO CL_URLAPI_URL
* +--------------------------------------------------------------------------------------</SIGNATURE>
method IF_GPCR_CHECK~GET_URL.
data lr_scope_obj      type ref to cl_diag_base_object.
  data lr_base_landscape type ref to cl_diagls_base_landscape.
  data lr_tech_syst      type ref to cl_diagls_technical_system.
  data lr_abap_client    type ref to cl_diagls_abap_client.
  data lr_database       type ref to cl_diagls_database.
  data  lt_sysparams      type ags_sise_t_sysparam.
  data  ls_sysparam       type ags_sise_s_sysparam.
  data ls_ts_basis type sdiagls_technical_system_basis.
  data ls_ts       type sdiagls_technical_system.
  data ls_db_basis type sdiagls_database_basis.
  data ls_db       type sdiagls_database.
  data lv_urlapi_app type ref to cl_urlapi_application.
  data ls_urlapi_param_context type surlapi_parameters_context.
  try.
      " get object
      lr_scope_obj = me->ms_scope_obj-scope_obj.
      " check type
      if ( lr_scope_obj->is_landscape_object( ) eq abap_true ).
        " cast to base landscape
        lr_base_landscape ?= lr_scope_obj.
        " check type of landscape object
        "
        " Technical System
        "
        if ( cl_diagls_util=>is_technical_system( lr_base_landscape ) eq abap_true ).
          " cast to technical system
          lr_tech_syst ?= lr_base_landscape.

          ls_ts_basis = lr_tech_syst->get_ts_structure( ).
          move-corresponding ls_ts_basis to ls_ts.
          ls_ts-technical_system = lr_tech_syst.
          "
          append ls_ts to ls_urlapi_param_context-technical_systems.
          " return the urlapi application
          lv_urlapi_app = cl_urlapi_application_manager=>get_application( 'SMADMIN_WORKMODE' ).
          lv_urlapi_app->set_parameters_context( ls_urlapi_param_context ).
          " return url
          re_urlapi_url = cl_urlapi_application_manager=>build_url_from_application( lv_urlapi_app ).
        elseif ( cl_diagls_util=>is_abap_client( lr_base_landscape ) eq abap_true ).
          " cast to abap client
          lr_abap_client ?= lr_base_landscape.
          " get technical system
          data lv_abap_client type sdiagls_abap_tech_syst.
          lv_abap_client = lr_abap_client->get_abap_tech_syst( ).
          lr_tech_syst = lv_abap_client-abap_technical_system.
          ls_ts_basis = lr_tech_syst->get_ts_structure( ).
          move-corresponding ls_ts_basis to ls_ts.
          ls_ts-technical_system = lr_tech_syst.
          "
          append ls_ts to ls_urlapi_param_context-technical_systems.
          " return the urlapi application
          lv_urlapi_app = cl_urlapi_application_manager=>get_application( 'TECHMON_SYSMON_GRAPH' ).
          lv_urlapi_app->set_parameters_context( ls_urlapi_param_context ).
          " return url
          re_urlapi_url = cl_urlapi_application_manager=>build_url_from_application( lv_urlapi_app ).
        elseif ( cl_diagls_util=>is_database( lr_base_landscape ) eq abap_true ).
          " cast to correct object
          lr_database ?= lr_base_landscape.
          " get database
          ls_db_basis = lr_database->get_structure( ).
          move-corresponding ls_db_basis to ls_db.
          ls_db-database = lr_database.
          " add to URL API parameter
          append ls_db to ls_urlapi_param_context-databases.
          " return the urlapi application
          lv_urlapi_app = cl_urlapi_application_manager=>get_application( 'TECHMON_SYSMON_GRAPH' ).
          lv_urlapi_app->set_parameters_context( ls_urlapi_param_context ).
          " return url
          re_urlapi_url = cl_urlapi_application_manager=>build_url_from_application( lv_urlapi_app ).
        endif.
      endif.
    catch cx_root.
      " do not return URL in case of unexpected exception
  endtry.
endmethod.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_CHECK_NO_WORKMODE->IF_GPCR_CHECK~IS_VALID
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RE_IS_VALID                    TYPE        BOOLEAN
* +--------------------------------------------------------------------------------------</SIGNATURE>
method if_gpcr_check~is_valid.
  data lr_scope_obj      type ref to cl_diag_base_object.
  data lr_base_landscape type ref to cl_diagls_base_landscape.
  " get object
  lr_scope_obj = me->ms_scope_obj-scope_obj.
  " set default value
  re_is_valid = abap_false.
  " check is landscape object
  if ( lr_scope_obj->is_landscape_object( ) eq abap_true ).
    " cast to base landscape
    lr_base_landscape ?= lr_scope_obj.
    if ( cl_diagls_util=>is_technical_system( lr_base_landscape ) eq abap_true ) or
       ( cl_diagls_util=>is_abap_client( lr_base_landscape )      eq abap_true ) or
       ( cl_diagls_util=>is_database( lr_base_landscape )         eq abap_true ) or
       ( cl_diagls_util=>is_host( lr_base_landscape )             eq abap_true ).
      re_is_valid = abap_true.
    endif.
  endif.
endmethod.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_CHECK_NO_WORKMODE->IF_GPCR_CHECK~RUN_CHECK
* +-------------------------------------------------------------------------------------------------+
* | [<---] EV_STATUS                      TYPE        AGS_SISE_ACTIVITY_STATUS
* | [<---] EV_MESSAGE                     TYPE        STRING
* | [<---] EV_DETAILS                     TYPE        AGS_SISE_T_LOG_CTX
* +--------------------------------------------------------------------------------------</SIGNATURE>
method IF_GPCR_CHECK~RUN_CHECK.
  data lr_scope_obj      type ref to cl_diag_base_object.
  data lr_base_landscape type ref to cl_diagls_base_landscape.
  " get object
  lr_scope_obj = me->ms_scope_obj-scope_obj.
  " check is landscape object
  if ( lr_scope_obj->is_landscape_object( ) eq abap_true ).
    " cast to base landscape
    lr_base_landscape ?= lr_scope_obj.
    " run check for base landscape object
    run_check_4_base_landscape(
      exporting
        iv_base_landscape_obj =    lr_base_landscape " Common class of the Landscape API.
      importing
        ev_status             =     ev_status" Simple Setup: Activity Status
        ev_message            =     ev_message
    ).
  endif.
endmethod.

* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_CHECK_NO_WORKMODE->RUN_CHECK_4_BASE_LANDSCAPE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_BASE_LANDSCAPE_OBJ          TYPE REF TO CL_DIAGLS_BASE_LANDSCAPE
* | [<---] EV_STATUS                      TYPE        AGS_SISE_ACTIVITY_STATUS
* | [<---] EV_MESSAGE                     TYPE        STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
method RUN_CHECK_4_BASE_LANDSCAPE.
  " data
  data lr_base_landscape      type ref to cl_diagls_base_landscape.
  data lr_abap_client         type ref to cl_diagls_abap_client.
  data ls_abap_ts             type sdiagls_abap_tech_syst.
  data lt_category            type tmon_t_category.
  data ls_category            type tmon_s_category.
  data ls_workmode_code       type ac_string.
  data ls_workmode_descr      type ac_string.
  data ls_curr_workmode_code  type ac_string.
  data ls_curr_workmode_descr type ac_string.
  data lt_workmode_view type dswpt_dtm_dt_alldt_display.
  data ls_workmode_view type line of dswpt_dtm_dt_alldt_display.
  data lr_root                type ref to cx_root.
  DATA lv_mo_key     TYPE         dtscompkey.
  DATA lv_mo_type    TYPE         dt_comp_type.
  DATA lt_work_modes TYPE         dswpt_dtm_dt_alldt_display.
  DATA ls_work_mode  LIKE LINE OF lt_work_modes.
  " get overview of the monitored system
  try.
      " check if object is abap client
      if ( cl_diagls_util=>is_abap_client( iv_base_landscape_obj ) eq abap_true ).
        " cast to correct object
        lr_abap_client ?= iv_base_landscape_obj.
        ls_abap_ts = lr_abap_client->get_abap_tech_syst( ).
        lr_base_landscape = ls_abap_ts-abap_technical_system.
      else.
        lr_base_landscape = iv_base_landscape_obj.
      endif.
      " get landscape ID
      lv_mo_key = lr_base_landscape->get_id( ).
      " set mo type
      if ( cl_diagls_util=>is_technical_system( lr_base_landscape ) eq abap_true ).
        lv_mo_type = cl_dswp_scheduler_const=>c_technicalsystem.
      elseif ( cl_diagls_util=>is_database( lr_base_landscape ) eq abap_true ).
        lv_mo_type = cl_dswp_scheduler_const=>c_database.
      elseif ( cl_diagls_util=>is_host( lr_base_landscape ) eq abap_true ).
        lv_mo_type =  cl_dswp_scheduler_const=>C_SERVER.
      else.
        " default is system
        lv_mo_type = cl_dswp_scheduler_const=>c_system.
      endif.
      " get current downtime state
      call function 'FDSWP_GET_WM_INFO'
        exporting
          iv_mo_key                = lv_mo_key
          iv_mo_type               = lv_mo_type
          iv_get_current_wm        = 'X'
        importing
          et_work_modes            =  lt_workmode_view
        exceptions
          illegal_import_parameter = 1
          others                   = 2.
      " check return code.
      if sy-subrc <> 0.
        ev_status = cl_sise_status=>error.
        ev_message = text-003.
        return.
      endif.
*      " get status table
*      ls_workmode_code = me->ms_check_param-low.
*      ls_workmode_descr = me->get_workmode_shortdescr( im_workmode_code = ls_workmode_code ).
*
       " read current work mode
       read table lt_workmode_view into ls_workmode_view index 1.
       " get curr workmode
       ls_curr_workmode_code  = ls_workmode_view-dt_event_phase.
       ls_curr_workmode_descr = me->get_workmode_shortdescr( im_workmode_code = ls_curr_workmode_code ).
      " check workmode
      if ( ls_curr_workmode_code eq '' ).
        ev_status  = cl_sise_status=>error.
        concatenate text-001 '' into ev_message respecting blanks.
      else.
        ev_status = cl_sise_status=>success.
        concatenate text-002 ' ' ls_curr_workmode_descr into ev_message respecting blanks.
      endif.
    catch cx_root into lr_root.
      ev_status = cl_sise_status=>error.
      ev_message = lr_root->get_longtext( ).
  endtry.
endmethod.
ENDCLASS.