Show TOC

SAPSetVariableLocate this document in the navigation structure

With this API method, you can define values for input-ready BW variables (prompts). If you want to set multiple variables, you can use the PauseVariableSubmit command with the SAPExecuteCommand method.

To call the method, use Application.Run and specify the following input parameters:

  • Prompt Name

    Name or technical name of the BW variable to be filtered.

  • Prompt Value

    String that represents the value for the prompt, for example the key. Note the syntax rules for entering values.

  • Value Format
    • Text

      Single member as text.

    • Key

      Single member as key.

    • INTERNAL_KEY

      Single member with its internal key.

    • INPUT_STRING

      Complex selection of members.

    • INPUT_STRING_AS_ARRAY

      Returns the input string as string as array.

    • LITERAL

      Single member with its internal key.

      With this value format, no immediate validation with the back-end system is executed. This improves the performance.

      This format is only valid if you set the prompt value with its internal key and you use the syntax rule Equal To.

      If the entered member is not valid, a message is displayed.

    Note The KEY and INTERNAL_KEY depend on the InfoObject modeling in SAP NetWeaver BW.
  • Formula Alias

    Enter the formula alias for the data source. You can set the alias when configuring the data source on the Components tab in the design panel.

    You have to define this parameter if the variables in the workbook are not merged. If the variables in the workbook are merged, you can define this parameter but you do not have to define it.

The system returns one of the following output parameters for each function execution:
  • 0 = execution failed.
  • 1 = execution successful.

Example

Dim lResult As Long

lResult=Application.Run("SAPSetVariable", "0BWVC_COUNTRY", "DE", "INPUT_STRING", "DS_1")

With this example, you set the variable 0BWVC_COUNTRY in data source DS_1 to country Germany.

Example:

Setting multiple variables
Call Application.Run("SAPSetRefreshBehaviour", "Off")
Call Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "On")
Call Application.Run("SAPSetVariable", "0BWVC_COUNTRY", "US")
Call Application.Run("SAPSetVariable", "0BWVC_MATERIAL", "Hardware")
Call Application.Run("SAPExecuteCommand", "PauseVariableSubmit", "Off")
Call Application.Run("SAPSetRefreshBehaviour", "On")
With this example, you set the variable 0BWVC_COUNTRY to country USA and the variable 0BWVC_MATERIAL to material Hardware. Both variables will be executed at once after setting off the command PauseVariableSubmit.