Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

SAP Screen Personas


 

Measuring TIME IN TRANSACTION


SAP SCREEN PERSONAS KNOWLEDGE BASE - by Sebastian Steinhauer

Purpose

In order to evaluate the impact of an SAP Screen Personas project compared to the unchanged transaction a common generic metric is time in transaction. This can be achieved by instrumenting the actual flavor, and recording the start time of the flavor, as well as the end time of the process. The difference between these values gives an easily understandable metric: time in transaction.

Limitation

Please note that this approach is due to an issue with session.utils.logMeasurement currently only supported in SAP GUI for HTML. Please check the section below on "Existing limitation with SAP GUI for Windows 7.40" for an suggested workaround.

Overview

This article will outline how the required measurements can be take and recorded. It will also outline how a simple flavor can be used to facilitate time in transaction measurements without distributing the instrumentation code across the system.

Leverage a Flavor to measure time to execute transaction.

In order to log data against a customer defined measuring point (in /personas/analytics) SAP Screen Personas 3.0 SP02 introduced a specific API. In order to log time in transaction 2 actions need to happen. First the start time and additional meta data needs to be logged to the session memory:

session.utils.put("tcode", ""+tcode);
session.utils.put("flavorId", flavorId);
session.utils.put("time.start", ""+Date.now());

Afterward the usual process steps in question should be executed.
Once the process steps are concluded, the end time needs to be recorded and the time logged to the backend:

var timestop = Date.now();
var timestart = session.utils.get("time.start");
var tcode = session.utils.get("tcode");
var flavorId = session.utils.get("flavorId");
var timeelapsed = timestop - timestart;
var measurement = JSON.stringify({tcode : tcode, flavor : flavorId, timestart : timestart, timestop : timestop, timeelapsed : timeelapsed});
session.utils.logMeasurement("TIMEINTRANSACTION", measurement);

Measuring performance of the Original Screen

The approach outlined above is limited to performance measurements of flavors, as it leverage the SAP Screen Personas flavor itself to record the elapsed time. While convenient for these cases it does not allow to measure performance of the Original Screen. In order to facilitate such a control group the proposed solution is to develop a flavor for the SAP Access Menu transaction SMEN which will start and stop the timer, and either launch a transaction with or without a flavor. This approach allows to contain all the performance measurement code in a single transaction. However, it requires that all transactions return to SMEN on conclusion in order to record the time.
In case of a flavor the above code snipped could also be re-used in the flavor and tied to an appropriate action.

Overall the central measurement flavor should include the following sample coding to be executed on load:

 

var timestop = Date.now();
var timestart = session.utils.get("time.start");
var tcode = session.utils.get("tcode");
var flavorId = session.utils.get("flavorId");
if (timestart){
 var timeelapsed = timestop - timestart;
 session.findById("wnd[0]/usr/lblPersonas_1458081934654").text = timeelapsed + "ms";
 var measurement = JSON.stringify({tcode : tcode, flavor : flavorId, timestart : timestart, timestop : timestop, timeelapsed : timeelapsed});
 session.utils.logMeasurement("TIMEINTRANSACTION", measurement);
 session.utils.put("time.start",""); 
} 
else {
 session.findById("wnd[0]/usr/lblPersonas_1458081934654").text="N/A"
 session.utils.put("time.start","");
}

A start of a transaction with a flavor can be triggered like this:

var tcode = session.findById("wnd[0]/usr/txtPersonas_1458079771239").text;
var flavorId = session.findById("wnd[0]/usr/txtPersonas_1458079780883").text;
session.utils.put("tcode", ""+tcode);
session.utils.put("flavorId", flavorId);
session.utils.put("time.start", ""+Date.now());
session.callTransaction(tcode);
session.utils.changeFlavor(flavorId);

While a start of a transaction without a flavor is slightly more complex as it needs to manually for a flavor change to no flavor (Original View) before starting the timer and execution of the transaction:

var tcode = session.findById("wnd[0]/usr/txtPersonas_1458079771239").text;
//force original screen
session.callTransaction(tcode);
session.utils.changeFlavor("");
session.findById("wnd[0]/tbar[0]/okcd").text = "/n";
session.findById("wnd[0]").sendVKey(0);
session.utils.put("tcode", ""+tcode);
session.utils.put("flavorId", "");
session.utils.put("time.start", ""+Date.now());
session.callTransaction(tcode);

A sample flavor including the above functionality can look like this:

 

Limitations of the approach and further options

This timing method is very basic, and limited to end-to-end time, measured in ms by the JS engine. It does not consider threading, client CPU or network load, processor interrupts, network effects, work process assignments, and co-habitation issues. However, these effects have empirically been observed to be minimal compared to fluctuation due to manual user interaction with the system.

