1,取附件内容放到新增的字段里
METHOD get_attachment. DATA: current TYPE REF TO if_bol_bo_property_access. DATA: dref TYPE REF TO data. DATA:gv_guid TYPE crmt_object_guid, ls_business_object TYPE sibflporb, lt_phioloios TYPE skwf_lpios, ls_phioloios LIKE LINE OF lt_phioloios, lt_ios_prop_result TYPE crm_kw_propst, ls_ios_prop_result LIKE LINE OF lt_ios_prop_result, lt_prop TYPE sdokproptls, ls_prop TYPE sdokproptl. FIELD-SYMBOLS: <nval> TYPE any, <oval> TYPE any. * get current entity IF iterator IS BOUND. current = iterator->get_current( ). ELSE. current = collection_wrapper->get_current( ). ENDIF. current->get_property_as_value( EXPORTING iv_attr_name = 'BP_GUID' IMPORTING ev_result = gv_guid ). CHECK gv_guid IS NOT INITIAL. "取出BP对应的附件信息 ls_business_object-instid = gv_guid. ls_business_object-typeid = 'BUS1006'. ls_business_object-catid = 'BO'. CALL METHOD cl_crm_documents=>get_info EXPORTING business_object = ls_business_object IMPORTING phioloios = lt_phioloios ios_properties_result = lt_ios_prop_result. READ TABLE lt_phioloios INTO ls_phioloios INDEX 1. IF sy-subrc = 0. READ TABLE lt_ios_prop_result INTO ls_ios_prop_result WITH KEY objtype = ls_phioloios-objtypelo class = ls_phioloios-classlo objid = ls_phioloios-objidlo. IF sy-subrc = 0. READ TABLE ls_ios_prop_result-properties INTO ls_prop WITH KEY name = 'KW_RELATIVE_URL'. IF sy-subrc = 0. value = ls_prop-value. ENDIF. ENDIF. ENDIF. ENDMETHOD.
2,设置字段类型
METHOD get_p_attachment. 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 = 'DISPLAY_DOC'. "... ENDCASE.
3,设置点击事件
METHOD eh_ondisplay_doc. * Added by wizard: Handler for event 'DISPLAY_DOC' DATA: lv_index TYPE int4, lr_entity_ext TYPE REF TO if_bol_bo_property_access,"if_bsp_wd_ext_property_access, lr_entity TYPE REF TO cl_crm_bol_entity, lr_coco TYPE REF TO cl_gs_cm_bspwdcomponent, lr_bsp_runtime TYPE REF TO cl_bsp_runtime, ls_attributes TYPE crmt_cmic_doc_attr, lr_data TYPE REF TO data. FIELD-SYMBOLS: <fs_key> TYPE string. DATA: current TYPE REF TO if_bol_bo_property_access. DATA: dref TYPE REF TO data. DATA:gv_guid TYPE crmt_object_guid, ls_business_object TYPE sibflporb, lt_phioloios TYPE skwf_lpios, ls_loio TYPE skwf_io, lv_url TYPE saeuri, ls_phioloios LIKE LINE OF lt_phioloios, lt_ios_prop_result TYPE crm_kw_propst, ls_ios_prop_result LIKE LINE OF lt_ios_prop_result, lt_prop TYPE sdokproptls, ls_prop TYPE sdokproptl. * get index of the table cl_thtmlb_util=>get_event_info( EXPORTING iv_event = htmlb_event_ex IMPORTING ev_index = lv_index ). * get entity from mixed note lr_entity_ext ?= me->typed_context->result->collection_wrapper->find( iv_index = lv_index ). CHECK lr_entity_ext IS BOUND. lr_entity_ext->get_property_as_value( EXPORTING iv_attr_name = 'BP_GUID' IMPORTING ev_result = gv_guid ). CHECK gv_guid IS NOT INITIAL. "取出BP对应的附件信息 ls_business_object-instid = gv_guid. ls_business_object-typeid = 'BUS1006'. ls_business_object-catid = 'BO'. CALL METHOD cl_crm_documents=>get_info EXPORTING business_object = ls_business_object IMPORTING phioloios = lt_phioloios ios_properties_result = lt_ios_prop_result. READ TABLE lt_phioloios INTO ls_phioloios INDEX 1. IF sy-subrc = 0. READ TABLE lt_ios_prop_result INTO ls_ios_prop_result WITH KEY objtype = ls_phioloios-objtypelo class = ls_phioloios-classlo objid = ls_phioloios-objidlo. IF sy-subrc = 0. READ TABLE ls_ios_prop_result-properties INTO ls_prop WITH KEY name = 'KW_RELATIVE_URL'. IF sy-subrc = 0. ENDIF. ENDIF. ls_loio-objtype = ls_phioloios-objtypelo. ls_loio-class = ls_phioloios-classlo. ls_loio-objid = ls_phioloios-objidlo. CALL METHOD cl_crm_documents=>get_with_url EXPORTING loio = ls_loio url_type = '2' IMPORTING url = lv_url EXCEPTIONS no_io = 1 OTHERS = 2. CHECK lv_url IS NOT INITIAL. ls_attributes-url_to_display = lv_url. CONCATENATE gv_doc_display_js 'thtmlbSuppressOnLoadKeyboardFocus(); window.open("' ls_attributes-url_to_display '", ' sy-timlo ')' INTO gv_doc_display_js. ENDIF. ENDMETHOD.
效果:
标签:prop,lt,UI,ls,附件,BP,phioloios,TYPE,result From: https://www.cnblogs.com/sapSB/p/17377246.html