HowTo restrict F4 Help Values for hierarchies in Bex variable screen
I read recently some great articles about the new enhancement framework from Thomas Weiss. You can find the series in the SDN wiki here.
I got an idea, how easy it is to extend SAP classes or function modules for customers without making modifications! In my article I want to show you how you can restrict the hierarchies for profit center if user presses F4 help on a hierarchy variable in the Bex variable screen with the enhancement framework.
I created a few very simple hierarchies on profit center.
I created a very simple query on a cube where I had Profitcenter, Fiscal period and Amount. It simply shows the periodic costs for the profit centers. Then I created a hierarchy variable and a hierarchy node variable and added it to the query as filters for profit center.
The corresponding variable for hierarchy nodes:
The query itself looks simple:
If you execute the query, the variable screen appears and asks you to choose a hierarchy. If you press F4 button for value help for the hierarchies, BW standard displays all hierarchies of profit center. In my example, I got this result.
This is not very comfortable, especially if the user is restricted to one or two hierarchies only. He has to know which to choose or find out with trial and error the hierarchy he’s authorized for. It would be nice to have an option where you can display the hierarchies only the user is granted for or hide those hierarchies which should not be used for a query. I debugged the F4 help in ABAP and Java Web. I found out, standard BW ends up in the function module RSR_HIER_IOBJ_GET. Unfortunately I found no parameter to restrict the hierarchies. Of course I don’t want to make a modification to this function module. The new enhancement framework now gives you a very easy solution to solve this problem.
The first thing you have to do is create an enhancement. In transaction SE37 choose function module “RSSH_HIER_OF_IOBJ_GET” and display code. Go to menu Function Module->Enhance Source Code. The source code will be displayed in a sort of modification view. Now you can go to menu EDIT->Enhancement Operations->Show Implicit Enhancement Points. You will see an enhancement point at the beginning and at the end of your function module.
In this very simple demo case extending the function module at the end is the appropriate thing. I take the results of the function module and delete all hierarchies from the result table except one. But you could also think of an authorization table to select the authorized hierarchies or implement any algorithm to restrict the number of hierarchies displayed. Because it is the central end point for all hierarchies of every infoobject, you should restrict the function to only this infoobject and/or user you want to restrict. For any other infoobject and/or user the code will not be executed. For use in authorization you have to make sure that you have taken users with star-authorization into account. Otherwise it can happen that users couldn’t choose any hierarchy to this infoobject.
Now place your curoso at the second enhandement point at the end of the standard code and go to menu EDIT->Enhancement Operations->Create Enhancement. In the following Popup you will we be asked if you want to enhance declaration, code or cancel this operation. I choose “Code”. In the next window you enter the name your enhancement like this:
Now you can enter your code, save and activate and test it. After activation the function group will also be recompiled!
Now save and activate your enhancement. The function module will also be re-compiled. Now execute the query again. Press F4 help on your hierarchy variable. The result will be that:
The result is really overwhelming.
But overall, I think we should expect from BI to implement these features with simple GUI activities. We are really wary of ABAPing in BI for small things.
Thanks for such a Blog. Quite helpful. But my scenario is different here. I want to restrict hierarchy display based upon Query/Report not user. Below is my scenario:
We have one query that is using GL Account InfoObject. We are displaying GL account as Hierarchy in Bex Output. There are 5 hierarchies in BW for GL Account Info Object.
I created one Variable to select hierarchy while running the query. When users select this variable it displays all 5 hierarchies available for GL Account InfoObject. But, for Balance sheet query, only 3 hierarchies are relevant and users only want to see those 3 hierarchies. Rest 2 hierarchies are relevant for Profit and loss queries. Same user when run P/L query he should only see those 2 hierarchies.
So in nutshell, users only want to see relevant hierarchies as per queries. Same user will run these reports, so we cannot restrict hierarchies for users by authorizations.
Is there any way to do this? Can we achieve this as per your Blog. If I find the query name in this function Module, I will be able to achieve this, but how to find query name in this module. Please guide me.
Can you please help me with my question?
Please guide me.
Regards
Amandeep Sharma