Web UI Code Bundle


Sl No
1
Topic
F4 value help for attribute
Using
Search help (SE11)
where
GET_V method of the attribute
Code
METHOD get_v_country.   " V Method of the attribute
  
DATA: ls_map TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping,
        lt_inmap 
TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping_tab,
        lt_outmap 
TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping_tab.

  ls_map
-context_attr = 'struct.country'.   " Attribute Name
  ls_map
-f4_attr = 'LAND1'.                 " Search Help (SE11) field name
  
APPEND ls_map TO: lt_inmap, lt_outmap.

  
CREATE OBJECT rv_valuehelp_descriptor TYPE cl_bsp_wd_valuehelp_f4descr
    
EXPORTING
      iv_help_id        
= 'CRM_COUNTRY'      " Search Help (SE11) name
      iv_help_id_kind   
= if_bsp_wd_valuehelp_f4descr=>help_id_kind_name
      iv_input_mapping  
= lt_inmap
      iv_output_mapping 
= lt_outmap.
ENDMETHOD.

 

Sl No
2
Topic
BACK button on the overview page
Using
NA
Where
‘WD_DESTROY’ method inside ‘Controller Initialization and Destruction’
Code
RAISE EVENT history_trigger.
CALL METHOD SUPER->WD_DESTROY.

 

Sl No
3
Topic
Make an Attribute Hyperlink
Using
NA
Where
GET_P method of the attribute
Code
METHOD get_p_bp_number.
  
CASE iv_property.
    
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value 
= cl_bsp_dlc_view_descriptor=>field_type_event_link.
    
WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
      rv_value 
= 'bpnumber'." Name of the event which will trigger.
  
ENDCASE.
ENDMETHOD.

 

Sl No
4
Topic
Get the Row Number clicked by user 
Using
NA
Where
Event handler method
Code
lv_index TYPE i,
cl_thtmlb_util=>get_event_info( EXPORTING iv_event = htmlb_event_ex
                                  
IMPORTING ev_index = lv_index ).

 

Sl No
5
Topic
Code for method SET_VIEW_GROUP_CONTEXT redefinition
Using
NA
Where
Method ‘SET_VIEW_GROUP_CONTEXT’
Code
IF iv_first_time = abap_true AND
    me
->view_group_context IS NOT BOUND.
    
IF iv_parent_context IS INITIAL.
      
CREATE OBJECT me->view_group_context TYPE cl_bsp_wd_view_group_context.
    
ELSE.
      me
->view_group_context = iv_parent_context.
    
ENDIF.
  
ENDIF.

 

Sl No
6
Topic
Buttons in OverView page: Edit, Save & Cancel
Added Info
To see the buttons in the toolbar also redefine method IF_BSP_WD_TOOLBAR_CALLBACK~GET_NUMBER_OF_VISIBLE_BUTTONS and fill value for rv_result
Where
Method IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS
Code
METHOD if_bsp_wd_toolbar_callback~get_buttons.
*  Calling Super is important for buttons
  
CALL METHOD super->if_bsp_wd_toolbar_callback~get_buttons
    RECEIVING
      rt_buttons 
= rt_buttons.

  
DATA: ls_button TYPE crmt_thtmlb_button_ext,
        lr_header 
TYPE REF TO cl_crm_bol_entity. " To hold the header entity
* Get header data to chech whether its bound
  lr_header ?= me
->typed_context-><context_node>->collection_wrapper->get_current( ).

  
CLEAR ls_button.
  ls_button
-on_click  = 'edit'.
  ls_button
-type      = cl_thtmlb_util=>gc_icon_edit.
  ls_button
-page_id   = me->component_id.

  
IF lr_header IS BOUND AND view_group_context->is_any_view_editable( ) = abap_false
    
AND lr_header->is_change_allowed( ) = abap_true.
    ls_button
-enabled = abap_true.
  
ELSE.
    ls_button
