0% found this document useful (0 votes)
300 views

Creating A Custom View in A Overview Page

The document describes how to create a custom table view (value node) in an overview page in SAP CRM. It involves creating a DDIC, enhancing a component, creating a view, assigning the view to an overview page in the runtime repository, configuring the view for display in the web UI, and adding toolbar buttons and event handlers to the view to allow inserting, editing, and deleting records.

Uploaded by

Bhanu Chander
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
300 views

Creating A Custom View in A Overview Page

The document describes how to create a custom table view (value node) in an overview page in SAP CRM. It involves creating a DDIC, enhancing a component, creating a view, assigning the view to an overview page in the runtime repository, configuring the view for display in the web UI, and adding toolbar buttons and event handlers to the view to allow inserting, editing, and deleting records.

Uploaded by

Bhanu Chander
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Creating a custom Table view(value node) in a

overview page:

We first created a DDIC in se11 .


i.e.zemp2

Go to component workbench.
T CODE BSP_WD_CMPWB

Enhance the component if it is not enhanced.


create view by right clicking on views in component structure browser.
give view name - zempview (user defined)

skip 'add model node' and enter value node as - zemp1(DDIC )


and select all attibutes.

select 'form view' and check 'configurable ' (Here, Screenshot is different one)

finally our view will b looked like this.

save it.
controller , context and context node classes will be generated.
our view in component structure browser will look like this.

No 'RT
Rep
Details of
View '

The view 'zempview' is not assigned to any view set or overviewpage. So, 'RT Rep
details of view' is not displayed here.
so we should add this view to overview page or viewset in runtime repository. In this
case opportunityOVViewset is the overviewpage name. So adding our view to view
area which is resided in
opportunityOVViewset.

After adding view to overviewpageset in Runtime repository, come out of that


component and reopen.

Then, you are able to see 'RT Rep details of view'.

Adding view in back end is completed. But it is not visible in web ui.
We should save the view. Now, open webUI and click on configure page. A window
will be opened.

Move our 'zempview' from left to right side. i.e Available Assignment blocks to
displayed assignment blocks. By clicking up and down buttons we can manage to
place the view in desired position.
save & close.
Now open component workbench , open our view and click on configuration tab.
Add fields from available to display byclicking '+' button.

save it.

Note: if you dont perform this step, you would get 'NO_CONFIG_FOUND' error in
webUI.
View will be displayed on the webUI.

ADDING TOOLBAR BUTTONS TO THE


TABLE VIEW :
To insert toolbar buttons , we need write code in DO_PREPARE_OUTPUT Method.
Here, the code look like this.
DO_PREPARE_OUTPUT:
*********************************************************************************
****
method DO_PREPARE_OUTPUT.
*CALL METHOD SUPER->DO_PREPARE_OUTPUT
** EXPORTING
**
IV_FIRST_TIME = ABAP_FALSE
*
.

data: ls_button type CRMT_THTMLB_BUTTON.

clear ls_button.
REFRESH gt_toolbar_buttons." gt_toolbar_buttons is an attribute of type CRM
T_THTMLB_BUTTON_T in the _IMPL Class.
ls_button-id = 'Insert'.
ls_button-text = 'Insert'.
ls_button-on_click = 'Insert'.
ls_button-tooltip = 'Insert'.
ls_button-enabled = abap_true.
APPEND ls_button to gt_toolbar_buttons.

clear ls_button.
ls_button-id = 'Delete'.
ls_button-text = 'Delete'.
ls_button-on_click = 'Delete'.
ls_button-type = cl_thtmlb_util=>gc_icon_delete.
ls_button-tooltip = 'Delete'.
ls_button-enabled = abap_true.
APPEND ls_button to gt_toolbar_buttons.
clear ls_button.
ls_button-id = 'Edit'.
ls_button-text = 'Edit'.
ls_button-on_click = 'Edit'.
ls_button-type = cl_thtmlb_util=>gc_icon_edit.
ls_button-tooltip = 'Edit'.
ls_button-enabled = me->view_group_context->is_view_in_display_mode( me ).
APPEND ls_button to gt_toolbar_buttons.

endmethod.

*********************************************************************************
****

Just we have added 'insert','delete' & 'edit' buttons, but they dont perform
any action if you click on them. For that we need to create Event handlers for
buttons to be performed.
Edit Button : (EH_ONEDIT):
**************************************************************************
****
method EH_ONEDIT.
data: lr_entity type ref to cl_crm_bol_entity,
lr_cuco type ref to CL_BT111H_O_OPPTDETAILSCU_IMPL. " BTADMINH (objec

t_id, GUID) is available in 'BT111H_OPPT/OpptDetailsCuCo' custom controller.


