I think most of readers at least once have parametrized their WebUI components, applications or views with some values or parameters depending on some information about user, runtime or whatever. For example, current business role or its configuration key is taken into consideration. Recently I found for myself pretty convenient way to configure (e.g. parametrized) own or enhanced WebUI views with a set of attributes. There is a standard way to assign a set of values to WebUI view configuration, named “General View Settings”. In this way sets of parameters will depend on well-known ones: configuration key, component usage, UI object type, UI object subtype.
Let’s start from the beginning. First of all we need a structure which represents a set of attributes we’d like to have. For example, I’ll take a simple one.
Then we need to enter our component, view and structure in maintenance view BSPC_DL_VIEWS:
After that on Configuration tab of our view in BSP_WD_CMPWB we will have an additional button Attributes.
For configurable view:
For table view:
Going there we’ll see a view to maintain values for attributes from our structure. To maintain a value for an attribute select the row of this attribute.
But we’re not finished yet. Now we need to utilize these maintained parameters. Let’s assume that my view does some search in DO_PREPARE_OUTPUT and then depending on parameters sort the result collection. For example, in view controller in DO_PREPARE_OUTPUT method. So here the code to get current set of parameters:
DATA: lr_config_descr TYPE REF TO if_bsp_dlc_config_attrib, ls_config_attr TYPE zst_example_parameters. lr_config_descr ?= me->configuration_descr. IF lr_config_descr IS BOUND. me->configuration_descr->get_config_data( ). lr_config_descr->get_attributes( CHANGING cs_attributes = ls_config_attr ). ENDIF.
Originally this feature seems to be developed to help in CRM-BI integration. See Using Attributes for Assignment Blocks – Fact Sheet – SAP Library Mainly the system uses such attributes to define BI connection or to store parameters for search/filter use cases. You can explore how these attributes are used in standard components/views referring entries maintained in BSPC_DL_VIEWS.
But who cares? I think we can use it for our own good 🙂
UPD: Cross-reference with SAP Note 2193909 – Setting Default Values in the UI Framework (link to this blog post is in the attachment to the note)