In every SAP SRM developer’s life there comes a day when he/she needs to modify the standard Web UI and this blog is intended for that day. Let’s get into the details now.
The things you need to know/have before reading this blog are
- Work experience in SAP SRM7
- Good knowledge of SAP ABAP Web Dynpro
- Patience :-)
I am going to divide the general requirements into few categories and discuss how we can achieve each of those requirements
- Hide certain field/ tab/container etc.,
- Replace the standard search help with a custom search help
- Make field non-editable/mandatory
- Add new fields/tabs
Category 1
SAP has provided a beautiful BADI WD_BADI_DOMODIFYVIEW for achieving most of the requirements under this category. This is a filter dependent BADI, so you can create multiple implementations based on webdynpro component and the VIEW name. It has an import parameter called VIEW, which gets the reference to the view controller at runtime. So, if you want to hide any of the UI element on a particular view, just proceed as below
- Right click on the field and go to technical help to identify the WD comp and VIEW that field belongs to
- Create an implementation of the BADI using WD component and VIEW as BADI filter
- Inside the implementation, get the reference of the UI element and remove/hide it from the UI
Sounds like a piece of cake. Isn’t it?. Well not always. Let’s look at an example to understand it better. For instance, if you want to hide PO number field on overview tab of the PO screen.
The technical help of PO number field gives us the information about WD component, VIEW name and component configuration
Create an implementation for the badi with the following filter combination
In the implementation of BADI use the following code:
DATA : lo_trans_cont TYPE REF TO cl_wd_transparent_container.
*every UI element in webdynpro has a corresponding class. Find the class for the UI element that you want to hide
CONSTANTS lc_main_cont_id TYPE string VALUE 'MAIN_CONTAINER'.
CONSTANTS lc_left_cont_id TYPE string VALUE 'LEFT_CONTAINER'.
*In this case the field is embedded in a transparentUIcontainer with name 'LEFT_CONTAINER', which in turn embedded
*in another container with name 'MAIN_CONTAINER'
lo_trans_cont ?= view->get_element( lc_main_cont_id ).
lo_trans_cont ?= lo_trans_cont->get_child( id = lc_left_cont_id ).
IF lo_trans_cont IS NOT INITIAL.
*Remove input field
lo_trans_cont->remove_child( id = 'PO_NUMBER').
*Remove label
lo_trans_cont->remove_child( id = 'PO_NUMBER_LABEL' ).
ENDIF.
PO number field is removed from the VIEW now
Same goes for hiding any container present in the view. For hiding subviews, please refer to Floorplan Manager for WebDynpro ABAP: Dynamically Modifying Purchase Order FPM in SRM7 Using Custom AppCC
Other way of doing this is creating a Z component configuration by copying the std one and making the changes to it
/SAPSRM/WDCC_PO_DOFC_OV_HD. click on ‘other functions’ and select ‘Enhance’
you can change the ‘visible’ property of the UI element
This method can be used , if the changes to the web UI applies to all the users.
Category 2
For this case, we will use the same BADI, but now we use the import parameter WD_CONTEXT, which holds the reference to the VIEW context.
Value helps are assigned at context attribute level. Every contest attribute has two properties related to search help
- input help mode
SAP use below code for different types of the search help
Deactivated 101
Automatic 111
DDIC 121
OVS 131
Application defined 141
- input help name – this field holds the actual search help name
Get the name of the view context attribute that holds the search help and use the below sample code to attach/overwrite new/existing search help
Below is the sample code to attach/overwrite search help to a context attribute:
DATA lo_nd_attrib TYPE REF TO if_wd_context_node.
DATA lo_nd_attrib_info TYPE REF TO if_wd_context_node_info.
*get the reference to context node info
lo_nd_attrib_info = lo_nd_attrib->get_node_info( ).
*attach the search help to the relevant attribute
lo_nd_attrib_info->set_attribute_value_help( name = ‘here enter the ID of the context attribute’
value_help_mode = '121' (if it is DDIC shlp)
value_help = ‘here enter the custom search help name that you have created')
Category 3
Use the below SPRO configuration to make the fields non-editable/mandatory
Add the field to the above configuration and select ‘Field enabled’ and ‘Field required’ check boxes as required. Same thing goes for fields at item level. You can define customer class and method to enable/disable fields based on custom logic. For more information on customer class, please refer to the SPRO documentation.
Category 4
There is an excellent blog written by Ricardo Romero on how to add custom fields to SC and POWL. You can find the blog here Add custom field to SC and POWL.
For adding new main views/Tabs, please refer to Floorplan Manager for WebDynpro ABAP: Dynamically Modifying Purchase Order FPM in SRM7 Using Custom AppCC.
If you cannot achieve the requirement by any of the above said methods, the last option would be to enhance the standard webdynpro component/view.
There might be other better ways of doing whatever I said above, so please post your thoughts and comments. I hope you enjoyed reading it as much as I did writing.