So, we r taking dat custom controller implementation class
CL_BT111H_O_OPPTDETAILSCU_IMPL.
lr_cuco ?= me->get_custom_controller( controller_id = 'BT111H_OPPT/OpptDetail
sCuCo' ). " typecasting
lr_entity ?= lr_cuco->typed_context->btadminh->collection_wrapper>get_current( ).
if lr_entity->lock( ) eq abap_true.
me->view_group_context->set_view_editable( me ).
" Accessing set_view_editable( ) which is in the IF_BSP_WD_VIEW_GROUP_CONTEX
T with view_group_context (instance attribute of IF_BSP_WD_VIEW_GROUP_CONTEXT
) & passing 'me' ref to controller class.
endif.
endmethod.

*****************************************************************************
Insert Button: (EH_ONINSERT)
*****************************************************************************
method EH_ONINSERT.
data: lr_value type ref to cl_bsp_wd_value_node,
lr_coll type ref to cl_bsp_wd_collection_wrapper.

" if_bol_bo_col

types: BEGIN OF ty_emp,


empno type zempno,
empname type zempname,
empdes type zempdes,
END OF ty_emp.
data lr_struct type ref to ty_emp.
create data lr_struct.
CREATE OBJECT LR_VALUE
EXPORTING
IV_DATA_REF = lr_struct.
lr_coll ?= me->typed_context->zemptable->get_collection_wrapper( ).
check lr_coll is bound.
lr_coll->add( lr_value ).

endmethod.

**************************************************************************
***
New row will be inserted in the table view zemployeeview.
DELETE BUTTON: (EH_ONDELETE):
*********************************************************************************
****
method EH_ONDELETE.
data: lr_entity type ref to cl_bsp_wd_value_node,"entity
ref from value node
lr_coll type ref to if_bol_bo_col," for the collection of collection
wrapper
lr_marked_coll type ref to if_bol_bo_col.
" for the marked collect
ion of collection wrapper

lr_coll ?= me->typed_context->zemptable->collection_wrapper. " getting colle


ction from wrapper
lr_marked_coll ?= lr_coll->get_marked( ).
lr_entity ?= lr_marked_coll->get_first( ).
while lr_entity is bound.
lr_coll->remove( lr_entity ). " if no of rows r marked to b deleted-while
lr_entity ?= lr_marked_coll->get_next( ).
ENDWHILE.
endmethod.

*************************************************************************************
SAVE METHOD: ( Of Overview page) :
Before proceeding to the coding part, we need to create custom controller 'zcuco'
and do create binding for the 'zemptable'.
By right clicking on custom controllers in component structure browser , we can
create cuco by the help of wizard.
After creating 'zcuco', we should create binding on the context node of zemptable.
After successful binding, the structure look like below.

Code for SAVE method should be written in the SAVE event handler of opportunity
overview page.
create event handler -SAVE and write the below code in that method.

SAVE BUTTON (EH_ONSAVE):


method EH_ONSAVE.
CALL METHOD SUPER->EH_ONSAVE
EXPORTING
HTMLB_EVENT
= HTMLB_EVENT
HTMLB_EVENT_EX = HTMLB_EVENT_EX.
data: lr_value_entity type ref to cl_bsp_wd_value_node, "
lr_modal_entity type ref to cl_crm_bol_entity,
lt_emp type STANDARD TABLE OF zemp,
ls_emp like line of lt_emp,
lr_coll type ref to if_bol_bo_col,
lr_cuco type ref to ZL_ZBT111H_ZCUCO_IMPL,
lv_id type crmt_object_id,
lv_guid type crmt_object_guid,
lr_iterator type ref to if_bol_bo_col_iterator.

lr_modal_entity ?= me->ztyped_context->btadminh->collection_wrapper>get_current( ).
lv_id = lr_modal_entity->get_property_as_string( iv_attr_name = 'OBJECT_ID'
).
lv_guid = lr_modal_entity->get_property_as_string( iv_attr_name = 'GUID' ).
lr_cuco ?= me->get_custom_controller( controller_id = 'ZBT111H/zcuco' ).
lr_coll ?= lr_cuco->typed_context->zemptable->collection_wrapper.
check lr_coll is bound.
lr_iterator ?= lr_coll->get_iterator( ).
lr_value_entity ?= lr_iterator->get_first( ).
while lr_value_entity is bound.
CALL METHOD LR_VALUE_ENTITY->GET_PROPERTIES
IMPORTING
ES_ATTRIBUTES = ls_emp.
ls_emp-z_id = lv_id.
ls_emp-z_guid = lv_guid.
* ls_emp = lr_value_entity->if_bol_bo_property_access~get_properties( ).
append ls_emp to lt_emp.
insert zemp from table lt_emp ACCEPTING DUPLICATE KEYS.
lr_value_entity ?= lr_iterator->get_next( ).
endwhile.
endmethod.

then save & activate.

You might also like