Dynamic Title descriptions in Assignment Blocks
The requirement is to adopt the Title text with the number of entries in the table as shown above
Techincal Developments:
In the Overview page add the below code:
Method “Update Title” has no parameters
Method “Update_View” :
Code :
Method : “UPDATE_TITLE”
DATA:
lr_view_area TYPE REF TO bsp_dlc_ovw_assgnm,
lv_text_element_id TYPE char70,
lv_title TYPE string,
lv_hit_count TYPE string,
lv_ui_object_type TYPE string,
ui_object_type TYPE bsp_dlc_object_type,
lv_tmp TYPE string,
ls_view_area_orig TYPE ls_view_area_orig.
DATA: lv_viewarea TYPE string.
DATA: lv_binding_error TYPE abap_bool.
DATA: lr_view TYPE REF TO cl_bsp_wd_view_controller.
DATA: lr_sub_view TYPE REF TO cl_bsp_wd_view_controller.
* Get component controller
* DATA: component_controller TYPE REF TO cl_crm_es_u_bspwdcomponen_impl.
* component_controller ?= me->comp_controller.
FIELD-SYMBOLS: <gv_hit_count> TYPE string.
DATA: lv_string TYPE string.
LOOP AT me->view_area REFERENCE INTO lr_view_area.
* IF lr_view_area->traymode = space.
TRY.
lr_view ?= me->get_subcontroller_by_viewname( iv_viewname = lr_view_area->appl_viewname ).
CATCH cx_root.
ENDTRY.
IF lr_view IS NOT BOUND.
lv_viewarea = lr_view_area->sequence.
lv_binding_error = me->update_view( iv_viewid = lr_view_area->appl_viewname
iv_viewarea = lv_viewarea
iv_viewname = lr_view_area->viewname ).
IF lv_binding_error IS INITIAL.
TRY.
lr_view ?= me->get_subcontroller_by_viewname( iv_viewname = lr_view_area->appl_viewname ).
CATCH cx_root.
ENDTRY.
ENDIF.
ENDIF.
IF lr_view IS BOUND.
lv_string = ‘lr_sub_view->GV_HITCOUNT’.
FIELD-SYMBOLS: <current_viewarea> TYPE ltype_va_content.
LOOP AT lr_view->viewarea_cont ASSIGNING <current_viewarea>.
lr_sub_view ?= <current_viewarea>–current–controller.
IF lr_sub_view IS BOUND.
ASSIGN (lv_string) TO <gv_hit_count>.
IF <gv_hit_count> IS ASSIGNED.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
IF <gv_hit_count> IS ASSIGNED.
lv_text_element_id = lr_view_area->title_ref.
lv_title = configuration_descr->get_custom_text( lv_text_element_id ).
IF lv_title IS INITIAL.
lv_title = lr_view_area->title_ref.
ENDIF.
IF lv_title CA ‘()’.
SPLIT lv_title AT ‘ (‘ INTO lv_title lr_view_area->title_ref .
ENDIF.
CONCATENATE lv_title ‘ ( ‘ <gv_hit_count> text–003 ‘)’ INTO lr_view_area->title_ref.
UNASSIGN <gv_hit_count>.
ENDIF.
* ELSEIF lr_view_area->traymode = abap_true.
*
* IF lr_view_area->title_ref CA ‘()’.
*
*
* lv_text_element_id = lr_view_area->title_ref.
*
* lv_title = configuration_descr->get_custom_text( lv_text_element_id ).
* IF lv_title IS INITIAL.
* lv_title = lr_view_area->title_ref .
* ENDIF.
* SPLIT lv_title AT ‘(‘ INTO lr_view_area->title_ref lv_title.
* ENDIF.
* ENDIF.
CLEAR lv_title.
ENDLOOP.
Method UPDATE_VIEW:
DATA lr_rep_view TYPE REF TO cl_bsp_wd_rep_view_ovw.
DATA lr_rep TYPE REF TO cl_bsp_wd_repository.
DATA lr_addview_rep_view TYPE REF TO cl_bsp_wd_rep_view.
DATA lv_viewarea TYPE string.
DATA lv_usg_descr TYPE bsp_wd_cmp_usage_descr.
DATA lr_exception TYPE REF TO cx_bsp_wd_incorrect_implement.
DATA lv_usage TYPE string.
DATA lv_dummy TYPE string.
DATA lv_error TYPE string.
DATA lr_exc TYPE REF TO cx_bsp_wd_incorrect_implement.
DATA lv_viewname TYPE string.
lr_rep_view ?= me->get_repository_view( ).
lr_rep = lr_rep_view->get_repository( ).
lv_viewname = iv_viewname.
* check for component usage and view: If switched off, ignore this assignment block.
* Improve this: Don’t even return switched off assignment blocks from configuration
TRY.
IF iv_viewid CS ‘.’.
SPLIT iv_viewid AT ‘.’ INTO lv_usage lv_dummy.
TRY.
lv_usg_descr = lr_rep->get_cmp_usage_def( lv_usage ).
CATCH cx_bsp_wd_incorrect_implement INTO lr_exc.
IF lr_exc->textid <> cx_bsp_wd_incorrect_implement=>access_2_inactive_element.
RAISE EXCEPTION lr_exc.
ELSE.
rv_error = abap_true.
RETURN.
ENDIF.
ENDTRY.
ELSE.
CASE lr_rep->check_va_assignment_defined(
iv_rep_view = rep_view
iv_viewarea = cl_bsp_dlc_config_list_based=>c_overviewarea_id
iv_assigned_view = iv_viewid ).
WHEN abap_false.
RAISE EXCEPTION TYPE cx_bsp_wd_incorrect_implement
EXPORTING
textid = cx_bsp_wd_incorrect_implement=>undefined_controller
controller = lv_viewname
name = me->view_id.
WHEN cl_webcuif_switch=>co_reaction_hide.
rv_error = abap_true.
RETURN.
ENDCASE.
ENDIF.
CATCH cx_bsp_wd_incorrect_implement INTO lr_exception.
rv_error = abap_true.
RETURN.
ENDTRY.
TRY.
lr_addview_rep_view = lr_rep->get_view( iv_viewid ).
IF lr_addview_rep_view IS INITIAL.
lr_addview_rep_view = lr_rep->create_by_name( iv_viewid ).
ENDIF.
bind_view( rep_view = lr_addview_rep_view
viewarea = iv_viewarea ).
rv_error = abap_false.
CATCH cx_bsp_wd_incorrect_implement INTO lr_exception.
rv_error = abap_true.
RETURN.
ENDTRY.
Call update_title method in Do_prepare_output Method of overview page.
Create a instance attribute “GV_HITCOUNT” and fill in the on_new_focus of the resulting context node in the which Title has to be updated with the Counts.
Very useful
Hi Vignesh ,
Firstly thanks for sharing such type of document which is very useful to us.
I am facing a issue when we are assinging lv_string to gv_hit_count.It is giving error field symbol not yet asigned.
ASSIGN lv_string TO <gv_hit_count>
Can you please help me for this issue.
Again , i am appreciating you to sharing such kind of document.
Regards,
Puneet Mittal
Hi ,
I unable to understand this line:
Create a instance attribute "GV_HITCOUNT" and fill in the on_new_focus of the resulting context node in the which Title has to be updated with the Counts.
What is the type gv_hitcount attribute ?
Can you explain in detail it would be helpful,
Regards,
Puneet Mittal
Hi Vignesh,
Thank you for sharing the document.
I'm trying to accomplish a similar requirement for the assignment blocks on the homepage WCC_SRV_HOME and even though I'm able to set the values in view_area table, the new assignment block title is not displayed, instead the default title is fetched and displayed.
Also, since lr_view is always bound, the update_view method is never triggered ( is it the correct behaviour? )
Thanks!
Viksit