SAP Focused Run tactical dashboard

ultiple systems. Items that are part of the tactical dashboard is database backup status, performance, logged on users, software maintenance status.

Questions that will be answered in this blog are:

  • How to use the Focused Run tactical dashboards?
  • How to fine tune the tactical dashboards?
  • How to setup your own tactical dashboard?

Tactical dashboards usage

To start the tactical dashboard, click the corresponding Fiori tile:

You now reach the tactical dashboard overview screen:

By clicking the Expand Group icon at the right you get first level of details:

By clicking the tile you are interested in you get the details.

Examples are hardware resources for current week and last month:

Dialog response times:

Amount of logged on users:

And software maintenance status for detailed components:

An alternative for manageming software components is via Security and Configuration management. More details be found in this detailed blog. The tactical dashboard is nice for 1 system. The configuration validation tool is useful for overview of components across multiple systems.

Configuration of the tactical dashboard

By clicking the personalization button top right:

you will reach the configuration screen. Here you can add and delete systems from the overview:

And you can set the view properties and thresholds for each of the categories:

This fine-tuning you do as per your companies needs. By clicking on the Visibility symbol, you can hide an aspect from your overview. Like above the Database backup was put to invisible.

Creating your own tactical dashboard

You can create your own tactical dashboard for your own specific needs. We will take the example here to make a dedicated dashboard for the backups. Since we want to check daily in the overview if the backups were successful.

Start by clicking top left on the big + symbol to add a new dashboard:

The personalization view screen will open:

Important here are a few things. Set the tick box Public if you want to share this dashboard. Find the keyword for the right SAP icon (use the SAP icons link and read this blog). Rename the dashboard by clicking the Rename button.

Now Save the page. Close the personalization. You are now in the empty screen. Open peronalization again to add the system(s):

Also hide the not needed views. On the left hand side you can immediately see the result updating.

Hint: start with one or two systems only when making a new dashboard. First fine tune what you want to see. When all is ok, add the systems later. If you have a lot of systems, the updating of the left hand screen will be slowing you down.

Don’t forget to save off course.

Using a dashboard created by a different user

If you want to use a dashboard created by a different user, go to the personalization option and select the add page option:

Now you can select any created dashboard, which has been set to public.

If you don’t see the correct dashboard, check with the owner that he made it public.

SAP Focused Run self monitoring

When using Focused Run you monitor systems. But how about the health and stability of the monitoring tool itself? Here is where self monitoring plays an important role.

Questions that will be answered are:

  • What to check in self monitoring?
  • How much metrics are collected and stored in my Focused Run installation?

Self monitoring

Self monitoring can be started with the Self Monitoring Fiori tile:

If you click the tile the overview page comes (this page will take time to load):

The interesting part is unfortunately hidden in the below screen (you need to scroll), which is the CPU utilisation.

The other interesting part is the amount of data collected and stored. This is not so interesting for yourself, but more interesting for your manager to show how much data HANA can handle, or to show how much work is really automated.

Simple diagnostics agent

On the top left icons, click on the Simple DA agent button to get the agent overview screen:

Important here:

  • Check that all agents are up
  • Check that all agent versions are not too old

Monitoring and Alerting Infrastructure

The next option is to check the MAI (monitoring and alerting infrastructure) data collection:

Important here is to fix the systems in error.

Wily Introscope

The Wily option will show if your Wily Introscope connected to Focused Run is ok. Wily is used for special use cases like JAVA and Business Objects products.

Managed system overview

The managed system overview gives the overview of the diverse systems and application status:

Any red or yellow item can mean a setup issue. But it can also be because of missing authorizations and privileges of the Focused Run technical user in the connected managed system.

Central component monitoring

The central component monitoring shows the overview of the central components:

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>

Activating early watch report (EWA) for ABAP and JAVA managed systems in SAP Focused Run

EWAs in Focused Run

When you have performed Simple System Integration (SSI) for the connected managed system on the Focused Run system, by default SSI itself activates the SAP early watch (EWA) reporting for a managed system, provided the managed system has IT Admin Role defined as Production system. For more information on how to set IT Admin Role read this blog.

For non productive systems you can also manually activate EWA.

Additionally for all ABAP systems (Production and Non-production), you will need to configure SDCCN in managed system so that EWA data is sent to the Focused Run system.

Note: In an Focused Run environment, EWAs are not generated on the Focused Run system, but rather at SAP side. Only data is collected at the Focused Run side and the EWA is then available in Service Messages at SAP. For accessing the EWAs you can navigate from the launchpad using the EWA Workspace tile. For more details click here or here.

Steps for activating EWA for ABAP Systems

STEP 1: Activate EWA on Focused run System

Goto Launchpad and click on the SAP Early Watch Alert Status tile.

In the EWA Status Application first you need to select scope to include all ABAP systems as shown below.

To activate EWA, change under Active column from NO to YES for the respective system.

After Activation status changes as shown below. Refresh after 5 minutes to ensure that the first circle is Green.

STEP 2: Configure SDCCN on Managed System

Once EWA session for an ABAP system is activated, the SDCCN of the respective ABAP system must read the EWA session data from Focused Run system. For more details read OSS note 2359359 – SDCC Enhancement for ABAP Systems Connecting to Focused Run.

