Show TOC

Using Selection ObjectsLocate this document in the navigation structure

Use

A selection object lets you specify a set of application components, packages, and programs for which you want to have coverage results calculated. Use a selection object with method IF_SCV_MEASUREMENT->BUILD_SELECTION_RESULT.

The advantage of using selection objects is that you can tailor the set of entities for which you want code coverage results calculated. For example, you can get results for an entire application component, yet still exclude packages that you do not want to see in the results.

Working with an Object Selection - Standalone Measurement

Here is how to use an object selection with a standalone measurement. This code snippet uses the INCLUDE and EXCLUDE methods of IF_SCV_SELECTION to customize the results calculated for a component.

You start by instantiating a selection object. You put the selection into effect by providing it as an argument to the IF_SCV_MEASUREMENT->BUILD_SELECTION_RESULT method.

* Customize the results with an object selection
* An object must be created, as it is not initially present. 

DATA: factory   TYPE REF TO if_scv_factory, 
      selection TYPE REF TO if_scv_selection,
      result    TYPE REF TO if_scv_result, 
      display   TYPE REF TO if_scv_result_display.

factory = cl_scv_coverage_api=>get_factory( ).
selection = factory->create_selection( ).

* Include my main component
selection->include_component( 'BC-CCM-MON' ).
* But exclude this component - doesn't belong to me
selection->exclude_component( 'BC-CCM-MON-SHM' ).
* And exclude this package as well
selection->exclude_package( 'SCSM' ).
* And exclude this program too
selection->exclude_program( 'S_TEST_FRAMEWORK' ).

* Do some measuring of code coverage...

* Calculate the results for the selected objects
result = measurement->build_selection_result( i_selection = selection ).

* Display the results in a graphical pop-up - 
* show_as_fullscreen also available
display = cl_scv_coverage_ui=>get_result_display( result ).
display->show_as_popup( ).

            

Working with an Object Selection - Measurement Series

You can save a selection as the default of a measurement series. When you first set up a measurement series, do the following before you save the series for the first time:

  • Obtain the selection object from the series with IF_SCV_SERIES->GET_SELECTION.

  • Set up the default object selection for the series.

When you save the series, the selection is saved with it. The series passes the saved selection automatically to IF_SCV_MEASUREMENT->BUILD_SELECTION_RESULT in the context of the series.

In effect, you can streamline and standardize the calculation of results in the series. One method call returns the standard set of results.

You can still calculate additional results in a message series. You can either call the BUILD methods that specify the entities for which results are to be calculated. Or you can substitute a different selection object for the series default object.

For details, see Step 2: Setting Defaults for a Measurement Series and Step 4: Calculating Coverage Results in a Measurement Series in the measurement series tutorial.

Object Selection Methods

Here are the methods you can use to tailor an object selection.

Note

An empty selection or a selection that specifies only exclusions are not supported. These selections cause an exception of type CX_SCV_CALL_ERROR in IF_SCV_MEASUREMENT->BUILD_SELECTION_RESULT.

Use these methods to include or exclude a single component, package, or program in a selection object.

Method of IF_SCV_SELECTION

Use

exclude_component

Exclude an application component in the component hierarchy from the code coverage results.

Example: If you request coverage results for objects in component BC-CCM-MON, you can use exclude_component( i_name = 'BC-CCMS-MON-SHM' ) to exclude the SHM subcomponent of BC-CCM-MON from the results. Objects that belong to BC-CCM-MON-SHM are also excluded from the results.

exclude_package

Exclude an ABAP package and its objects from the code coverage results.

Example: If you request coverage results for objects in component BC-CCM-MON, you can use exclude_package( i_name = 'SMOI' ) to exclude that package and its objects from the results.

exclude_program

Exclude an ABAP program by name from the code coverage results.

For class pools and function groups and modules, the API needs the full technical name. For a class, this is the class pool name, not CL_CCMS_AL_DATA_ENVIRONMENT, but CL_CCMS_AL_DATA_ENVIRONMENT===CP. For a function group, this is the function pool name, not SALK but SAPLSALK.

You can use the RS_TADIR_TO_PROGNAME function module to translate an object entry ( Start of the navigation path Goto Next navigation step Object Directory Entry End of the navigation path) to a technical program name. For example, object type FUGR and object name SALK yields the function pool name SAPLSALK.

include_component

include_package

include_program

Include a component, package, or program and any subcomponents in the code coverage results. For details, see the EXCLUDE-methods above.

Use these methods to include or exclude ranges of objects in a selection object.

Method of IF_SCV_SELECTION

Use

get_component_range

get_package_range

get_program_range

These methods return the specifications in the selection object for each of these categories of entities. For example, you might see that a component is to be included and a set of packages is to be excluded.

get_root_components

get_root_packages

These methods evaluate the relationships in the selection specifications and return root component and package specifications.

Example: If you have specified that a selection object should include components BC-CCM-MON and BC-CCM-MON-SHM, then the get_component_range method returns both component specifications, get_root_components returns only the specification for BC-CCM-MON.

set_component_range

set_package_range

set_program_range

With these methods, you can write a set of object selection specifications to a selection object.

The methods take as a parameter a ranges table, with which you can flexibly define sets of entities.