Should the results of this first level of examination be inconclusive of not meeting expectations a more detailed analysis could measure number and time of request per dialog step. Specifically the number and duration of requests to /sap/bc/personas (for script execution)  and /sap/bc/personas3 (images and other SAP Screen Personas specific resources) should be recorded. This should help either identify scripts that might require additional tweaking or resources that should be reduced in since. 

Existing limitation with SAP GUI for Windows 7.40

Due to a mismatch between SAP GUI for Windows and SAP Screen Personas in certain configurations it can happen that session.utils.logMeasurement is not recording the measurements correctly into the measuring point. However it is possible to log the data leveraging a custom RFC.

Here is an example for such a RFC:

function z_personas_log_measurement.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_MSPNT_ID) TYPE  /PERSONAS/MEASUREMENTPOINT
*"     VALUE(IV_MS_DATA) TYPE  STRING
*"     VALUE(IV_TIMESTAMP) TYPE  TIMESTAMPL
*"----------------------------------------------------------------------

  data: lv_timestamp              type                   timestampl,
        lt_measurement_data_pairs type standard table of string,
        lt_measurement_data       type                   /personas/cl_measurement_utils=>tt_items,
        ls_measurement_data       like line of           lt_measurement_data,
        lr_context                type ref to            /personas/cl_context_dynp,
        lr_measurement_hndl       type ref to            /personas/cl_measurement_hndl.

  field-symbols: <lv_measurement_data_pair> like line of lt_measurement_data_pairs.

************************************************************
* Prepare measurement data.
************************************************************

* Check, if timestamp is provided.
  lv_timestamp = iv_timestamp.
  if iv_timestamp is initial.
    get time stamp field lv_timestamp.
  endif.

* Extract required measurement data from provided string.

  "Get "Name:Value" data pairs.
  split iv_ms_data at ',' into table lt_measurement_data_pairs.

  "Save measurement data name and value from each pair into separate table.
  loop at lt_measurement_data_pairs assigning <lv_measurement_data_pair>.
    split <lv_measurement_data_pair> at ':'
     into ls_measurement_data-name ls_measurement_data-value.
    insert ls_measurement_data into table lt_measurement_data.
  endloop.

************************************************************
* Log measurement.
************************************************************

  create object lr_context.

  create object lr_measurement_hndl
    exporting
      ir_context = lr_context.

  lr_measurement_hndl->log_measurement(
    exporting
      iv_mspnt_id         = iv_mspnt_id
      iv_timestamp        = lv_timestamp
      it_measurement_data = lt_measurement_data ).

endfunction.

This RFC stores the data in the same structures and it can be accessed through standard SAP Screen Personas features. However this sample coding is provided without warranty or support by SAP.

The RFC can be called from the script as outlined here:

// Name information, which is required
var firstDataName   = 'currentApplication';
var secondDataName  = 'currentScreen';
var thirdDataName   = 'currentFlavor';

// Get required information
var firstDataValue  = session.info.transaction;
var secondDataValue = session.info.screenNumber;
var thirdDataValue  = session.info.flavorId;

// Combine appropriate name and information into data
var nameValueSeparator = ':';
var firstData = firstDataName.concat(nameValueSeparator, firstDataValue);
var secondData = secondDataName.concat(nameValueSeparator, secondDataValue);
var thirdData = thirdDataName.concat(nameValueSeparator, thirdDataValue);

// Combine all data into one string
var dataSeparator = ',';
var measurementData = firstData.concat(dataSeparator, secondData, dataSeparator, thirdData);


// Call RFC
var oRFC = session.createRFC("Z_PERSONAS_LOG_MEASUREMENT");
oRFC.setParameter("IV_MSPNT_ID", 'VADIMS_MSPNT');  // setting the measuring point parameter
oRFC.setParameter("IV_MS_DATA", measurementData);
oRFC.setParameter("IV_TIMESTAMP", '');  // server timestamp is used if not provided
oRFC.send();

 

 

Sample Flavor

You can download the above sample flavor here: http://file.personas.help/uploads/145824454369731.zip

Related Content

Related Search Terms:

SAP Screen Personas, Analytics, log measure, SP02

 

 

 

 

Important News

This knowledge base is not solely SAP provided content - but community driven. Please also check on SMP and help.sap.com for SAP released information and notes on SAP Screen Personas.

Create New Article

Compare SAP Screen Personas versions

Search the KB

How to Open OSS Message

 What information is needed for creating OSS message?

  1. Make Sure you are on the latest patches and notes.
  2. Kernel Patch Level
  3. Two Types of connections to your environment: HTTP and R/3
  4. All the connections should be tested with proper credentials provided
  5. Steps to re-create the issue
  6. Attach related logs
  7. File tickets against BC_PER