Introduction
From time to time in various projects customers have the following, and without doubts seem as very simple and regular, requirement: to restrict the values which are shown on F4 in BEx query according to some business logic.
The first reaction to such requirement - “use authorizations concept” - obviously miss the fact that it does not give full response to the requirement as well as it does not restrict F4 values at all.
Actually, there are some workarounds. However all of them could be used only in WAD, but not in BEx parameters screen.
Since BI 7.01 SP 09 (SAP Note 1416952) we can use BADI RSR_VARIABLE_F4_RESTRICT that supposed to restrict F4 values which are shown in BEx parameters screen.
Goal
In this article I’d like to show how to control F4 values in BEx query according to some simple logic using this BADI.
Implementation
I’d like to follow the next simple scenario: some users are restricted in their authorizations to some planning versions and they want to select in F4 only allowed values.
As a part of the solution there is some DSO (for example ZOMT_F4) that contains links between users ID and allowed planning versions (according to authorizations). Only these values should be shown on F4 according to use ID although there are many other values of planning versions.
Figure 1 - DSO with links between user ID and version
The final result should be as shown below (if I logged in as a user Z) - only 3 planning versions (which are linked to user Z in DSO) are shown in the parameter screen.
Figure 2 - F4 Screen
First, we need to create some class, for example ZBW_F4_RESTRICTIONS, with two interfaces: IF_BADI_INTERFACE and IF_RSR_VARIABLE_F4_RESTRICT.
Figure 3-The Class
Then, create BADI implementation via SE19.
Figure 4-The Implementation
In the implementing class field put ZBW_F4_RESTRICTIONS.
Figure 5-Implementing Class
In the filter values put your info object technical name (in our example planning version).
Figure 6-The Filter
In the next step go to method GET_RESTRICTION_FLAT and add the following code.
Figure 7-The Code
This code will be executed only for variable “YOUR VARIABLE” and restrict planning version values by user ID according to the values in a DSO, so only these values will be shown at F4 in BEx query.
In addition there are some nice features in the BADI such as possibility to figure out which query/info provider/info object is executed, setting F4 mode (M, A or D), restricting hierarchy nodes etc.