For this first create a HTTP destination from the managed ABAP system to Focused Run system using report /BDL/CREATE_HTTP . Provide the following input and execute the report.

  1. HTTP Destination: By default, it shows as SDCC_SID, you’d better change the SID to the real target system id. This is the suggestion, but you can specify any name if you want.
  2. SSL Status(HTTPS): This checkbox means whether you want to use HTTPS for the communication. By default, it will only use HTTP.
  3. Path Prefix: By default, the service used by SDCCN is /sap/bc/sdf/sdcc/. You cannot change this unless you mark the checkbox “Force Mode”.
  4. User Name: FRN_EWA_<FRUN SID> which you have created during the initial setup of FRUN system
  5. Run report /BDL/CONFIGURE_SDCCN_HTTP to activate SDCCN. Provide the HTTP destination that created in step 2 and change the job user. Only the first check box must be  selected (only on FRUN 1.0 both check boxes must be selected).
  6. The job user must have authorization SAP_SDCCN_ALL

After running this report with above parameters, the SDCC_OSS RFC will be removed from RFC destinations, and the new HTTP destination will be added to RFC destinations.

STEP 3: Create Maintenance Package on SDCCN in Managed System

Now you need to create a maintenance package in transaction SDCCN of managed system.

To Ensure the EWA activation is properly completed, goto transaction SDCCN on the managed system and ensure that the EWA sessions for the managed system is registered.

When EWA Data is sent to Focused Run and processed at the SAP side, you will see all circles in Green for the respective ABAP system as shown below.

Activating EWA for JAVA Systems

Goto Launchpad and click on the SAP Early Watch Alert Status tile.

In the EWA Status Application first you need to select scope to include all java systems as shown below.

To activate EWA, change under Active column from NO to YES for the respective system.

After Activation status changes as shown below. Refresh after 5 minutes to ensure that the first circle is Green.

To Ensure the EWA activation is properly completed, goto transaction SDCCN on the FRUN system and ensure that the EWA session for respective Java system is registered.

When EWA Data is sent to FRUN and processed, you will see all circles in Green for the respective JAVA system as shown below.

EWA troubleshooting

In case of issues you can follow the link to the troubleshooting guide of SAP:

Data retention

The EWA data is kept for 1 year. To change this, read the blog on housekeeping settings.

Relevant OSS notes

OSS notes:

Guided answers

SAP guided answers:

<< This blog was originally posted on SAP Focused Run Guru by Manas Tripathy from Simac. Repost done with permission. >>

SAP Focused Run cloud monitoring overview

The integration and cloud monitoring function of SAP Focused Run consists of 2 main functions:

  • Cloud monitoring between on premise and cloud SAP products
  • Interface monitoring between SAP systems (read more on interface monitoring in this blog)

This blog will give an overview of the Cloud monitoring between SAP on premises systems and SAP cloud solutions.

Questions that will be answered in this blog are:

  • How does the Cloud monitoring in SAP Focused Run look like?
  • How much details and history can I see in SAP Focused Run interface monitoring?
  • Can I link an Cloud monitoring event to and alert?
  • Which Cloud monitoring scenarios are supported?
  • How to monitor message to and from SAP CPI?
  • How to setup the monitoring towards SAP CPI?
  • How to monitor message to and from SAP Ariba?
  • How to setup the monitoring towards SAP Ariba?

Cloud monitoring

To start the cloud monitoring click on the Fiori tile:

Select the cloud scenarios:

You now reach the scenario overview screen:

Click on the tile for details (we will take Ariba as example):

Click on the red line between the on premise and the cloud system:

Click on the red errors number for the error overview:

Click on specific error:

Supported cloud scenarios

Not all cloud products and scenarios of SAP are supported via SAP Focused Run Cloud monitoring. On the SAP Focused Run Expert Portal the following scenarios are currently published:

Read the scenario details carefully! Inside the details there might be less monitored than you were expecting.

CPI message monitoring

SAP Focused Run Cloud Monitoring can be used to monitor messages to and from the SAP BTP CPI solution. CPI stands for Cloud Platform Integeration.

End result of CPI message monitoring

The configuration of the scenario is described in the next chapter. We start explaining the end result.

Select the scenario and the overview tile appears:

Click on the card to go to the scenario topology:

Zoom into the overview screen of the errors:

And drill down to any specific error:

Set up of the CPI monitoring scenario

llow the steps from the SAP expert portal for CPI monitoring to setup the STRUST in SAP Focused Run for the CPI URL.

Validate in the SAP Focused Run ABAP stack that these two parameters are set in RZ11:

  • icm/HTTPS/client_sni_enabled = TRUE
  • ssl/client_sni_enabled = TRUE

If this is done, go to the cloud setup FIORI tile:

Add a new end point for CPI:

The application key, client ID and client secret will need to be provided by the basis person or functional consultant maintaining the CPI interface configurations on the BTP cloud. Depending on the security setup, a proxy is required as well.

After entering the details check the connection that connectivity is working as expected.

Now go to the configuration of the interface scenario and create a new cloud service for Cloud Platform Integration:

On the monitoring screen specify filters for specific IFlows if requiered:

On the alerting tab you can set up any alerting wanted:

Set the filter for alerting (in this case all failed flows):

Assign alert receivers and make sure everything is saved and activated.

Now you can model the scenario graphically as well:

Cloud monitoring: Ariba

SAP Focused Run Cloud Monitoring can be used to monitor messages to and from the Ariba solution.

End result of Ariba cloud monitoring

The configuration of the scenario is described in the next chapter. We start explaining the end result.

Select the scenario and the overview tile appears:

Click on the card to go to the scenario topology:

Click on the red line to zoom into the communication error details:

Click on the message to zoom into the details:

Set up of the Ariba monitoring scenario

ollow the steps from the SAP expert portal for Ariba monitoring to setup the STRUST in SAP Focused Run for the Ariba URL.

Validate in the SAP Focused Run ABAP stack that these two parameters are set in RZ11:

  • icm/HTTPS/client_sni_enabled = TRUE
  • ssl/client_sni_enabled = TRUE

