SAP BW Text Variable

SAP BW Text VariableWelcome to the tutorial about SAP BW text variables as part of our free SAP BW training. SAP BW text variable acts as a placeholder for text. You can use these variables in calculated key figures, structures, and query descriptions. The way these variables appear are technical name bounded by ampersands (&). The processing type governs the way in which SAP BW text variable gets filled with values during runtime of the query.

These types of BW variables can have the following processing types:

  • User Entry/Default Value
  • Replacement Path
  • Customer Exit
  • SAP Exit

For instance, let us assume that we have ‘Deliveries Report’ query with Division and Ship-To Party in rows. There are 12 different selections for Delivered Quantity restricted with each of the 12 calendar months (JAN 2016 to DEC 2016) respectively. The screenshot is given below.

Deliveries Report: Query Designer
Deliveries Report: Query Designer

The underlying restrictions in ‘Selection 1’ can be seen in the following screen.

Selection 1 Details
Selection 1 Details

Similarly, there are eleven more selections, one for each calendar month. The screenshots are given below.

Selection 2 Details
Selection 2 Details
Selection 12 Details
Selection 12 Details

There is also a variable on ‘Division’ which gets displayed on the Selection screen of the query. A screenshot is given below.

Select Values for Variables in BEx Analyzer
Select Values for Variables in BEx Analyzer

Let’s execute this query to see what output we get. Let’s select ‘East’ division and click on ‘OK’ highlighted in the below screen.

Select Values for Variables in BEx Analyzer
Select Values for Variables in BEx Analyzer

The following is the report output.

Report Output
Report Output

The report output is not easily comprehendible due to the static descriptions that exist in the columns of the query (Selection 1, Selection 2, Selection 3, Selection 4, …, Selection 12). We can make use of SAP BW text variable for dynamic description of the query columns to make columns more comprehendible. For instance, you can replace ‘Selection 1’ with ‘JAN 2016’ to make the query output more understandable. There is also a requirement to change the query description to show the Division selected by a user during query runtime.

Create SAP BW Text Variable

Changing Query Column Descriptions

Let us now start by creating a new SAP BW text variable for ‘Selection 1’ in the ‘Description’ field. The screenshot is given below.

Creating Text Variable for Query Columns
Creating Text Variable for Query Columns

After clicking on ‘New Variable’ highlighted in the above screen, the following screen appears.

Variable Properties
Variable Properties

Enter the technical name and description as per the following screen.

Variable Properties
Variable Properties

From the list of Processing Types that are available, choose ‘Replacement Path’.

Variable Properties
Variable Properties

Select Reference Characteristic as 0CALMONTH. The screenshot is given below.

Variable Properties
Variable Properties

Now, go to ‘Replacement’ tab. The following screen appears.

Variable Properties
Variable Properties

As can be seen from the following screen, you can replace the variable with Key, External Characteristic Value Key, Label, Attribute Value, and Hierarchy Attribute.

Variable Properties
Variable Properties

As we would like to see the labels in out query output, let’s choose ‘Label’. The screenshot is given below.

Variable Properties
Variable Properties

After clicking on the button highlighted in the above screen, the following screen appears.

Saving the Variable
Saving the Variable

Click on ‘OK’ highlighted in the below screen.

Saving the Variable
Saving the Variable

Now, click on ‘OK’ in the below screen to continue.

Saving the Variable
Saving the Variable

You can now see the new variable in the description field of the selection.

‘Selection 1’ Description with Text Variable
‘Selection 1’ Description with Text Variable

Click on ‘OK’ highlighted in the below screen to proceed.

‘Selection 1’ Description with Text Variable
‘Selection 1’ Description with Text Variable

This is how the Query Definition looks like:

Query Definition
Query Definition

Let’s now change the ‘Selection 2’. There is no need to create a new SAP BW text variable again, we can reuse the existing variable created for ‘Selection 1’. Hence, click on ‘Entry of variables’ highlighted in the below screen.

Entering Text Variable for Query Columns
Entering Text Variable for Query Columns

The following screen appears.

Entering Text Variable for Query Columns
Entering Text Variable for Query Columns

Let’s now select ‘ZCALYRMNTH’ text variable created above for ‘Selection 1’.

Entering Text Variable for Query Columns
Entering Text Variable for Query Columns

Click on ‘OK’ highlighted in the above screen to get the following screen.

‘Selection 2’ Description with Text Variable
‘Selection 2’ Description with Text Variable

Let’s now click on ‘OK’ highlighted in the below screen to proceed.

‘Selection 2’ Description with Text Variable
‘Selection 2’ Description with Text Variable

The following screen appears.

Query Definition
Query Definition

Repeat the process we followed for changing ‘Selection 2’ for all the remaining selections. The following screen appears.

Query Definition
Query Definition

Changing Query Description

As there is also a requirement to change the Query Description to show the Division selected by user during query runtime, we will have to create a new SAP BW text variable and append it to the existing query description.

Go to Query Properties by clicking on the button highlighted in the below screen.

Query Designer: Toolbar (Properties)
Query Designer: Toolbar (Properties)

The following screen appears.

Properties
Properties

Click on “New Variable” highlighted in the below screen to create a new SAP BW text variable.

Creating Text Variable for Query Description
Creating Text Variable for Query Description

The following screen appears.

Variable Properties
Variable Properties

Enter the technical name and description as per the following screen.

Variable Properties
Variable Properties

Now, choose processing type as ‘Replacement Path’ as per the following screen.

Variable Properties
Variable Properties

Select Reference Characteristic as ‘Division’.

Variable Properties
Variable Properties

Now, go to ‘Replacement Path’ tab. The following screen appears.

Variable Properties
Variable Properties

Set ‘Replace With’ field as ‘Label’. The following screen appears.

Variable Properties
Variable Properties

Click on the button highlighted in the below screen.

Saving the Variable
Saving the Variable

The following screen appears.

Saving the Variable
Saving the Variable

Click on ‘OK’ highlighted in the above screen. The following screen appears.

Saving the Variable
Saving the Variable

Now, click on ‘OK’ highlighted in the above screen to proceed. The Query Description now looks as follows (Deliveries Report: &ZTDIVISION&).

Query Definition
Query Definition

Let’s now save our Query by clicking on the button highlighted in the below screen.

Saving the Query
Saving the Query

The following screen appears.

Saved Query: Query Designer
Saved Query: Query Designer

Execute the Query

Let’s now execute the query in SAP BEx Analyzer. This is how it looks like:

Query in BEx Analyzer
Query in BEx Analyzer

Now, select values for variables and execute the query using the ‘OK’ button.

Select Values for Variables in BEx Analyzer
Select Values for Variables in BEx Analyzer

The report output is given below.

Report Output
Report Output

Query Description has the ‘Division’ selected by user during runtime and all the columns are now more understandable.

In SAP BW reports, SAP BW text variable plays a crucial role in making users more comfortable by showing results with appropriate descriptions. Hence, it is of utmost importance to understand what SAP BW text variables is and how to use them cleverly in your reports.

Did you like this tutorial? Have any questions or comments? We would love to hear your feedback in the comments section below. It’d be a big help for us, and hopefully it’s something we can address for you in improvement of our free SAP BW tutorials.

Navigation Links

Go to next lesson: SAP BW Hierarchy Variable

Go to previous lesson: SAP BW Variables

Go to overview of the course: SAP BW Training

2 thoughts on “SAP BW Text Variable”

Leave a Reply

Do you have a question and want it to be answered ASAP? Post it on our FORUM here --> SAP FORUM!

Your email address will not be published. Required fields are marked *