This article will help people trying to understand how to use CRM UI to start coding to handle UI elements. It covers the basics of how you could control the UI element using CRM bol programming
It has been divided into these 5 sections where
- Finding the UI component
- Opening the corresponding UI component from back-end
- Find relevant technical objects to modify
- Code changes to make the field display only or editable
1. Requirement: Disable a UI element
For customer overview screen when user clicks on edit to update the address information
It opens the next screen where based on some business rule edit button for communication address should be enabled or disabled.
2. Find the UI component
Right click on the specific field and press F2 and you would be able to see the technical details
Make a note of the UI component and View as below
UI Component is BP_ADDR and View is BP_ADDR/AccountCommNumbersEL
3. Open the UI component in backend
Use transaction obsp_wd_cmpwb to be able to open the component in backend CRM system
Enter the component found above as BP_ADDR you can use an existing enhancement or create a new one. IN my case I am using an existing enhancement as ZCRM
Find the UI component and View associated with it
It shows the different view components as seen below
In order for us to change the section for communication we need to focus on the controller implementation class Implementation Class ZL_BP_ADDR_ACCOUNTCOMMNUM_IMPL And View layout AccountCommNumbersEL.htm
4. Find relevant technical objects to modify
If you have never used the UI object above, then the methods would need to be redefine in my class I already used the class before so no need to redefine hence using the class ZL_BP_ADDR_ACCOUNTCOMMNUM_IMPL. The below diagram shows how you can redefine a class by right clicking and choosing redefine.
The class ZL_BP_ADDR_ACCOUNTCOMMNUM_IMP is one of the important one which has a method DO_PREPARE_OUTPUT where you can control to make view editable or display only
Class implementation is a bol entity of type CL_BSP_WD_VIEW_CONTROLLER
IN this class you get attributes by default which can be used to control the context behavior
For this case we would be using VIEW_GROUP_CONTEXT
This further reference an associated interface IF_BSP_WD_VIEW_GROUP_CONTEXT
5. Code changes to display /edit the section
Below code was added in method DO_PREPARE_OUTPUT
Breakpoints can be set and after changes you would notice that you are still able to edit the BP header section
Let’s add an additional line of code which says as below. Display value is now X which means the user would not have any rights to edit the Phone, mobile highlighted above.
me->zaddress_display = 'X'.
Now when the program runs it is able to show the field as display only.
The additional setting is to create an attribute in the class
This attribute value is then passed on the BSP page as below
Where the code should say:
displayMode = "<%= controller->zaddress_display %>"
To make all fields editable below code should be used
me->view_group_context->set_all_editable( ). me->zaddress_display = ' '.
And in the HTM page the value of Zddress would now be passed as Blank which would make the field editable.
Thanks for taking time to read please share your comments and views.
Note that the original article was posted on below link