If this is done, go to the cloud setup FIORI tile:

Add a new end point for Ariba:

The application key, client ID and client secret will need to be provided by the basis person or functional consultant maintaining the Ariba interface configurations on the Ariba cloud. Depending on the security setup, a proxy is required as well.

After entering the details check the connection:

Now go to the configuration of the interface scenario and create a new cloud service for Ariba Network Transaction:

On the Monitoring tab connect to the end point create above and set the wanted filters:

If you want, you can also set up alerting in the third tab.

Save and activate the setup.

Now you can model the scenario graphically as well:

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>

SAP Focused Run demo system and OpenSAP course

The SAP site for Focused Run has a link to the online Focused Run demo system and link to videos.

First visit the general SAP Focused Run site. Now scroll down to the resources part:

On the right hand side are the video.

In the middle the Demo System link. You can also access it directly via this URL.

Scroll down to the landscape overview. To access the system press the blue “SAP Focused Run launchpad button”.

The user ID and password is in the table below the button.

OpenSAP training on SAP Focused Run

SAP is providing training on SAP Focused Run on the OpenSAP online platform. Follow this link for the main training.

Content of the online training:

Older background material

Some older, but still useful, background material can be found on this link.

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>

SAP Focused Run housekeeping and technical clean up

Housekeeping in SAP Focused Run is needed for 3 reasons:

  1. Keep performance high
  2. Reduce data footprint on the database
  3. Stay within the licensed volume (see more on licenses of SAP Focused Run in this blog)

Questions that will be answered in this blog are:

  • Which housekeeping settings can I make in SAP Focused Run?

Housekeeping for alert and event management

For alert and event management housekeeping program:

Housekeeping for system analysis and root cause analysis

For system analysis housekeeping schedule program SRAF_LOG_HOUSEKEEPING and WEA_AGG_STORE_PARTITIONING. For root cause analysis schedule program RCA_HOUSEKEEPING.

Detailed settings for RCA housekeeping are done in table RCA_HKCONFIG. You can maintain this table with SM30:

Housekeeping for application integration monitoring

For application integration monitoring housekeeping schedule program /IMA/HOUSEKEEPING for older releases and /IMA/HOUSEKEEPING_NEW for FRUN 3.0 FP01 onwards.

In the tile for integration monitoring you maintain the detailed settings and retention periods:

Press the change button to alter the data retention periods towards your need:

Housekeeping for EWA data

For EWA data housekeeping schedule program FRUN_DELETE_SERVICE_DATA:

Important year: default 1 year of EWA data is kept. If you need more, increase the days kept. If you want to clean up more, you can reduce the days.

Housekeeping for health monitoring

For health monitoring housekeeping, schedule program OCM_HOUSEKEEPING.

Housekeeping for statistical records

For housekeeping of statistical records, schedule program AI_STATRAGG_HOUSEKEEPING:

Housekeeping for work mode management

For housekeeping of work mode management, schedule program WMM_HOUSEKEEPING:

Housekeeping for security and configuration validation

In the Configuration and configuration analytics Administration tile, choose the configuration icon:

Here you can set the retention period.

Technical clean up

There are also technical tables that might grow fast in SAP Focused Run that will consume memory in your HANA database.

Fast growing table LMDB_P_CHANGELOG

See OSS note 2610122 – Cleaning up the change history in the LMDB: run program RLMDB_CLEAR_CHANGELOG.

Fast growing SISE_LOG table

Run program SISE_LOG_DELETE to clean up SISE_LOG table. See OSS note 2984789 – Scenario F4-help not working for SISE_LOG_DELETE report.

Idoc and PI monitoring data fast growing

If you get too much data for idoc monitoring, apply OSS note 3241688 – Category wise table cleanup report (IDOC, PI). This note delivers program /IMA/TABLE_CLEANUP_REPORT for clean up.

Invalid entries in MAI_UDM_PATHS

If table MAI_UDM_PATHS is getting large, follow the instructions from OSS note 3030652 – Cleanup invalid entries from database table mai_udm_paths to clean up. It is explained in more detail in OSS note 3250729 – Housekeeping for metric paths. And read OSS note 3424812 – MAI housekeeping does not allow ad hoc execution for ad hoc clean up.

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>

ABAP cleaner Eclipse plugin

The ABAP cleaner Eclipse plugin is a great tool to clean up your ABAP code according to the ABAP clean code principles.

Questions that will be answered in this blog are:

  • How to install the ABAP cleaner Eclipse plugin?
  • How to run the ABAP cleaner?
  • How to configure the ABAP cleaner?

Installation of the ABAP cleaner Eclipse plugin

Follow the instructions on the ABAP cleaner site for installation. In short, just like you install the ADT tools, now put in the site “https://sap.github.io/abap-cleaner/updatesite“. Download the software and ignore the certificate warnings. Eclipse restart is required.

Running ABAP cleaner

Basic use instructions can be found on the ABAP cleaner site. We will use this example code:

REPORT zcleanerdemo.

* ABAP clean code demo
Data: abap_true type boolean.
data: do_not_do_anything type boolean.

write:/ 'Hello world'.

if abap_true <> 'X'.
write: 'ok'.
else.
write: 'not ok'.

endif.

Yes, this code is ugly.

In Eclipse right click on the code and select the option Source Code and then the option Clean up with Interactive ABAP cleaner…

It is best to start always with the interactive cleaner so you have insights and control on the changes done to your source code.

On the left hand side you see your old code. On the middle the code changes proposed. On the right hand side you see the clean up settings.

The profile is determining the rules used. Out of the box you get the default and essential profile. It is advised to play around and build your own set using the Configure button (see next chapter in this blog).