-enabled = abap_false.
  
ENDIF.
  
APPEND ls_button TO rt_buttons.

  
CLEAR ls_button.
  ls_button
-on_click  = 'cancel'.
  ls_button
-type      = cl_thtmlb_util=>gc_icon_cancel.
  ls_button
-page_id   = me->component_id.

  
IF lr_header IS BOUND AND view_group_context->is_any_view_editable( ) = abap_true
    
AND lr_header->is_change_allowed( ) = abap_true.
    ls_button
-enabled = abap_true.
  
ELSE.
    ls_button
-enabled = abap_false.
  
ENDIF.
  
APPEND ls_button TO rt_buttons.

  
CLEAR ls_button.
  ls_button
-on_click  = 'save'.
  ls_button
-type      = cl_thtmlb_util=>gc_icon_save.
  ls_button
-page_id   = me->component_id.

  
IF lr_header IS BOUND AND view_group_context->is_any_view_editable( ) = abap_true
    
AND lr_header->is_change_allowed( ) = abap_true.
    ls_button
-enabled = abap_true.
  
ELSE.
    ls_button
-enabled = abap_false.
  
ENDIF.
  
APPEND ls_button TO rt_buttons.
ENDMETHOD.
Sl No
6.1
Topic
EDIT button coding of OverView page
Where
‘EH_ONEDIT’ method of OverView page
Code
METHOD eh_onedit.

  
DATA: lr_entity TYPE REF TO cl_crm_bol_entity.

  lr_entity ?= me
->typed_context->headerov->collection_wrapper->get_current( ).

  
CHECK lr_entity IS BOUND.
  
CHECK lr_entity->is_change_allowed( ) = abap_true.

  
IF lr_entity->lock( ) = abap_true.
    me
->view_group_context->set_all_editable( ).
  
ELSE.
    me
->view_group_context->reset( ).
  
ENDIF.

ENDMETHOD.
Sl No
6.2
Topic
CANCEL button coding of OverView page
Where
‘EH_ONCANCEL’ method of OverView page
Code
METHOD eh_oncancel.

  
DATA: lr_entity       TYPE REF TO cl_crm_bol_entity,
        lr_transaction  
TYPE REF TO if_bol_transaction_context.

  lr_entity ?= me
->typed_context->headerov->collection_wrapper->get_current( ).

  
CHECK lr_entity IS BOUND.

  lr_transaction 
= lr_entity->get_transaction( ).
  lr_transaction
->revert( iv_suppress_buffer_sync = abap_true ).

  view_group_context
->reset( ).

ENDMETHOD.
Sl No
6.3
Topic
SAVE button coding of OverView page
Where
‘EH_ONSAVE’ method of OverView page
Code
METHOD eh_onsave.

  
DATA: lr_entity       TYPE REF TO cl_crm_bol_entity,
        lr_transaction  
TYPE REF TO if_bol_transaction_context,
        lr_core         
TYPE REF TO cl_crm_bol_core.

  lr_entity ?= me
->typed_context->headerov->collection_wrapper->get_current( ).

  
CHECK lr_entity IS BOUND.

  lr_transaction 
= lr_entity->get_transaction( ).

  
IF lr_transaction IS NOT BOUND.
    lr_core 
= cl_crm_bol_core=>get_instance( ).
    lr_transaction 
= lr_core->begin_transaction( ).
  
ENDIF.

  
IF lr_transaction IS BOUND.
    
IF lr_transaction->check_save_possible( ) = abap_true.
      
CHECK lr_transaction->save( ) = abap_true.
      lr_transaction
->commit( ).
    
ENDIF.
  
ENDIF.

  view_group_context
->reset( ).
ENDMETHOD.

 

