接以前做的例子,用组件做了个搜索界面,明细里添加了object_id的链接:
method GET_P_OBJECT_ID. "#EC NEEDED ** generated by search page wizard if me->running_in_f4_popup( ) = abap_false. 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 = 'CLICKONLINK'. endcase. endif. endmethod.
DATA lv_index TYPE i. DATA: lv_action TYPE c. cl_thtmlb_util=>get_event_info( EXPORTING iv_event = htmlb_event_ex IMPORTING ev_index = lv_index ). DATA lr_node TYPE REF TO if_bol_bo_property_access. lr_node ?= me->typed_context->searchresultnode->collection_wrapper->find( iv_index = lv_index ). DATA lv_guid TYPE CRMT_OBJECT_GUID." REF TO data. DATA lv_obj TYPE crmt_object_id. lr_node->get_property_as_value( EXPORTING iv_attr_name = 'OBJECT_ID' IMPORTING ev_result = lv_obj ). SELECT SINGLE GUID INTO LV_GUID FROM CRMD_ORDERADM_H WHERE OBJECT_ID = LV_OBJ. DATA: lv_bol_core TYPE REF TO cl_crm_bol_core. lv_bol_core = cl_crm_bol_core=>get_instance( ). lv_bol_core->start_up( 'BT' ). DATA lr_entity TYPE REF TO cl_crm_bol_entity. lr_entity = lv_bol_core->get_root_entity( iv_object_name = 'BTOrder' iv_object_guid = LV_GUID ). * 将跟对象传递到window_controller DATA lr_col TYPE REF TO cl_crm_bol_entity_col. CREATE OBJECT lr_col. lr_col->if_bol_bo_col~add( lr_entity ). DATA: lr_window TYPE REF TO cl_bsp_wd_window. lr_window = me->view_manager->get_window_controller( ). lr_window->call_outbound_plug( iv_outbound_plug = 'DEFAULT' iv_data_collection = lr_col ).
method OP_DEFAULT. CONSTANTS lv_ui_action TYPE crmt_ui_actions VALUE 'B'. "display DATA lr_ent TYPE REF TO if_bol_bo_property_access. DATA lr_descriptor_object TYPE REF TO cl_crm_ui_descriptor_object. lr_ent ?= iv_data_collection->get_first( ). CATCH SYSTEM-EXCEPTIONS move_cast_error = 4. lr_descriptor_object ?= lr_ent. ENDCATCH. IF sy-subrc NE 0. CALL METHOD cl_crm_uiu_bt_navigate=>prepare_col_for_navigate EXPORTING ir_collection = iv_data_collection iv_ui_action = lv_ui_action EXCEPTIONS no_nav_descriptor_inserted = 1 OTHERS = 2. ENDIF. IF sy-subrc EQ 0. DATA lr_nav TYPE REF TO if_crm_ui_navigation_service. lr_nav = cl_crm_ui_navigation_service=>get_instance( me ). * Navigate to Target Component lr_nav->navigate_dynamically( iv_data_collection ). ENDIF. endmethod.
上面是做成通用的,下面是给单独事件的:
METHOD eh_onclickno. DATA: lv_index TYPE int4, * lr_comp_controller TYPE REF TO cl_bt111s_o_bspwdcomponen_impl, * lr_cuco TYPE REF TO cl_bt111s_o_cucosearch_impl, lr_entity TYPE REF TO if_bol_bo_property_access, lv_event TYPE REF TO cl_htmlb_event_tableview, lr_msg_srv TYPE REF TO cl_bsp_wd_message_service, lv_subrc TYPE sy-subrc, lv_tableview_ex TYPE REF TO cl_thtmlb_table_view. CALL METHOD cl_thtmlb_util=>get_event_info EXPORTING iv_event = htmlb_event_ex IMPORTING ev_index = lv_index. * set entity as current one lr_entity ?= me->typed_context->result->collection_wrapper->find( iv_index = lv_index ). CHECK lr_entity IS BOUND. DATA l_guid TYPE crmd_orderadm_h-guid. CALL METHOD lr_entity->get_property_as_string EXPORTING iv_attr_name = 'GUID' * iv_use_iso_format = ABAP_FALSE RECEIVING rv_result = l_guid. DATA lr_core TYPE REF TO cl_crm_bol_core. DATA lr_bt TYPE REF TO cl_crm_bol_entity. lr_core = cl_crm_bol_core=>get_instance( ). *初始化 BT为组件集名称 lr_core->start_up( 'BT' ). TRY. CALL METHOD lr_core->get_root_entity EXPORTING iv_object_name = 'BTOrder' iv_object_guid = l_guid " 单句对应的GUID RECEIVING rv_result = lr_bt. CATCH cx_crm_genil_model_error . ENDTRY. CHECK lr_bt IS BOUND. RAISE EVENT history_trigger. DATA: lr_nav_descr TYPE REF TO if_bol_bo_property_access. DATA: lr_navigation TYPE REF TO if_crm_ui_navigation_service. DATA: lr_col TYPE REF TO cl_crm_bol_bo_col. DATA: rv_value_node TYPE REF TO cl_bsp_wd_value_node. cl_crm_ui_descriptor_obj_srv=>create_ui_object_based( EXPORTING iv_ui_object_type = 'BT116_SRVO' iv_ui_object_action = 'B' RECEIVING rr_result = lr_nav_descr ). CHECK lr_nav_descr IS BOUND. lr_navigation = cl_crm_ui_navigation_service=>get_instance( me ). CHECK lr_navigation IS BOUND. * Check whether navigation is supported IF lr_navigation->is_dynamic_nav_supported( lr_nav_descr ) NE abap_true. RETURN. ELSE. CREATE OBJECT lr_col. lr_col->if_bol_bo_col~add( iv_entity = lr_nav_descr ). lr_col->if_bol_bo_col~add( iv_entity = lr_bt iv_set_focus = abap_true ). lr_navigation->navigate_dynamically( lr_col ). ENDIF. ENDMETHOD.