You can set the clean up range: from current statement, current method, current class to whatever code you opened in Eclipse (multiple windows). You might wonder, why only current statement or method? Remember one of the clean code principles is the boy scout rule; leave the code better than how you found it. So no need to refactor old stuff completely, do it chunk by chunk every time.

The restrict rules of syntax can be set to the latest ABAP release or to a specific release.

If you click on a rule, you can see the rules applied in bottom right part of the screen:

If you are happy with the changes press the Apply and close button.

ABAP cleaner configuration

On the screen above when you hit the Configure button you reach the configuration screen:

This screen is overwhelming when you start. Top right you can manage your profiles. Create new ones or copy from templates. Bottom right you can switch on and off which detailed rule is part of the profile. On the top right you can fine tune the exact details of each rule according to your needs and preferences.

The changes you make will be made instantly available on the example, so you can immediately assess the impact of your fine tuning.

Word of care: take care that ABAP cleaner and Pretty printer are not constantly juggling your code around.

SAP Focused Run alert management outbound integration to ServiceNow

SAP Focused Run alert management function can send out mails to alert to mail addresses (see this blog).

SAP Focused Run can also call an outbound integration to a ITIL tool like ServiceNow. This can help to speed up incident creation.

It needs implementation on ABAP level. The coding is given at the end of the blog.

Questions that will be answered in this blog are:

  • How does the high level integration between SAP Focused Run and ServiceNow look like?
  • Where can I find information on the to-be-implemented ABAP BADI?
  • How can I send an alert directly to ServiceNow from the Alert management detailed page?
  • How can I automate in template settings to send an alert via outbound integration towards ServiceNow?
  • How do I connect from the ABAP stack towards the midserver?
  • Which BADI do I need to activate for the outbound integration?
  • How do I call the midserver connection from the BADI?
  • How do I deal with the differences in severity definition between ServiceNow and SAP Focused Run?
  • If I want to set up the connection via web services, what do I need to do?
  • How can I include application logging in such a way that I can monitor the calls and issues in SLG1?
  • Where can I find the ABAP code needed?

Setting up the integration

For setting up the integration to ServiceNow the AEM third party consumer connection BADI must be implemented. The full manual for the BADI itself can be found on the SAP Focused Run Expert portal.

The documents describes the BADI in generic way.

To call ServiceNow you have to use one of the following 2 integration methods:

  • Call webservice: in this case you import the WSDL from ServiceNow and generate the proxy and execute the SOAMANAGER settings to logon to ServiceNow. You need ABAP code in the BADI to call the proxy. See this blog for generic use of setting up webservice consumption in ABAP stack. Available webservices for ServiceNow can be found on the ServiceNow page.
  • Call the ServiceNow midserver: in this case you call a REST interface. In this case you need to setup a HTTP RFC connection to the midserver. ABAP code in the BADI is needed to make the REST call. See this blog for generic use of REST call in ABAP stack. REST API references from ServiceNow can be found on the ServiceNow page.

Alert trigger integration

If you are inside an alert, you can trigger the alert reaction:

Then select the reaction to forward to ServiceNow:

Within few seconds the alert in ServiceNow is created:

Alert reaction automation in template settings

The alert reaction to ServiceNow can also be automated as Outbound Integration. If you are in template maintenance mode, switch to Expert mode.

In the alerts tab now configure the alert type for Forward to and Outbound Connector:

Assign the correct variant.

If you click on the variant you go to the variant configuration screen:

Then select the outbound integration name to see the details:

Important here is the where used list, which shows you from which templates and template elements the connector is called.

Whenever the alert is raised, also the outbound integration connector to ServiceNow is called.

Set up the RFC destination

In SM59 setup the RFC connection towards the MID server as type H RFC connection:

Activation of the enhancement spot and BADI

The details of the enhancement spot and BADI implementation are in the SAP document published on the SAP Focused Run Expert Portal.

Use transaction SE18 or SE80 to activate enhancement spot ACC_REACTION_EXTERNAL and then activate BADI BADI_ACC_REACTION_EXT.

The result looks as follows:

Double click on the implementation:

Double click on the REACT_TO_ALERT interface to go to the code. The code we implemented looks as below:

METHOD if_acc_reaction_ext~react_to_alert.     
  IF is_alert-ref->get_type( ) <> 'ALERT'.       
    RETURN.     
  ENDIF.     
" Init. the application log.     
  me->zgo_logger = NEW zcl_snow_bi_logger( ). " Add info message to notify reaction was triggered     
  me->zgo_logger->bal_log_add_message(       
    EXPORTING 
       ziv_msgty = zif_snow_constants=>zgc_message_types-info        ziv_msgno = '002'     
     ).     
" Send message to service now     
  NEW zcl_snow_bi_common( )->zif_snow_bi_common~send_message_to_snow(     EXPORTING         
      zii_logger       = me->zgo_logger       
      zii_snow_message = NEW zcl_snow_event_message( zii_alert = is_alert-ref  )
      ziv_resolution_state = zif_snow_constants=>zgc_resolution_state-new     ).     
" Save the application log     
  me->zgo_logger->bal_log_save( ).   
ENDMETHOD.

What do we do in the code:

  1. We only react on type ALERT
  2. We make an entry in the application log (so we can check later on in SLG1)
  3. We call the actual interface which we have implemented in class ZCL_SNOW_BI_COMMON class

The implementation code