Sl No
7
Topic
Coding for One Click Action
Add Info
1st one OCA attribute needs to be added in the context node attributes.
1.       Select Value Attribute
2.       Attr Name: thtmlb_oca
3.       DDICType: crm_thtmlb_one_click_action
Where
Method ‘GET_OCA_T_TABLE’ of the context node class
Code
METHOD get_oca_t_table.

  
DATA: ls_oca TYPE crmt_thtmlb_one_click_action.

  
CLEAR ls_oca.
  ls_oca
-id       = 'EDIT'.
  ls_oca
-icon     = 'edit.gif'.
  ls_oca
-text     = ''.
  ls_oca
-tooltip  = 'Edit Record'.
  ls_oca
-active   = 'X'.
  
APPEND ls_oca TO rt_actions.

  
CLEAR ls_oca.
  ls_oca
-id       = 'DELETE'.
  ls_oca
-icon     = 'delete.gif'.
  ls_oca
-text     = ''.
  ls_oca
-tooltip  = 'Delete Record'.
  ls_oca
-active   = 'X'.
  
APPEND ls_oca TO rt_actions.
ENDMETHOD.
Sl No
7.1
Topic
Coding for GET_P method of OCA attribute
Code
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'." Name of the event which will trigger.
  
ENDCASE.
endmethod.
Sl No
7.2
Topic
Coding for OCA event handler method to identify the Action and Row index
Code
METHOD eh_on_oca.

  
DATA: lv_event TYPE string,
        lv_index 
TYPE c LENGTH 2.

  
SPLIT htmlb_event_ex->event_defined AT '.' INTO lv_event lv_index.

  
CASE lv_event.
    
WHEN 'EDIT'.
    
WHEN 'DELETE'.
    
WHEN OTHERS.
  
ENDCASE.
ENDMETHOD.

 

Sl No
8
Topic
Codes for creating tree view
Using
NA
Where
Method ‘DO_PREPARE_OUTPUT’
Code
IF me->typed_context-><context_node>->node_tab IS INITIAL.
    me
->typed_context-><context_node>->refresh( ).
  
ENDIF.

  
CALL METHOD super->do_prepare_output
    
EXPORTING
      iv_first_time 
= abap_false.
Sl No
8.1
Topic
Codes for refresh  method
Where
Method ‘REFRESH’ of the Context Node
Code
DATA:   lr_entity   TYPE REF TO cl_crm_bol_entity,
        lr_coll_wr  
TYPE REF TO cl_bsp_wd_collection_wrapper,
        lr_iterator 
TYPE REF TO if_bol_bo_col_iterator,
        lr_root     
TYPE REF TO if_bsp_wd_tree_node.

  
CALL METHOD super->refresh.
  
TRY.
      lr_coll_wr  ?= me
->get_collection_wrapper( ).
      lr_iterator ?= lr_coll_wr
->get_iterator( ).
      lr_entity   ?= lr_iterator
->get_first( ).

      
WHILE lr_entity IS BOUND.
        lr_root 
= me->node_factory->get_proxy(
          iv_bo           
= lr_entity
          iv_proxy_type   
= 'ZT14_TREE_VIEW_MAIN'). "Name of the proxy class
                                                    
"for 1st Node
        lr_root
->node_key = add_root_node( lr_root ).
        lr_entity ?= lr_iterator
->get_next( ).
      
ENDWHILE.

    
CATCH cx_sy_move_cast_error cx_sy_ref_is_initial.
  
ENDTRY.
Sl. No.
8.2
Topic
Codes for  method ‘GET_<param_name>’ of Class 'ZT14_TREE_VIEW_MAIN (Class for 1st node)
Where
Method ‘GET_<param_name>’ of Class 'ZT14_TREE_VIEW_MAIN (Class for 1st node)
Add Info
<param_name> is the parameter name used in method ‘GET_TABLE_LINE_SAMPLE’ of the context node
Code
  DATA: lr_entity TYPE REF TO cl_crm_bol_entity.

  
IF me->bo IS BOUND.
    lr_entity ?= me
