Consider there is a requirement to create a role based web application for use by the administrators and managers that displays employee details. Managers are allowed to view complete information of an employee, the administrators have only restricted view access.
For example, managers have access to annual salary, rate and expense; and the administrative user can only view the expense details along with the other information, but not the annual salary and the rate.
Even though there are different ways to achieve the result, the formlayout tag of PHTMLB BSP extension gives more flexibility for the developer to customize the page with less effort and minimal change in the code at any stage of the development process.
Let’s create a BSP application to show how this can be achieved, this example is based on SAP WAS 6.40.
1. Create a BSP application ZTESTONE.
2. Create a page with flow logic candmain.htm with the following attributes
Now, customize the formlayout controls with desired display attributes by maintaining values in the table VRCFPHTMLB_FLI_C.
First column: Name of the BSP page name along with the application name and name space.
Second column: Meaningful name for the context, which will be used as the value for customization key of the formlayout attribute.
Third column: Id of the formlayout control to be customized on the page.
Fourth column: Display attribute of the control in the formlayout.
When this context name is used in the customization key attribute of the formlayout, the view of the page depends on the display attributes mentioned in the above table.
Other data fields that are to be displayed on the page irrespetive of the role is not maintained here as part of the context(Customization key).
Table : VRCFPHTMLB_FLI_C
5. OnCreate event:
In our scenario when the application is started it is set to administrator role, in which the annual salary and the rate are not displayed, however expense field is shown as display only.
onCreate event is used to set the page attributes to the value mentioned below.
6. On Input processing event(Button clicked):
When button is clicked, the page attributes are changed, so that the page layout will show the fields for the Manager. In this case, all the fields are displayed in the layout.
The results for this example are shown below.
This example can also be tried in WAS 6.20, which has PHTMLB BSP extensions. However, the field customization table PHTMLB_FLI_CUST is to be maintained programmatically with the required values for customization as there is no table maintenance transaction available.