The sending code in method ZIF_SNOW_BI_COMMON~SEND_MESSAGE_TO_SNOW that was just called looks as follows:

  METHOD zif_snow_bi_common~send_message_to_snow.

    " Retrieve JSON body for the request
    DATA(zlv_snow_event_json) = zii_snow_message->get_json( ziv_resolution_state ).

    me->add_json_to_bal_log( EXPORTING zii_logger   = zii_logger
                                       ziv_json     = zlv_snow_event_json ).


    TRY.
        " Execute HTTP Post, send data to the MiD API
        DATA(zlv_http_status_code) = NEW zcl_snow_mid_api( )->post( ziv_event_messages = zlv_snow_event_json ).

        " Add HTTP response code to the log..
        IF zlv_http_status_code-code >= 200 AND zlv_http_status_code-code < 300.
          DATA(zlv_msgty) = zif_snow_constants=>zgc_message_types-success.
        ELSE.
          zlv_msgty = zif_snow_constants=>zgc_message_types-error.
        ENDIF.

        zii_logger->bal_log_add_message(
           EXPORTING
             ziv_msgty = zlv_msgty
             ziv_msgno = '001'
             ziv_msgv1 = |{ zlv_http_status_code-code } { zlv_http_status_code-reason }|
         ).

      CATCH zcx_snow_mid_api INTO DATA(zlo_exception).
        "Add exception to the application log
        zii_logger->bal_log_add_message(
          EXPORTING
            ziv_msgid = zlo_exception->if_t100_message~t100key-msgid
            ziv_msgno = zlo_exception->if_t100_message~t100key-msgno
            ziv_msgv1 = CONV #( zlo_exception->if_t100_message~t100key-attr1 )
            ziv_msgv2 = CONV #( zlo_exception->if_t100_message~t100key-attr2 )
            ziv_msgv3 = CONV #( zlo_exception->if_t100_message~t100key-attr3 )
            ziv_msgv4 = CONV #( zlo_exception->if_t100_message~t100key-attr4 )
        ).
    ENDTRY.

  ENDMETHOD.

What happens here:

  1. Data object is build in the data definition (details follow below)
  2. This is logged
  3. The actual call is performed by calling class ZCL_SNOW_MID_API (details follow below)
  4. The result is checked (200 is http code for Ok)
  5. Error result is logged in case of issues

The code for the message content

For the message content, we first define the message event type:

INTERFACE zif_snow_message
  PUBLIC .

  TYPES:
    BEGIN OF zgts_event,
      "! Source
      source           TYPE string,
      "! Name of the object
      node             TYPE string,
      "! Type of object, host, instance
      type             TYPE string,
      "! Severity
      severity         TYPE string,
      "! Date/Time(YYYY-MM-DD HH:MM:SS)
      time_of_event    TYPE string,
      "! Alert description/name
      description      TYPE string,
      "! SAP System ID
      event_class      TYPE string,
      "! Unique ID
      message_key      TYPE string,
      "! Alert state
      resolution_state TYPE string,
      "! Resource
      resource         TYPE string,
    END OF zgts_event.

  METHODS get_json  IMPORTING ziv_resoultion_state TYPE string
                    RETURNING VALUE(zrv_json)      TYPE /ui2/cl_json=>json.

ENDINTERFACE.

This event is used in the actual message build code:

  METHOD zif_snow_message~get_json.

    DATA zlv_events TYPE /ui2/cl_json=>json.

    " Get current time stamp
    GET TIME STAMP FIELD DATA(zlv_time_stamp_now).

    DATA(zlv_event_json) = /ui2/cl_json=>serialize(
      EXPORTING
        data        =  VALUE zif_snow_message~zgts_event(
          source              = |{ syst-sysid } - FRUN |
          node                = zgi_alert->get_managed_object_name( )
          type                = zgi_alert->get_managed_object_type( )
          severity            = me->convert_severity( zgi_alert->get_severity( ) )
          time_of_event       = me->convert_alert_timestamp( ziv_timestamp = zlv_time_stamp_now )
          description         = COND #( LET custom_description = me->remove_html_tags( zgi_alert->get_custom_description( ) ) IN
                                        WHEN strlen( custom_description ) > 0 THEN custom_description
                                        ELSE me->remove_html_tags( zgi_alert->get_sap_description(  ) ) )
          event_class         = substring( val = zgi_alert->get_managed_object_name( ) off = 0 len = 3 )
          message_key         = zgi_alert->get_type_id( )
          resolution_state    = ziv_resoultion_state
          resource            = zgi_alert->get_name( )
        )
        pretty_name = /ui2/cl_json=>pretty_mode-low_case
    ).

    IF zlv_events IS INITIAL.
      zlv_events = zlv_event_json.
    ELSE.
      zlv_events = zlv_events && ',' && zlv_event_json.
    ENDIF.

    IF zlv_events IS NOT INITIAL.
      zrv_json =  '{ "records": [' && zlv_events && '] }'.
    ENDIF.

  ENDMETHOD.

Simple method codes:

  METHOD if_acc_mea~get_managed_object_name.
    rv_managed_object_name = ms_mea-context_name.
  ENDMETHOD.
  METHOD if_acc_mea~get_managed_object_type.
    rv_managed_object_type = ms_mea-context_type.
  ENDMETHOD.
  METHOD if_acc_mea~get_severity.
    rv_severity = ms_mea-severity.
  ENDMETHOD.
  METHOD convert_alert_timestamp.

    " Convert the timestamp
    CONVERT TIME STAMP ziv_timestamp TIME ZONE 'UTC'
      INTO DATE DATA(zlv_date) TIME DATA(zlv_time)
      DAYLIGHT SAVING TIME DATA(zlv_dls_time).


    zrv_date_time = |{ zlv_date+0(4) }-{ zlv_date+4(2) }-{ zlv_date+6(2) } { zlv_time+0(2) }:{ zlv_time+2(2) }:{ zlv_time+4(2) }|.

  ENDMETHOD.
  METHOD if_acc_mea~get_name.
    rv_name = ms_mea-name.
  ENDMETHOD.
  METHOD if_acc_mea~get_type_id.
    rv_type_id = ms_mea-type_id.
  ENDMETHOD.