->bo.
    lr_entity
->get_property_as_string(
      
EXPORTING iv_attr_name = 'CASE_NUMBER' "1st attr name
      RECEIVING rv_result 
= value ).
  
ENDIF.
Sl. No.
8.3
Topic
Codes for  method ‘IF_BSP_WD_TREE_NODE~GET_CHILDREN’ of Class 'ZT14_TREE_VIEW_MAIN (Class for 1st node)
Where
Method ‘IF_BSP_WD_TREE_NODE~GET_CHILDREN’
Code
  DATA: lr_coll   TYPE REF TO if_bol_bo_col,
        lr_entity 
TYPE REF TO cl_crm_bol_entity,
        lr_child  
TYPE REF TO if_bsp_wd_tree_node.

  lr_entity ?= me
->bo.

  
TRY.
      
CALL METHOD lr_entity->get_related_entities
        
EXPORTING
          iv_relation_name 
= 'BuilCleansingCaseTargetRel' 
        RECEIVING
          rv_result        
= lr_coll. "Get the child data for 2nd Node

      
IF lr_coll IS BOUND.
        lr_entity ?= lr_coll
->get_first( ).
        
WHILE lr_entity IS BOUND.
          lr_child 
= me->node_factory->get_proxy( 
            iv_bo           
= lr_entity
            iv_proxy_type   
= 'ZT14_TREE_PROXY_CUSTOMER' "Class for 2nd Node
            iv_parent_proxy 
= me ).

          lr_child
->is_leaf = abap_true. "This means this is the last node of tree
          
APPEND lr_child to rt_children.

          lr_entity ?= lr_coll
->get_next( ).
        
ENDWHILE.
      
ENDIF.
    
CATCH cx_crm_genil_model_error.

  
ENDTRY.
Sl. No.
8.4
Topic
Replace code in <view>.htm file of the tree view
Where
<view>.htm file of the tree view
Code
<chtmlb:configTree       downloadToExcel       = "FALSE"
                         
id                    = "ProductTree" 
                         nodeTable             = 
"<%= <context_node>->node_tab %>"
                         nodeTextColumn        = 
"CASE_NUMBER" <%--Attribute name of the 1st row--%>
                         onCollapseNode        = 
"collapse" <%--EventHandler method name--%>
                         onExpandNode          = 
"expand"   <%--EventHandler method name--%>
                         onRowSelection        = 
"select"
                         personalizable        = 
"TRUE"
                         selectedRowIndex      = 
"<%= <context_node>->SELECTED_INDEX %>"
                         selectedRowIndexTable = 
"<%= <context_node>->SELECTION_TAB %>"
                         selectionMode         = 
"NONE"
                        
type                  = "<%= CL_THTMLB_TREE=>
GC_TYPE_COLUMN %>"
                         
table                 = "//<context_node>/Table"
                         usage                 = 
"ASSIGNMENTBLOCK"
                         noFrame               = 
"TRUE"
                         visibleRowCount       = 
"10" 
                        
xml                   = "<%= controller->configuration_descr->get_config_data( ) %>" />
Sl. No.
8.5
Topic
Codes for event handler method of COLLAPSE
Where
Method ‘EH_ONCOLLAPSE’
Code
DATA: lr_event_ic TYPE REF TO cl_crm_ic_tree,
      lr_event_thtmlb 
TYPE REF TO cl_thtmlb_tree.

  
FIELD-SYMBOLS: <fs_line> TYPE crmt_bsp_treetable_node.
  
TRY .
      lr_event_ic ?= htmlb_event_ex
.
      typed_context
-><context_node>->collapse_node( lr_event_ic->row_key ).
    
CATCH cx_sy_move_cast_error.
      
TRY .
          lr_event_thtmlb ?= htmlb_event_ex
.
          typed_context
-><context_node>->collapse_node( lr_event_thtmlb->row_key ).
        
