SAP CRM WEB UI - ONE CLICK ACTIONS

This is a simple example for adding one click action events to a table view for bsp applications.

First, add OCA attribute to table view's context node.

Right click Attributes->Create a value attribute with the following DDIC type "CRM_THTMLB_ONE_CLICK_ACTION".

After adding value attribute, go to context node class and redefine method 'GET_OCA_T_TABLE'. 

Define your OCA buttons-> icons & event names in this method.

After that, create GET_P method of OCA attribute with the OCA event to be triggered.

METHOD get_p_thtmlb_oca. 

 CASE iv_property. 
  WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype. 
   rv_value = cl_bsp_dlc_view_descriptor=>field_type_oca. 
  
  WHEN if_bsp_wd_model_setter_getter=>fp_onclick. 
   rv_value = 'OCA_ACTION'. 
 
 ENDCASE. 

ENDMETHOD.

 

Create the OCA event handler, in this example "OCA_ACTION" and define actions to be done inside OCA event.

As we know event handler names are case sensitive, always try to use capitals.

In this example i have written my code to delete the row on cursor's index when clicked.

METHOD eh_onoca_action. 

 DATA: lv_event TYPE string, 
       lv_index_c TYPE c LENGTH 2, 
       lv_index TYPE i. 
 
 DATA: lr_prop_acc TYPE REF TO if_bol_bo_property_access. 

 SPLIT htmlb_event_ex->event_defined AT '.' INTO lv_event lv_index_c. 
 lv_index = lv_index_c. 
 
 CHECK lv_index IS NOT INITIAL. 

 CASE lv_event.
 
  WHEN 'DELETE'. 
   CHECK lv_index IS NOT INITIAL. 
   
   lr_prop_acc ?= typed_context->list->collection_wrapper->find( iv_index = lv_index ).
   CHECK lr_prop_acc IS BOUND. 

   typed_context->list->collection_wrapper->remove( lr_prop_acc ). 

  WHEN OTHERS. 
   EXIT. 

 ENDCASE. 

ENDMETHOD.

 

Reminder: Do not forget to add the attribute to displayed fields on the configuration window.

This is how it looks and delete button removes selected row from the collection as expexted.

ABOUT Uğur Kaya

http://linkedin.com/in/kayau

RELATED POSTS

COMMENTS

comments powered by Disqus