Helper method to remove HTML tags:

  METHOD remove_html_tags.

    IF ziv_description IS INITIAL.
      RETURN.
    ENDIF.

    DATA(zlv_description) = ziv_description.

    DATA(zlv_newline) = cl_abap_char_utilities=>newline.

    REPLACE ALL OCCURRENCES OF '<h2>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</h2>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<strong>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</strong>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<p>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</p>' IN zlv_description WITH zlv_newline IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<b>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</b>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<u>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</u>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<i>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</i>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<ul>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</ul>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<li>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</li>' IN zlv_description WITH zlv_newline IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<a href="' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF REGEX '">[A-Za-z0-9_\~\-+=&[:space:]]*</a>' IN  zlv_description WITH '' IGNORING CASE.

    REPLACE ALL OCCURRENCES OF ' ' IN zlv_description WITH '_'  IGNORING CASE.
    REPLACE ALL OCCURRENCES OF ':' IN zlv_description WITH ':'     IGNORING CASE.

    zrv_desription = zlv_description.


  ENDMETHOD.

Method to convert severity:

  METHOD convert_severity.

    CASE ziv_sm_severity.
      WHEN 1 OR 2 OR 3 OR 4.
        zrv_sn_severity = 5. " Info
      WHEN 5.
        zrv_sn_severity = 4. " Warning
      WHEN 6.
        zrv_sn_severity = 3. " Minor
      WHEN 7.
        zrv_sn_severity = 2. " Major
      WHEN 8 OR 9.
        zrv_sn_severity = 1. " Critical
      WHEN OTHERS.
        zrv_sn_severity = 0. " Clear
    ENDCASE.

  ENDMETHOD.

This method convert the SAP Focused Run severity code from 1 to 9 towards the codes in ServiceNow. Adjusts the codes per your requirement.

The sending code

The sending code is as follows (for more details on ABAP REST calls, read this blog):

  METHOD post.

    " Initialize the HTTP client
    me->init_http_client( ).

    " Set header
    me->zgo_http_client->request->set_method( method = me->zgo_http_client->request->co_request_method_post ).

    me->zgo_http_client->request->set_content_type( content_type = zgc_content_type ).

    " Set body
    me->zgo_http_client->request->set_cdata( EXPORTING data = ziv_event_messages ).

    " Send the data (POST)
    me->send( ).

    " Receive the response; needed to get the http status code
    me->receive( ).

    " Get the status code
    me->zgo_http_client->response->get_status(
      IMPORTING
        code   = zrs_status-code      " HTTP status code
        reason = zrs_status-reason    " HTTP status description
    ).

  ENDMETHOD.

Subimplementations of the methods:

  METHOD init_http_client.

    cl_http_client=>create_by_destination(
      EXPORTING
        destination              = zgc_destination      " Logical destination (specified in function call)
      IMPORTING
        client                   = me->zgo_http_client  " HTTP Client Abstraction
      EXCEPTIONS
        argument_not_found       = 1
        destination_not_found    = 2
        destination_no_authority = 3
        plugin_not_active        = 4
        internal_error           = 5
        OTHERS                   = 6
    ).

    IF sy-subrc NE 0.
      me->raise_exception_for_sys_msg( ).
    ENDIF.

  ENDMETHOD.
  METHOD send.

    me->zgo_http_client->send(
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        http_invalid_timeout       = 4
        OTHERS                     = 5
    ).

    IF sy-subrc NE 0.
      me->raise_exception_for_sys_msg( ).
    ENDIF.

  ENDMETHOD.
  METHOD receive.

    me->zgo_http_client->receive(
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        OTHERS                     = 4
    ).

    IF sy-subrc NE 0.
      me->raise_exception_for_sys_msg( ).
    ENDIF.

  ENDMETHOD.
  METHOD raise_exception_for_sys_msg.

    RAISE EXCEPTION TYPE zcx_snow_mid_api
      EXPORTING
        textid = VALUE scx_t100key(
                      msgid = syst-msgid
                      msgno = syst-msgno
                      attr1 = syst-msgv1
                      attr2 = syst-msgv2
                      attr3 = syst-msgv3
                      attr4 = syst-msgv4
                  ).

  ENDMETHOD.

What is important here is that in the constant ZGC_DESTINATION is the definition of the H type RFC destination towards the midserver.

Helper code: zcl_snow_event_message

Method ZIF_SNOW_MESSAGE~GET_JSON with input ZIV_RESOULTION_STATE type STRING and returning ZRV_JSON type /UI2/CL_JSON=>JSON, code:

  METHOD zif_snow_message~get_json.

    DATA zlv_events TYPE /ui2/cl_json=>json.

    " Get current time stamp
    GET TIME STAMP FIELD DATA(zlv_time_stamp_now).

    DATA(zlv_event_json) = /ui2/cl_json=>serialize(
      EXPORTING
        data        =  VALUE zif_snow_message~zgts_event(
          source              = |{ syst-sysid } - FRUN |
          node                = zgi_alert->get_managed_object_name( )
          type                = zgi_alert->get_managed_object_type( )
          severity            = me->convert_severity( zgi_alert->get_severity( ) )
          time_of_event       = me->convert_alert_timestamp( ziv_timestamp = zlv_time_stamp_now )
          description         = COND #( LET custom_description = me->remove_html_tags( zgi_alert->get_custom_description( ) ) IN
                                        WHEN strlen( custom_description ) > 0 THEN custom_description
                                        ELSE me->remove_html_tags( zgi_alert->get_sap_description(  ) ) )
          event_class         = substring( val = zgi_alert->get_managed_object_name( ) off = 0 len = 3 )
          message_key         = zgi_alert->get_type_id( )
          resolution_state    = ziv_resoultion_state
          resource            = zgi_alert->get_name( )
        )
        pretty_name = /ui2/cl_json=>pretty_mode-low_case
    ).

    IF zlv_events IS INITIAL.
      zlv_events = zlv_event_json.
    ELSE.
      zlv_events = zlv_events && ',' && zlv_event_json.
    ENDIF.

    IF zlv_events IS NOT INITIAL.
      zrv_json =  '{ "records": [' && zlv_events && '] }'.
    ENDIF.

  ENDMETHOD.

