This blog is written to help those developers who would try to restrict the FAGLL03H on cost centers despite it’s an optional field on report.
Problem Statement:
In transaction related to line item browser FAGLL03H and we faced a scenario from business where they want to make cost center as mandatory field so that if a user having no access to a particular cost center would not be able to see the related line items or get an error related to authorization.
The only problem in this case is cost center field is not a mandatory field in selection screen. Now if cost center is not a mandatory field then a user has the option not to enter any value and run it and user will be displayed with all cost center information in a particular G/L, which should not be the case.
Analysis:
The report FAGLL03H has inbuilt validation on cost centers but the pre-requisite is that cost center should be entered on selection screen but as cost center is not a mandatory field , it becomes difficult. So to handle this situation, we followed with note 2443238 which has given us few enhancement points e.g. CREATE_DEFAULT_RESTRICTIONS of BADI FAGL_LIB,SELECT_DATA of BADI FAGL_LIB.
So, we were trying to validate the authority object related to K_CCA in enhancement CREATE_DEFAULT_RESTRICTIONS but later on we found out that if we can select all cost centers for which a user is authorized in his/her roles and pass it to the parameter SELOPT_T , report will automatically will take care of cost center validation.
So here are few tables which can be helpful in next section in case you would like to make cost center validation on FAGLL03H.
Solution:
Combine table AGR_USERS and AGR_1252 to get all relevant authorizations e.g. low field in AGR_1252 is KS* for cost center and HI* for hierarchy(has multiple cost centers).Use CSKS table for picking cost centers.
ls_range-low = -low+6(10).
COLLECT ls_range
INTO -selopt_t.
In above code ,fill the parameter SELOPT_T and this method will get executed when you enter the t-code(before loading of selection screen) and in Fiori once you select the fiori app. So, once you are on Selection-screen you can see the cost centers filled and if you execute the report than report’s standard functionality will validate the cost centers automatically.
You can also follow the below link to make your fields(cost center) as invisible so that user cannot add new cost centers(because cost centers are already selected from roles, there’s no need for user to add new cost centers).
Conclusion:
So to wrap it up, if you need to filter on cost centers in FAGLL03H then you can use the existing field on selection screen and use the above mentioned enhancement to select the cost centers from roles of a user and place it on the cost center field on selection screen.
It will ensure that standard functionality of the report stays intact and we are doing minimal changes in enhancement.
Please comment below if there is any question or doubt related to this blog.