Welcome 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.
The underlying restrictions in ‘Selection 1’ can be seen in the following screen.
Similarly, there are eleven more selections, one for each calendar month. The screenshots are given below.
There is also a variable on ‘Division’ which gets displayed on the Selection screen of the query. A screenshot is given below.
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.
The following is the 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.
After clicking on ‘New Variable’ highlighted in the above screen, the following screen appears.
Enter the technical name and description as per the following screen.
From the list of Processing Types that are available, choose ‘Replacement Path’.
Select Reference Characteristic as 0CALMONTH. The screenshot is given below.
Now, go to ‘Replacement’ tab. The following screen appears.
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.
As we would like to see the labels in out query output, let’s choose ‘Label’. The screenshot is given below.
After clicking on the button highlighted in the above screen, the following screen appears.
Click on ‘OK’ highlighted in the below screen.
Now, click on ‘OK’ in the below screen to continue.
You can now see the new variable in the description field of the selection.
Click on ‘OK’ highlighted in the below screen to proceed.
This is how the Query Definition looks like:
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.
The following screen appears.
Let’s now select ‘ZCALYRMNTH’ text variable created above for ‘Selection 1’.
Click on ‘OK’ highlighted in the above screen to get the following screen.
Let’s now click on ‘OK’ highlighted in the below screen to proceed.
The following screen appears.
Repeat the process we followed for changing ‘Selection 2’ for all the remaining selections. The following screen appears.
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.
The following screen appears.
Click on “New Variable” highlighted in the below screen to create a new SAP BW text variable.
The following screen appears.
Enter the technical name and description as per the following screen.
Now, choose processing type as ‘Replacement Path’ as per the following screen.
Select Reference Characteristic as ‘Division’.
Now, go to ‘Replacement Path’ tab. The following screen appears.
Set ‘Replace With’ field as ‘Label’. The following screen appears.
Click on the button highlighted in the below screen.
The following screen appears.
Click on ‘OK’ highlighted in the above screen. The following screen appears.
Now, click on ‘OK’ highlighted in the above screen to proceed. The Query Description now looks as follows (Deliveries Report: &ZTDIVISION&).
Let’s now save our Query by clicking on the button highlighted in the below screen.
The following screen appears.
Execute the Query
Let’s now execute the query in SAP BEx Analyzer. This is how it looks like:
Now, select values for variables and execute the query using the ‘OK’ button.
The report output is given below.
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
Nice post, clear and easy to understand with your example.
Thank you.
Nice explanation Prashanti. but instead of january 2019 how iu got jan 2019 ?