Method Constructor with input ZII_ALERT type IF_ACC_MEA, code:

  METHOD constructor.

    me->zgi_alert = zii_alert.

  ENDMETHOD.

Method CONVERT_ALERT_TIMESTAMP input ZIV_TIMESTAMP type TIMESTAMP, returning ZRV_DATE_TIME type STRING. Code:

  METHOD convert_alert_timestamp.

    " Convert the timestamp
    CONVERT TIME STAMP ziv_timestamp TIME ZONE 'UTC'
      INTO DATE DATA(zlv_date) TIME DATA(zlv_time)
      DAYLIGHT SAVING TIME DATA(zlv_dls_time).


    zrv_date_time = |{ zlv_date+0(4) }-{ zlv_date+4(2) }-{ zlv_date+6(2) } { zlv_time+0(2) }:{ zlv_time+2(2) }:{ zlv_time+4(2) }|.

  ENDMETHOD.

Method CONVERT_SEVERITY input ZIV_SM_SEVERITY type AC_SEVERITY, returning ZRV_SN_SEVERITY type INT4. Code:

  METHOD convert_severity.

    CASE ziv_sm_severity.
      WHEN 1 OR 2 OR 3 OR 4.
        zrv_sn_severity = 5. " Info
      WHEN 5.
        zrv_sn_severity = 4. " Warning
      WHEN 6.
        zrv_sn_severity = 3. " Minor
      WHEN 7.
        zrv_sn_severity = 2. " Major
      WHEN 8 OR 9.
        zrv_sn_severity = 1. " Critical
      WHEN OTHERS.
        zrv_sn_severity = 0. " Clear
    ENDCASE.

  ENDMETHOD.

Method REMOVE_HTML_TAGS, input ZIV_DESCRIPTION type STRING, returning ZRV_DESRIPTION type STRING. Code:

  METHOD remove_html_tags.

    IF ziv_description IS INITIAL.
      RETURN.
    ENDIF.

    DATA(zlv_description) = ziv_description.

    DATA(zlv_newline) = cl_abap_char_utilities=>newline.

    REPLACE ALL OCCURRENCES OF '<h2>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</h2>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<strong>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</strong>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<p>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</p>' IN zlv_description WITH zlv_newline IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<b>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</b>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<u>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</u>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<i>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</i>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<ul>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</ul>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<li>' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '</li>' IN zlv_description WITH zlv_newline IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<a href="' IN zlv_description WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF REGEX '">[A-Za-z0-9_\~\-+=&[:space:]]*</a>' IN  zlv_description WITH '' IGNORING CASE.

    REPLACE ALL OCCURRENCES OF ' ' IN zlv_description WITH '_'  IGNORING CASE.
    REPLACE ALL OCCURRENCES OF ':' IN zlv_description WITH ':'     IGNORING CASE.

    zrv_desription = zlv_description.


  ENDMETHOD.

Helper code: zcl_snow_bi_logger

Exception class ZCX_SNOW_MID_API as redefinition of CX_ROOT with re-implementation of constructor; inputs TEXTID type F_T100_MESSAGE=>T100KEY and PREVIOUS type PREVIOUS.

Code:

  METHOD constructor ##ADT_SUPPRESS_GENERATION.

    CALL METHOD super->constructor
      EXPORTING
        previous = previous.

    CLEAR me->textid.

    IF textid IS INITIAL.
      if_t100_message~t100key = if_t100_message=>default_textid.
    ELSE.
      if_t100_message~t100key = textid.
    ENDIF.

  ENDMETHOD.

Helper class zcl_snow_bi_logger.

Method: ZIF_SNOW_BI_LOGGER~BAL_LOG_SAVE:

 METHOD zif_snow_bi_logger~bal_log_save.

    IF me->zgo_bal_log IS BOUND.

      me->zgo_bal_log->save( ziv_commit = abap_true ).

    ENDIF.

  ENDMETHOD.

Method: ZIF_SNOW_BI_LOGGER~BAL_LOG_ADD_EXCEPTION

Import parameter: ZIX_SNOW_EXCEPTION type ref to ZCX_SNOW_MID_API

Code:

  METHOD zif_snow_bi_logger~bal_log_add_message.

    IF me->zgo_bal_log IS BOUND.

      me->zgo_bal_log->add_message(
        EXPORTING
          ziv_msgty = ziv_msgty
          ziv_msgid = ziv_msgid
          ziv_msgno = ziv_msgno
          ziv_msgv1 = ziv_msgv1
          ziv_msgv2 = ziv_msgv2
          ziv_msgv3 = ziv_msgv3
          ziv_msgv4 = ziv_msgv4
      ).

    ENDIF.

  ENDMETHOD.

Method: ZIF_SNOW_BI_LOGGER~BAL_LOG_ADD_FREE_TEXT

