Component BT116IT SRVO

Component BT116IT SRVO

Customizing

UI

Component BT116IT_SRVO

View BT116IT_SRVO/GenericItem

Context node BTADMINI new model attribute ZEXEC_SERV_EMP_NAME

Relation BTPartner_00000052_MAIN (Executing Service Employee)

Component usage for Employee Search

CUBPSearchEmployee

Define attribute in View Controller ZL_BT116IT__GENERICITEM_IMPL

GV_LINENUMBERInstance AttributeProtectedTypeI

Getter

METHOD get_zexec_serv_emp_name.
DATA: current TYPE REF TO if_bol_bo_property_access.
DATA: dref TYPE REF TO data.
value = ''. "#EC NOTEXT
IF iterator IS BOUND.
current = iterator->get_current( ).
ELSE.
current = collection_wrapper->get_current( ).
ENDIF.
TRY.
DATA: coll TYPE REF TO if_bol_entity_col.
DATA: entity TYPE REF TO cl_crm_bol_entity.
entity ?= current.
coll= entity->get_related_entities(
iv_relation_name= 'BTItemPartnerSet' ). "#EC NOTEXT
current = coll->get_current( ).

"Create new Entity if not exists
IF current IS NOT BOUND AND entity->is_changeable( ) = abap_true.
current = entity->create_related_entity( iv_relation_name= 'BTItemPartnerSet' ).
ENDIF.
entity ?= current.
DATA(lr_set) = entity.
coll= entity->get_related_entities(
iv_relation_name= 'BTPartner_00000052_MAIN' ). "#EC NOTEXT
entity = coll->get_current( ).
IF entity IS NOT BOUND AND lr_set->is_changeable( ) = abap_true.
entity = lr_set->create_related_entity( iv_relation_name= 'BTPartner_00000052_MAIN' ).
ENDIF.
"Standard class for Partner
value = cl_crm_uiu_bt_partner=>get_partner2( entity ).
CATCH cx_sy_ref_is_initialcx_sy_move_cast_error
cx_crm_genil_model_error.
RETURN.
ENDTRY.
ENDMETHOD.

Setter

METHOD set_zexec_serv_emp_name.
DATA:
current TYPE REF TO if_bol_bo_property_access,
dref TYPE REF TO data,
copy TYPE REF TO data.
FIELD-SYMBOLS:
<nvalTYPE any,
<oval> TYPE any.
* get current entity
IF iterator IS BOUND.
current = iterator->get_current( ).
ELSE.
current = collection_wrapper->get_current( ).
ENDIF.
* get old value and dataref to appropriate type
TRY.
DATA: coll TYPE REF TO if_bol_entity_col.
DATA: entity TYPE REF TO cl_crm_bol_entity.
entity ?= current.
coll= entity->get_related_entities(
iv_relation_name= 'BTItemPartnerSet' ). "#EC NOTEXT
current = coll->get_current( ).
IF current IS NOT BOUND.

"Create new Entity if not exists
IF current IS NOT BOUND AND entity->is_changeable( ) = abap_true..
current = entity->create_related_entity( iv_relation_name= 'BTItemPartnerSet' ).
ENDIF.
ENDIF.
entity ?= current.
coll= entity->get_related_entities(
iv_relation_name= 'BTPartner_00000052_MAIN' ). "#EC NOTEXT
current = coll->get_current( ).
cl_crm_uiu_bt_partner=>set_partner2( ir_current = current
iv_new_value = value ).
IF current IS NOT BOUND AND entity->is_changeable( ) = abap_true.
current = entity->create_related_entity( iv_relation_name= 'BTPartner_00000052_MAIN' ).
ENDIF.
CATCH cx_sy_ref_is_initialcx_sy_move_cast_error
cx_crm_genil_model_error.
RETURN.
ENDTRY.
ENDMETHOD.

I-Method

METHOD get_i_zexec_serv_emp_name.
DATA: current TYPE REF TO if_bol_bo_property_access.
DATA: lv_no_manual_entryTYPE comt_partner_no_manual_entry.
rv_disabled= 'TRUE'.
IF iterator IS BOUND.
current = iterator->get_current( ).
ELSE.
current = collection_wrapper->get_current( ).
ENDIF.
TRY.
DATA: coll TYPE REF TO if_bol_entity_col.
DATA: entity TYPE REF TO cl_crm_bol_entity.
entity ?= current.

