on 09-22-2008 3:17 PM
Hi Experts,
How to add THTMLB_OCA attribute, which is present in
Coponent Name: BT111H_OPPT
View: SalesteamList
Context Node: BTPARTNER
Attribute: THTMLB_OCA
How to add this attibute. Also guide me how to add 'Delete' Button in a Table.
Regards,
Guru
Hi
I am giving you the stepwise solution for adding edit and delete buttons and handling their clicks.
STEP 1 . Write get and Get_P method in the Node Class .
· Go to the context node which is reponsible for handling Result List and double click on its implementation class (having _CN extention ) .
· create GET_P_THTMLB_OCA method as follows. ( follow the same method defination as you find in
Coponent Name: BT111H_OPPT
View: SalesteamList
Context Node: BTPARTNER
Attribute: THTMLB_OCA method get_thtmlb_oca )
method GET_P_THTMLB_OCA.
CASE iv_property.
field type: one click actions
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_oca.
onClick
WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
rv_value = 'one_click_action'.
ENDCASE.
endmethod.
Exit the workbench and open your component again . Now you can see the attribute THTMLB_OCA in the context node attributes .
STEP 2. Make the Configruation to have ACTIONS column .
· Go to the configruation Tab and add a column by pulling attribute THTMLB_OCA onto displayed fields .
· Name the column title as u2018Actionsu2019.
STEP 3. Redefine GET_OCA_T_TABLE .
· Go to the context node implemetation class ( the one with CN extention ) and redefine method GETOCA_T_TABLE as follows.
method GET_OCA_T_TABLE.
· e.g. standard one click action 'Edit' and 'Delete'.
DATA: ls_one_click_action TYPE crmt_thtmlb_one_click_action.
ls_one_click_action-id = 'EDIT'. "#EC NOTEXT
ls_one_click_action-icon = 'edit.gif'.
ls_one_click_action-text = ''.
ls_one_click_action-tooltip = u2018Edit Business Strategyu2019
ls_one_click_action-active = abap_true.
APPEND ls_one_click_action TO rt_actions.
ls_one_click_action-id = 'DELETE'. "#EC NOTEXT
ls_one_click_action-icon = 'delete.gif'.
ls_one_click_action-text = ''.
ls_one_click_action-tooltip = u2018Delete Business Strategyu2019
ls_one_click_action-active = abap_true.
APPEND ls_one_click_action TO rt_actions.
endmethod.
STEP 4. Add Event handler and Out bound Plug to handle click of One Click Action Buttons and navigation .
· Go to the view and create event handler u2018EH_ONONE_CLICK_ACTIONu2019 using the wizard .
· Write following code in the handler .
METHOD eh_onone_click_action.
*CALL METHOD SUPER->EH_ONONE_CLICK_ACTION
.
DATA: lv_index TYPE int4,
lr_current TYPE REF TO if_bol_bo_property_access,
lr_entity TYPE REF TO if_bol_bo_property_access,
lv_event TYPE string,
lv_indx TYPE string, "#EC NEEDED
lr_core TYPE REF TO cl_crm_bol_core,
lr_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
lv_x_save TYPE ad_save VALUE 'X',
lv_text1 TYPE string,
lv_text2 TYPE string.
CALL METHOD cl_thtmlb_util=>get_event_info
EXPORTING
iv_event = htmlb_event_ex
IMPORTING
ev_index = lv_index.
CHECK lv_index IS NOT INITIAL.
set entity as current one
lr_entity ?= me->typed_context->YOURNODE->collection_wrapper->find( iv_index = lv_index ).
CHECK lr_entity IS BOUND.
lr_entity ?= me->typed_context->YOURNODE->collection_wrapper->get_current( ).
Get the action clicked on
SPLIT htmlb_event_ex->event_defined AT '.' INTO lv_event lv_indx.
CASE lv_event.
Edit the current Activity
WHEN 'EDIT'.
Navigate to the edit page (i.e. DetailsEF)
op_one_click_action( ) .
WHEN 'DELETE' .
" copy the code from any available std. for deleting
ENDCASE.
ENDMETHOD.
· Save the method.
· Go to the view and create outbound plug ONE_CLICK_ACTION using wizard.
· Write following code in the outbound plug
METHOD op_one_click_action.
DATA: lr_window TYPE REF TO cl_bsp_wd_window.
lr_window = me->view_manager->get_window_controller( ).
lr_window->call_outbound_plug( 'ONE_CLICK_ACTION' ).
ENDMETHOD.
· Go to the window in which the view having action buttons is attached in component browser and create and out bound plug using wizard. Use following code.
method OP_ONE_CLICK_ACTION.
fire_outbound_plug( iv_outbound_plug = 'ONE_CLICK_ACTION'
iv_data_collection = iv_data_collection ).
endmethod.
STEP 5 . Handle Navigation .
Thansks & Regards,
Suchita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please Review notes 1293317, 1263797.
It could help you with your isse
Best Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guru,
Create both set_ and Get_ method. It Should display you the attribute.
If you are in enhanced component, check if the component controller is enhanced..if not then enhanced it..It seems a bug as it does not display the attributes added after view enhanced until component controller is enhanced.
I am sure, then you can see the attribute.
Thanks & Regards,
Suchita.
P.S. : In SE80 open the context node class that already has THTMLB_OCA. Open methods folder and then Right click on its GET_, SET_, GET_I etc and Copy to your context node class. This is the easy way to copy methods without errors. Later you must activate your class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suchita,
Great!!!, got the attribute, once I logoff from the system and then logged in. But tried again with another node, it works fine when I exit from workbenh and logged in.
Now I am done with Step 1,2 and 3. But in step 4, I pasted the following code and getting error as explained below:
METHOD EH_ON_ONE_CLICK_ACTION.
DATA: LV_INDEX TYPE INT4,
LV_EVENT TYPE STRING,
LV_INDX TYPE STRING,
LR_ENTITY TYPE REF TO CL_CRM_BOL_ENTITY,
LR_CURRENT TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS,
LR_COL TYPE REF TO IF_BOL_BO_COL,
LR_CORE TYPE REF TO CL_CRM_BOL_CORE,
LV_ONE_CLICK_LOCK TYPE SYSUBRC.
CALL METHOD CL_THTMLB_UTIL=>GET_EVENT_INFO
EXPORTING
IV_EVENT = HTMLB_EVENT_EX
IMPORTING
EV_INDEX = LV_INDEX.
CHECK LV_INDEX IS NOT INITIAL.
Get the current entity
ME->TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER->FIND( IV_INDEX = LV_INDEX ).
LR_CURRENT = TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER->GET_CURRENT( ).
LR_ENTITY ?= LR_CURRENT. <Getting Error at this point as shown below in the exception>
Try to lock the current entity
LV_ONE_CLICK_LOCK = CL_CRM_UIU_BT_TOOLS=>SET_ONE_CLICK_LOCK( ME->TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER ).
SPLIT HTMLB_EVENT_EX->EVENT_DEFINED AT '.' INTO LV_EVENT LV_INDX.
CASE LV_EVENT.
Delete the current entity
WHEN 'DELETE'.
IF LV_ONE_CLICK_LOCK = 0.
TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER->REMOVE( LR_CURRENT ).
LR_ENTITY->DELETE( ).
LR_CORE = CL_CRM_BOL_CORE=>GET_INSTANCE( ).
LR_CORE->MODIFY( ).
VIEW_GROUP_CONTEXT->SET_VIEW_EDITABLE( ME ).
ENDIF.
ENDCASE.
ENDMETHOD.
Exception thrown is as follows:
An error occurred during event processing in view BusCont.htm
An exception has occurred Exception Class CX_SY_MOVE_CAST_ERROR - Source type \CLASS=CL_BSP_WD_VALUE_NODE is not compatible, for the purposes of assignment, with target type \CLASS=CL_CRM_BOL_ENTITY
Method: ZL_ICCMP_BT_BUSCONT_IMPL=>EH_ON_ONE_CLICK_ACTION
Source Text Row: 21
Regards,
Guru
Hi Xavier,
Once I change the reference type from CL_CRM_BOL_ENTITY to CL_BSP_WD_VALUE_NODE,
It throws the following dump:
Exception Class CX_SY_MOVE_CAST_ERROR - Source type \CLASS=CL_BSP_WD_VALUE_NODE is not compatible, for the purposes of assignment, with target type \CLASS=CL_CRM_BOL_ENTITY
Method: ZL_ICCMP_BT_BUSCONT_IMPL=>EH_ON_ONE_CLICK_ACTION
Source Text Row: 21
Regards,
Guru
Hi Xavier,
As per your suggestions I have done the required modification in code as follows:
METHOD EH_ON_ONE_CLICK_ACTION.
DATA: LV_INDEX TYPE INT4,
LV_EVENT TYPE STRING,
LV_INDX TYPE STRING,
LR_ENTITY TYPE REF TO CL_BSP_WD_VALUE_NODE,
LR_CURRENT TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS,
LR_COL TYPE REF TO IF_BOL_BO_COL,
LR_CORE TYPE REF TO CL_CRM_BOL_CORE,
LV_ONE_CLICK_LOCK TYPE SYSUBRC.
CALL METHOD CL_THTMLB_UTIL=>GET_EVENT_INFO
EXPORTING
IV_EVENT = HTMLB_EVENT_EX
IMPORTING
EV_INDEX = LV_INDEX.
CHECK LV_INDEX IS NOT INITIAL.
Get the current entity
ME->TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER->FIND( IV_INDEX = LV_INDEX ).
LR_CURRENT = TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER->GET_CURRENT( ).
LR_ENTITY ?= LR_CURRENT.
Try to lock the current entity
LV_ONE_CLICK_LOCK = CL_CRM_UIU_BT_TOOLS=>SET_ONE_CLICK_LOCK( ME->TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER ).
SPLIT HTMLB_EVENT_EX->EVENT_DEFINED AT '.' INTO LV_EVENT LV_INDX.
CASE LV_EVENT.
Delete the current entity
WHEN 'DELETE'.
IF LV_ONE_CLICK_LOCK = 0.
TYPED_CONTEXT->BUSCONTEXT->COLLECTION_WRAPPER->REMOVE( LR_CURRENT ).
LR_ENTITY->DELETE( ).
LR_CORE = CL_CRM_BOL_CORE=>GET_INSTANCE( ).
LR_CORE->MODIFY( ).
VIEW_GROUP_CONTEXT->SET_VIEW_EDITABLE( ME ).
ENDIF.
ENDCASE.
ENDMETHOD.
But, when I check the code, it throws the following error:
METHOD "DELETE" is unknown or Protected or Private.
When I navigate to that method (thru class CL_BSP_WD_VALUE_NODE), I don't find 'Delete' method.
Regards,
Guru
Hi Guru,
Is your table view is based on a VALUE NODE ? if yes, then thats rare...how are you adding entity to the core in that case ? If you are able to handle the value node to add entities and handle saving to them till the document creation then it should be ok to delete them from collection.
Just try usinfg PUBLISH_CURRENT for the context node after you delete. This refreshes the context node and wrapper.
If Publish current does not work then just for my understanding of the behaviour, just add following after your deletion code :
lr_coco ?= comp_controller.
CHECK lr_coco IS BOUND.
cl_crm_uiu_bt_tools=>save( lr_coco->typed_context->YOURCONTEXTNODE ).
define lr_coco as TYPE REF TO CL_ ( write IMPL class of component controller here )
and see if your entry is getting deleted and let me know.
Regards,
Suchita
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.