Hiding Fields Dynamically based on Roles in MDGM for EHP 5.0
SAP Master Data Governance software helps organizations govern financial, material, customer, or supplier master data from its creation in a business application through its replication to target applications to ensure data quality and regulatory compliance across the enterprise
Master Data Governance for Materials in general supports governing of objects like General Data, Descriptions, Unit Of measure, Basic Text, Internal Comment, Class Assignment and Characteristic Valuation. It always possible to extend the standard Data Model provided by SAP to govern either existing fields in table related to material or custom fields that are added to the standard table using extensions. Master Data Governance has also provided standard UI’s with which user can enter values. This document shows of how fields can be hidden dynamically based on the User role
This is the standard Materials UI provided by SAP.
You should having developer access for creating components and creating new configurations. You should have some knowledge of Web Dynpro ABAP.
MDG comes up with a standard BADI in EHP 5.0 in which you have the flexibility to make a field read only or Hidden based on roles. You can access the BADI using MDGIMG
Create an implementation class and provide a filter so that it works only for that particular UI
Now, in the implementation Class you have a method Modify_Definition through which you can hide fields.
In this example, we have maintained a custom table in which we have maintained the Roles Names and the corresponding views to be hidden.
data: lt_roles type standard table of agr_users, lt_role_tab type standard table of xxxx , “custom table wa_role_tab type yyyy, “custom structure wa_roles type agr_users. data: wa_hideview like line of et_hide_view. select * from xxxx into corresponding fields of table lt_role_tab. call function 'CKEXUTIL_USER_TO_ROLE' exporting i_uname = sy-uname tables et_agr_users = lt_roles. loop at lt_roles into wa_roles . read table lt_role_tab into wa_role_tab with key role = wa_roles-agr_name. if sy-subrc = 0. loop at lt_role_tab into wa_role_tab where role = wa_roles-agr_name. wa_hideview-mainview = wa_role_tab-tab. “ pass the View name to be hidden append wa_hideview to et_hide_view. endloop. endif. clear: wa_role_tab, wa_roles. endloop.
We use method Modify_view to hide fields in a view.
The same example as above is used here
*** code added for hiding fields for global approver
data: lt_roles type standard table of agr_users,
wa_roles like line of lt_roles.
call function ‘CKEXUTIL_USER_TO_ROLE’
i_uname = sy–uname
et_agr_users = lt_roles.
read table lt_roles into wa_roles with key agr_name = ‘yyyy’.
if sy-subrc = 0.
data: wa_property like line of et_property.
loop at et_property into wa_property.
wa_property–read_only = ‘X’.
modify et_property from wa_property index sy–tabix.