Inputs ZIV_MSGTY type SYMSGTY and ZIV_TEXT type ZCL_BC_BAL_LOG=>ZGTV_FREE_TEXT “(which is TYPES zgtv_free_text TYPE c LENGTH 200) .

Source:

  METHOD zif_snow_bi_logger~bal_log_add_free_text.

    IF me->zgo_bal_log IS BOUND.

      me->zgo_bal_log->add_free_text(
        EXPORTING
          ziv_msgty = ziv_msgty
          ziv_text  = ziv_text
      ).

    ENDIF.

  ENDMETHOD.

Constructor code:

  METHOD constructor.

    me->zgo_bal_log = zcl_bc_bal_log=>factory(
        ziv_object     = zif_snow_constants=>zgc_bal_log-object
        ziv_sub_object = zif_snow_constants=>zgc_bal_log-sub_object
    ).

  ENDMETHOD.

Using the ServiceNow web services

The ServiceNow webservices including instructions on how to download the WSDL are published on the ServiceNow help web pages.

Download the WSDL file and follow the instructions from this blog to import the WSDL file inso SE80 and generate the ABAP web service proxy object. In SOAMANAGER setup the logical port towards your ServiceNow installation and make sure the connection is working.

Then implement the ABAP code as above.

In stead of calling the REST service, you now call the ABAP proxy generated:

* Data Declarations
DATA: zcl_proxy TYPE REF TO zco_zbapidemowebservice, " Proxy Class
      zdata_in  TYPE zzbapidemo, " Proxy Input
      zdata_out TYPE zzbapidemoresponse, " Proxy Output
      zfault    TYPE REF TO cx_root. " Generic Fault

* Instantiate the proxy class providing the Logical port name
CREATE OBJECT zcl_proxy EXPORTING logical_port_name = 'ZDEMOWS'.

* Set Fixed Values
zdata_in-zimport = '1'.

TRY .
    zcl_proxy->zbapidemo( EXPORTING input = zdata_in
                          IMPORTING output = zdata_out ).
    WRITE: / zdata_out-zexport.
  CATCH cx_root INTO zfault.
* here is the place for error handling

ENDTRY.

Off course you will use the generated in and out data from the generated service.

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>

SAP Focused Run system analysis overview

System analysis is part of the Root Cause analysis functions of Focused Run. It can be used for issues analysis of current issues and for longer term trending.

Questions that will be answered in this blog are:

  • How can I start execute System Analysis for a system?
  • Which type of systems can be analysed with System Analysis?
  • How can I use the System Analysis tool for immediate analysis of issues with a system?
  • How can I use the System Analysis tool for getting insight in the longer term trends inside a system?
  • How to set up System Analysis for performance analysis?

System analysis

Start the system analysis function by clicking on the Fiori tile for System Analysis:

Select the system you need to analyze for issues in the scope selection screen. In the first case we take an ABAP stack with time frame of the last 6 hours:

This overview might be bit overwhelming the first time. But you can see the performance was bad in the middle of the day (see top middle graph on average response time). Bottom middle graph shows CPU of some application servers was at 100%. And at the same time there were many dumps (right middle graph). This gives a clear direction were to look for issues.

The system analysis overview adjusts the information automatically to its content. This is the information for a HANA system:

Note here that the time frame here is from the last month. This is for getting longer term overview of the system behaviour. You can get this longer term overview by changing the time frame of the system analysis tool.

Page catalog

You can select a specific view from the page catalog list on the left button bar on the screen:

So you can easily filter the specific page for the type of system you need to analyze.

Performance analysis in System Analysis

In the system analysis function there is a special function to monitor system performance based on ST03 system data from the managed system.

Choose the menu option for ABAP performance:

The performance overview will now open:

You can click on many items now to get to the details.

Setup of Performance Analysis

To make the above function work;, click on the settings wheel and click on the Configure Collection of ABAP performance data:

Make sure the system you need analysis data from is activated correctly.

If the data collection is not ok, check the Collector Status button and Agent logs. Also check the backend system user used to see if this user has sufficient authorization to fetch the required data.

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>

SAP Focused Run license and usage

SAP Focused Run is a licensed product. The metric is amount of GB stored in the application.

If you have more systems, more detailed metrics, with short measurement times and many functions, the more GB you will use.

Questions that will be answered in this blog are:

  • How to check the current license usage?
  • What drives the usage?
  • How can I get a cost estimate?
  • How can I create a business case for Focused Run?

Checking the license usage

In SE38 start program FRUN_USAGE_UPDATE:

Now you can see which Focused Run function uses how many MB’s.

What drives the usage?

Usage is driven by:

Getting a cost estimate

Your SAP account manager or the Focused Run team in Germany can give you a good cost estimate. Material number for Focused Run in the price list is 7019453.

Input for cost estimate: sizes and numbers of systems, functions of Focused Run you want to deploy, and the retention period of the data.

Output: cost estimate.

Creating the business case

The business case has 2 aspects:

  • Cost: infrastructure, license, implementation
  • Benefits

Benefits is easier to quantify if your IT service is more mature.

Elements to consider:

  • How much does an hour of outage cost on your main ECC or S4HANA core system? For lager companies, this is easily 10.000 Euro per hour or more.
  • How much does your complaint handling cost per ticket?
  • How much time is currently spent on manual monitoring?

Benefits of SAP Focused Run are then in avoiding half the outages by faster insights and reducing the outage costs. You cannot avoid all outages, but you can act faster.

Benefits of Focused Run are in improved clean up and issue solving. This will both reduce issues in your systems and reduce complaints and tickets you need to handle.

For larger system landscapes (more than 50 systems) the business case is quite easy to create and will be positive fast.

<< This blog was originally posted on SAP Focused Run Guru by Frank Umans. Repost done with permission. >>