Wednesday, June 1, 2011

Usage of custom businessrole parameters

In the customizing of the UI Framework, there is an option to ‘Define Parameters’.
SAP Customizing Implementation Guide - Customer Relationship Management - UI Framework - Technical Role Definition - Define Parameters.

Here, in the top node, you can maintain custom parameters. As an example, I will show you how this can be used to default a value in the IC webclient search screen.
Let’s say you want to default the country in the search screen to help users find the correct businesspartner more quickly.
Create a new parameter, in our case ZCOUNTRY.

Add the newly created parameter to the profile definition that has been applied to the business role. If needed, create a new profile definition.
Assign the parameter to the definition and add the correct value.
Now in the coding where you want to read the parameter, add the following ABAP lines:
DATA: parameters TYPE REF TO cl_crm_ui_parameter_util,
parameter_value TYPE string.
parameters = cl_crm_ui_parameter_util=>get_instance( ).
parameter_value = parameters->get_parameter( 'ZCOUNTRY' ).

Where of course ‘ZCOUNTRY’ can also be some other parameter.
Parameter_value will get the value from the maintained assignment.

Now add this to the search screen…

IF parameter_value is not initial.
  DATA: lv_qs TYPE REF TO cl_crm_bol_query_service.
  lv_qs ?= me->typed_context->searchcustomer->collection_wrapper->get_current( ).
  lv_qs->if_bol_bo_property_access~set_property_as_string( iv_attr_name = 'COUNTRY' iv_value = parameter_value ).
As the parameters can be retrieved at any time in the coding, you can use this to further differentiate between business roles. Adding a default value of course is just an example. You can also use the parameters to for instance disable a button, determine a categorization schema or determine possible values in a dropdown listbox...