CATCH cx_sy_move_cast_error.
      
ENDTRY.
  
ENDTRY.
Sl. No.
8.6
Topic
Codes for  event handler method of EXPAND
Where
Method ‘EH_ONEXPAND’
Code
DATA: lr_event_ic TYPE REF TO cl_crm_ic_tree,
      lr_event_thtmlb 
TYPE REF TO cl_thtmlb_tree.

  
FIELD-SYMBOLS: <fs_line> TYPE crmt_bsp_treetable_node.
  
TRY .
      lr_event_ic ?= htmlb_event_ex
.
      typed_context
-><context_node>->collapse_node( lr_event_ic->row_key ).
    
CATCH cx_root.
      
TRY .
          lr_event_thtmlb ?= htmlb_event_ex
.
          typed_context
-><context_node>->expand_node( lr_event_thtmlb->row_key ).
        
CATCH cx_root.
      
ENDTRY.
  
ENDTRY.

 

Sl No
9
Topic
Code for setting view configuration 
Using
NA
Where
Method DO_CONFIG_DETERMINATION
Code
me->set_config_keys(  iv_object_type          = 'ZT14_UI_OBJ1'
                      iv_object_sub_type      
= 'SUBOBJ1'
                      iv_propagate_2_children 
= abap_true ).



Sl No
10
Topic
Call pop up from same component 
Info
You need to create Component Interface of the view of pop up.
Where
Outbound Plug Method of the caller view
Code
lr_popup ?= me->comp_controller->window_manager->create_popup(
       iv_interface_view_name
 = <Your interface window>
       iv_usage_name
 = if_bsp_wd_window_manager=>co_own_window
       iv_title
 = lv_title ).


Sl No
11
Topic
Dropdown for attribute
Info
Define the dropdown
where
GET_P method of the attribute
Code
CASE iv_property.
    
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value 
= cl_bsp_dlc_view_descriptor=>field_type_picklist.
    
WHEN if_bsp_wd_model_setter_getter=>fp_server_event.
      rv_value 
= '<event_name>'.
  
ENDCASE.
Sl No
11.1
Topic
Dropdown for attribute
Info
Populate dropdown value.
Declare gr_ddlb_<attribute> in the _CN class as follows
gr_ddlb_<attribute> Instance Attribute Private Type Ref To CL_CRM_UIU_DDLB
Populate your dropdown table
Where
V method of the attribute
Code
  DATA: lt_ddlb       TYPE bsp_wd_dropdown_table,
        ls_ddlb       
TYPE bsp_wd_dropdown_line,

  
IF gr_ddlb_<attribute> IS NOT BOUND.
    
CREATE OBJECT gr_ddlb_<attribute>
      
EXPORTING
        iv_source_type 
= 'T'.

      ls_ddlb-key
   = <key>.
      ls_ddlb-value
 = <value>.
      
APPEND ls_ddlb TO lt_ddlb.

    
INSERT INITIAL LINE INTO lt_ddlb INDEX 1.
    gr_ddlb_<attribute>
->set_selection_table( lt_ddlb ).
  
ENDIF.

  rv_valuehelp_descriptor 
= gr_ddlb_zzfld00000h.







Sl No
12
Topic
Add Button in HTML with Authority check 
Info
NA
Where
HTML Page
Code
<thtmlb:searchButtonsArea>
 <%  AUTHORITY-CHECK OBJECT '<auth_obj_name>'
                          
ID 'ACTVT' FIELD '<num>'.
     
IF sy-subrc = 0 .%>

      <thtmlb:button design  = 
"EMPHASIZED"
                     id
      = "<id>"
                     onClick
 = "<event>"
                     text
    = "<%= page-                              >otr_trim( '<OTR_name>' ) %>" />
    
<%  ENDIF. %>
</thtmlb:searchButtonsArea>
 




--------------------------------------------------------------------------------------








No comments:

Post a Comment