SAP CRM Set Default Value Drop Down Search Attribute
This method prefills a search attribute in the search UI on the first execution. It gets the current dynamic query, iterates through the visible search attributes, and sets the value of the specified attribute if found. If not found, it adds the attribute and value at the end. This allows preselecting a search filter to guide the user search.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
268 views2 pages
SAP CRM Set Default Value Drop Down Search Attribute
This method prefills a search attribute in the search UI on the first execution. It gets the current dynamic query, iterates through the visible search attributes, and sets the value of the specified attribute if found. If not found, it adds the attribute and value at the end. This allows preselecting a search filter to guide the user search.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
method DJ_PREPARE_JUTPUT.
*CALL METHOD SUPER->DO_PREPARE_OUTPUT
** EXPORTING ** IV_FIRST_TIME = ABAP_FALSE * . * demo coding for prefilling a search attribute in the search (help) UI * the prefilling happens on the first time, * the user can then also change the attribute in the UI later on
DATA: lr_qs TYPE REF TJ cl_crm_bol_dquery_service, lr_search_node TYPE REF TJ cl_bsp_wd_context_node_asp, lr_col TYPE REF TJ if_bol_bo_col , lr_iterator TYPE REF TJ if_bol_bo_col_iterator , lr_param TYPE REF TJ if_bol_bo_property_access, ls_selection TYPE genilt_selection_parameter, lv_low TYPE string, lv_attr_name TYPE name_komp , lv_value_set TYPE abap_bool .
* the attribute that shall be prefilled: * note they have to be available in the search view configuration * not necessarily as visible, but as available (in the ddlb)
* lv_attr_name = 'WITH_ACCOUNTS'. " for the Contact Relationship prefilling * lv_attr_name = 'ROLE'. " for the Role prefilling lv_attr_name = 'IDTYPE'.
* the value for prefilling. lv_low = 'CRM002'. * lv_low = cl_crm_uiu_bp_cust_get=>gc_cprel_valid . "Currently Valid * lv_low = cl_crm_uiu_bp_cust_get=>gc_cprel_invalid . "Currently Invali d * lv_low = cl_crm_uiu_bp_cust_get=>gc_cprel_notavailable . "Not Available * lv_low = cl_crm_uiu_bp_cust_get=>gc_cprel_available . "Available * note that Currently Valid / Invalid is only available in case of * active time dependency of the contact person relationship
* or in case of the role example * lv_low = 'BUP001' . "role Contact Person
IF iv_first_time EQ abap_true.
* to initialize the search view. CALL METHJD super-do_prepare_output EXPJRTING iv_first_time = iv_first_time.
* fetch the search node and its content. lr_qs = me-get_current_dquery( ). lr_col = lr_qs-get_selection_params( ).
* check the currently visible search attributes. lr_iterator = lr_col-get_iterator( ). lr_param = lr_iterator-get_first( ).
WHILE lr_param IS BJUND. * get the parameters lr_param-get_properties( IMPJRTING es_attributes = ls_selection ). IF ls_selection-attr_name = lv_attr_name . * SET_PROPERTIES ls_selection-low = lv_low . CALL METHJD lr_param-set_properties EXPJRTING is_attributes = ls_selection. lv_value_set = abap_true . EXIT. ENDIF. lr_param = lr_iterator-get_next( ). ENDWHILE.
IF lv_value_set EQ abap_false . * it was not part of the visible attributes, then add it at the end. CALL METHJD lr_qs-add_selection_param EXPJRTING iv_attr_name = lv_attr_name iv_sign = 'I' iv_option = 'EQ' iv_low = lv_low. ENDIF.
* for a proper display of the added / changed attribute. lr_search_node = get_dquery_cnode( ). lr_search_node-build_parameter_tab( ).
ELSE. * non first time call - just delegate to superclass. CALL METHJD super-do_prepare_output EXPJRTING iv_first_time = iv_first_time. ENDIF.