On this page:

The ABAP language does not support dynamic byte code instrumentation (such as Java), so it is not possible (or officially supported by SAP) to intercept arbitrary ABAP commands during runtime.

This section describes the procedure for manual ABAP code adjustments, which are useful when automatic instrumentation is not supported.

Please note that this section covers only the enhancement of already detected business transactions, i.e. the code must be executed in the context of the existing business transaction, otherwise it is not monitored.

SAP GUI dialog transactions are reconstructed into business transactions from log data, so no business transaction context exists during runtime.

Custom Actions

To enable the collection of performance data for a section of custom ABAP code, use the /DVD/APPD_CL_RUNTIME class to start and stop the runtime measurement:

* Start action runtime measurement
  /dvd/appd_cl_runtime=>action_start( iv_name = 'Custom action 1' ).

* Custom ABAP code to be monitored
....

* Stop action runtime measurement
  /dvd/appd_cl_runtime=>action_stop( ).
CODE


The preceding code collects the number of calls and the total runtime of the specific action. These metrics are stored in the transaction snapshot (top five custom actions ordered by runtime).

Ensure the action_stop( ) is always called for the monitored action:

  • If an exception is raised during the action, call the action_stop( ) method in the CATCH section to stop the measurement
  • Ensure there are no EXIT, RETURN or other commands which interrupt the action and avoid the action_stop( ) call

If the runtime measurement is not stopped properly, the performance data might not be collected or can be collected incorrectly.

Custom RFC Exit Calls

To enable correlation of custom RFC calls, adjust the ABAP code before and after the CALL FUNCTION ... DESTINATION as mentioned in the example:

* Declare local variable for AppD Correlation Header
  DATA: lv_appd_header TYPE STRING.

* Start the exit call for function module and remote destination
  lv_appd_header = /dvd/appd_cl_agent_rfc=>client_before_rfc( 
                                            iv_funcname    = 'Z_MY_RFC_FUNCTION'
                                            iv_destination = 'MY_RFCDEST' ).
* Custom RFC call
  CALL FUNCTION 'Z_MY_RFC_FUNCTION'
    DESTINATION 'MY_RFCDEST'
    EXPORTING 
      iv_appd_header = lv_appd_header
      ...
    IMPORTING ...
    EXCEPTIONS ... .
 
* Stop the exitcall
  /dvd/appd_cl_agent_rfc=>client_after_rfc( ).
  sy-subrc = /dvd/appd_cl_agent_rfc=>sv_subrc.   "restore SY-SUBRC after the call
CODE


The code above starts a new exit call to the RFC backend. If the target system is an instrumented ABAP or Java system, then the correlation information is propagated and the business transaction continues on the target system. 

For ABAP target systems, the user associated with the RFC destination, or the user making the RFC call must have sufficient authorizations on the target system. See SAP Authorizations (auth. role /DVD/APPD_RFC_ABAP).

For RFC exit calls to work properly on Java JCo Server, the Java system must be restarted after the first installation of the JCo plugin version 4.5.2002 or newer.

Only the following RFC destination types are supported for custom RFC exit calls:

  • ABAP Connections (type '3' destination)
  • TCP/IP connections (type 'T' destination)

Please make sure that the used destination is a supported destination type before enhancing your code.