Only for items with parent item
DATA lv_num_parentTYPE crmt_item_no_parent.
entity->get_property_as_value( EXPORTING iv_attr_name= 'NUMBER_PARENT'
IMPORTING ev_result= lv_num_parent).
IF lv_num_parentIS INITIAL.
RETURN.
ENDIF.
coll= entity->get_related_entities(
iv_relation_name= 'BTItemPartnerSet' ). "#EC NOTEXT
current = coll->get_current( ).
IF current IS NOT BOUND.
RETURN.
ENDIF.
entity ?= current.
coll= entity->get_related_entities(
iv_relation_name= 'BTPartner_00000052_MAIN' ). "#EC NOTEXT
entity = coll->get_current( ).
IF entity IS NOT BOUND.
RETURN.
ENDIF.
* check if manual entry is blocked on interface
cl_crm_uiu_bt_partner=>is_partner_no_manual_entry(
EXPORTING ir_partner_entity = entity
iv_partner_fct = '00000052'
IMPORTING ev_no_manual_entry= lv_no_manual_entry).
IF lv_no_manual_entryEQ abap_false.
rv_disabled= 'FALSE'.
ENDIF.
CATCH cx_sy_ref_is_initialcx_sy_move_cast_error
cx_crm_genil_model_error.
RETURN.
ENDTRY.
ENDMETHOD.

V-method

METHOD get_v_zexec_serv_emp_name.
CREATE OBJECT rv_valuehelp_descriptorTYPE cl_bsp_wd_valuehelp_navdescr
EXPORTING
iv_outbound_plug= 'OP_SEARCHEMPLOYEE'. Outbound plug
ENDMETHOD.

P-method

METHOD get_p_zexec_serv_emp_name.
DATA: current TYPE REF TO if_bol_bo_property_access.
DATA: lv_descTYPE string.
current = collection_wrapper->get_current( ).

"Standard class for Partner
lv_desc = cl_crm_uiu_bt_partner=>get_partner2( current ).
"Standard class for Partner
CHECK cl_crm_uiu_bt_partner=>check_link( ir_collection_wrapper= collection_wrapper
iv_index = iv_index) = abap_true.
CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
IF iv_display_mode= abap_false.
rv_value= cl_bsp_dlc_view_descriptor=>field_type_input.
ELSE.
rv_value= cl_bsp_dlc_view_descriptor=>field_type_event_link.
ENDIF.
WHEN if_bsp_wd_model_setter_getter=>fp_onclick.

"Event handler
rv_value= 'TOEMPLOYEE'. "#EC NOTEXT
WHEN if_bsp_wd_model_setter_getter=>fp_tooltip.
rv_value= lv_desc. "#EC NOTEXT
ENDCASE.
ENDMETHOD.

Event handler

Selected employefrompopup

METHOD eh_onselexec_srv_emp.
* Added by wizard: Handler for event 'SELEXEC_SRV_EMP'
DATA:
lr_context_node TYPE REF TO cl_bsp_wd_context_node,
lr_current TYPE REF TO if_bol_bo_property_access,
lr_ent TYPE REF TO cl_crm_bol_entity,
lr_partner TYPE REF TO cl_crm_bol_entity,
lv_outbound_plugTYPE seocmpname,
lv_partner_no TYPE string.
lv_outbound_plug= bpsearch_employee_popup->get_fired_outbound_plug( ).
CHECK lv_outbound_plug= 'TOOVERVIEW'.
lr_context_node= bpsearch_employee_popup->get_context_node( iv_cnode_name= 'EMPLOYEE' ).
lr_current= lr_context_node->collection_wrapper->get_current( ).
CHECK lr_currentIS BOUND.
lv_partner_no= lr_current->get_property_as_string( iv_attr_name= 'BP_NUMBER' ).
DATA:
lr_cnTYPE REF TO cl_bsp_wd_context_node.
FIELD-SYMBOLS:
<lr_cnTYPE any.
ASSIGN me->context->('BTItems') TO lr_cn.
IF lr_cnIS ASSIGNED.
lr_cn ?= <lr_cn.
lr_ent ?= lr_cn->collection_wrapper->get_current( ).
ENDIF.
DATA(lr_coll) = lr_ent->get_related_entities_by_bpath( |BTOrderItemAll[{ gv_linenumber }]/BTItemPartnerSet/BTPartner_00000052_MAIN| ).
lr_partner ?= lr_coll->get_current( ).
IF lr_partnerIS NOT BOUND.
lr_partner ?= lr_ent->create_related_entity( iv_relation_name= 'BTPartner_0000052_MAIN' ).
ENDIF.
cl_crm_uiu_bt_partner=>set_partner2( ir_current = lr_partner
iv_new_value = lv_partner_no).
ENDMETHOD.

