How-to Use TVARVC Values via ABAP

The STVARV Transaction has been used to configure the TVARVC table, now what?

Anywhere within the BW application that you have access to execute snippets of ABAP code, you can use a ‘SELECT ___ FROM TVARVC WHERE ___’ statement to get access to the configured values:

  • Transformation routines;
  • DTP and InfoPackage selection filters;
  • Process Variants;
  • Function module based Virtual Providers;
  • Generic Extractors;
  • Variables for Reporting.

Here is a simple code snippet to show how this can be done for TVARVC Parameter records, not TVARVC Selections records.

"Note: The code snippet below will populate the L_PERSON_LOAD local
"      variable with a default value and then override it with the
"      value in the ZBW_PERSON_LOAD record from the TVARVC table.
"Note: This approach of (1) Default Value and then (2) TVARVC override
"      allows for situations where the TVARVC ZBW_PERSON_LOAD
"      record does not exist. It allows the executing program to
"      continue without aborting while achieving the goal of an
"      optional 'Configuration Override' functionality.
"Note: To use this code in a different specific scenario, just replace
"      all occurances of 'person_load' with a name that clearly
"      identifies the specific purpose of the new local variable and
"      its matching TVARVC parameter record.


  c_tvarvc_person_load type rvari_vnam value 'ZBW_PERSON_LOAD',
  c_tvarvc_person_load_type type rsscr_kind value 'P',
  c_person_load_default type tvarv_val value 'X'.

  l_person_load type tvarv_val.

* Ensure a default value is assigned.
  l_person_load = c_person_load_default.

* Get the TVARVC configuration value.
  select single low
    from tvarvc
    into l_person_load
   where name = c_tvarvc_person_load
     and type = c_tvarvc_person_load_type.

"Note: Any code implemented below will be working on the assumption
"      that the L_PERSON_LOAD variable will always be a valid value.
"Note: It will be the matching TVARVC parameter value or the
"      hardcoded default value if the TVARVC record does not exist.

* Next Step: Use 'l_person_load' variable to for the business rule.

Where has this optional override configuration technique been useful?