ToEmployee Details

METHOD eh_ontoemployee.
DATA: lr_ent TYPE REF TO cl_crm_bol_entity,
lr_cw TYPE REF TO cl_bsp_wd_collection_wrapper,
lv_indexTYPE i,
lr_col TYPE REF TO if_bol_bo_col.
cl_thtmlb_util=>get_event_info(
EXPORTING
iv_event= htmlb_event_ex
IMPORTING
ev_index= lv_index).
* get collection wrapper
lr_cw ?= get_collection_wrapper( gc_context_node_admini).
* set row index on collection
lr_ent ?= lr_cw->find( iv_index= lv_index).
lr_ent= lr_ent->get_related_entity( iv_relation_name= 'BTItemPartnerSet' ). "#EC NOTEXT
CHECK lr_entIS BOUND.
lr_col= lr_ent->get_related_entities( iv_relation_name= 'BTPartner_00000052_MAIN' ). "EC NOTEXT
IF lr_colIS BOUND AND lr_col->size( )0.
op_navigate_display( lr_col).
ENDIF.
ENDMETHOD.

Outboudplugs

Dynamic NavigatetoEmployee

METHOD op_navigate_display.
DATA: lr_nav_cuco TYPE REF TO if_crm_ui_navigation_service,
lv_descriptor_objectTYPE REF TO if_bol_bo_property_access,
prop TYPE REF TO if_bol_bo_property_access,
ent TYPE REF TO cl_crm_bol_entity,
ui_object_type TYPE bsp_dlc_object_type,
bp_guid TYPE bu_partner_guid,
lv_partner TYPE bu_partner,
lv_col_empl TYPE REF TO if_bol_bo_col,
gr_badi_name TYPE REF TO ecrm_isu_bp_get_ui_object_type.
* navigate dynamically to partner
prop = iv_data_collection->get_first( ).
CHECK prop IS BOUND.
ent ?= prop.
CHECK entIS BOUND.
CALL METHOD ent->if_bol_bo_property_access~get_property_as_value
EXPORTING
iv_attr_name= 'PARTNER_GUID'
IMPORTING
ev_result = bp_guid.
lr_nav_cuco ?= cl_crm_ui_navigation_service=>get_instance( iv_controller= me ).
iv_data_collection->clear( ).
CALL METHOD cl_crm_ui_descriptor_obj_srv=>create_ui_object_based
EXPORTING
iv_ui_object_type = if_crm_uiu_object_types_const=>gc_employee
iv_ui_object_action= 'B'
RECEIVING
rr_result = lv_descriptor_object.
CALL METHOD ent->if_bol_bo_property_access~get_property_as_value
EXPORTING
iv_attr_name= 'PARTNER_NO '
IMPORTING
ev_result = lv_partner.
CALL METHOD cl_bp_abc_uiu_tools=>get_collection_with_employee
EXPORTING
iv_partner = lv_partner
RECEIVING
rv_collection= lv_col_empl.
ent ?= lv_col_empl->get_first( ).
iv_data_collection->add( ent).
iv_data_collection->add( lv_descriptor_object).
lr_nav_cuco->navigate_dynamically( iv_data_collection= iv_data_collection).
ENDMETHOD.

Search Employee

METHOD op_searchemployee.
DATA:
lv_attribute TYPE string,
lv_model TYPE string,
lv_event_stringTYPE string.
cl_chtmlb_config_utility=>outbound_plug_event_info(
EXPORTING
iv_event_string= lv_event_string
IMPORTING
ev_model_name = lv_model
ev_index = gv_linenumber
ev_attribute = lv_attribute).
DATA lv_titleTYPE string.
lv_title= cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BT/EMPLOYEE_SEARCH' ).
bpsearch_employee_popup= comp_controller->window_manager->create_popup(
iv_interface_view_name= 'SearchHelpWindow'
iv_usage_name= 'CUBPSearchEmployee'
iv_title= lv_title).
bpsearch_employee_popup->set_on_close_event( iv_view= me iv_event_name= 'SELEXEC_SRV_EMP' ).
* set display mode
bpsearch_employee_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_surrounded).
* Open the Popup
bpsearch_employee_popup->open( iv_inbound_plug= 'CLEAR_ALL' ).
ENDMETHOD.