FPM提高篇-创建应用程序控制器
1. 应用程序控制器介绍
应用控制器可用来管理FPM页面元素,包括UIBB、按钮、文本描述等
2. 创建Component Configuration
3. 创建并选择FBI应用程序控制器/控制器退出类
FBI应用程序控制器:继承超类
/BOFU/CL_FBI_CONTROLLER_NEW
控制器退出类(可选):实现接口/BOFU/IF_FBI_CONTROLLER_EXIT
,并重定义所有方法
4. 使用应用程序控制器
在FPM页面中选择选择创建的Component Configuration
5. 应用
5.1 控制UIBB属性
IWCI_IF_FPM_OVP_CONF_EXIT~OVERRIDE_EVENT_OVP
读取UIBB的基本属性并修改
DATA(lv_eventid) = io_ovp->get_event( )->mv_event_id.
DATA: lv_hidden_list TYPE C.
DATA: lv_hidden_tree TYPE C.
io_ovp->get_uibbs(
EXPORTING
iv_content_area = 'PAGE_1'
iv_section = 'SECTION_1'
IMPORTING
et_uibb = DATA(lt_uibbs)
* es_maximized_uibb_key =
).
**判断权限控制UIBB是否要隐藏
AUTHORITY-CHECK OBJECT 'ZRE_RPEV'
ID 'ACTVT' FIELD '46'.
* ID '/RER/ORGID' FIELD 'xxxxxxxx'.
IF SY-SUBRC = 0.
lv_hidden_list = abap_true .
lv_hidden_tree = abap_false .
ELSE.
lv_hidden_list = abap_false .
lv_hidden_tree = abap_true .
ENDIF.
LOOP AT lt_uibbs ASSIGNING FIELD-SYMBOL(<fs_uibb>).
IF <fs_uibb>-config_id = 'ZRRE_UIBB_EVALU_LIST'.
<fs_uibb>-hidden = lv_hidden_list .
ELSEIF <fs_uibb>-config_id = 'ZRRE_UIBB_EVALU_TREE'.
<fs_uibb>-hidden = lv_hidden_tree .
ELSE.
<fs_uibb>-hidden = abap_false.
ENDIF.
io_ovp->change_uibb(
EXPORTING
is_uibb = <fs_uibb>
iv_section = 'SECTION_1'
).
ENDLOOP.
5.2 navigate restart
DATA lo_navigate_to TYPE REF TO if_fpm_navigate_to.
data: mo_fpm type ref to IF_FPM.
CALL METHOD mo_fpm->get_navigate_to
RECEIVING
ro_navigate_to = lo_navigate_to.
lo_navigate_to->restart( '' ).
5.3 AFTER_NEEDS_CONFIRMATION
IWCI_IF_FPM_APP_CONTROLLER~AFTER_NEEDS_CONFIRMATION
METHOD iwci_if_fpm_app_controller~after_needs_confirmation.
DATA:lo_fpm TYPE REF TO if_fpm,
lv_cancel TYPE char1.
CASE io_event->mv_event_id.
WHEN if_fpm_constants=>gc_event-read_only.
lo_fpm ?= cl_fpm_factory=>get_instance( ).
IF lo_fpm IS BOUND.
lo_fpm->mo_app_parameter->get_value(
EXPORTING
iv_key = 'CANCEL_DIAG'
IMPORTING
ev_value = lv_cancel
* er_value =
).
IF lv_cancel IS NOT INITIAL.
lo_fpm->mo_app_parameter->delete_value( iv_key = 'CANCEL_DIAG' ).
CLEAR ct_confirmation_requests.
ENDIF.
ENDIF.
WHEN OTHERS.
CALL METHOD super->iwci_if_fpm_app_controller~after_needs_confirmation
EXPORTING
io_event = io_event
it_uibbs = it_uibbs
CHANGING
ct_confirmation_requests = ct_confirmation_requests.
ENDCASE.
ENDMETHOD.
5.4 控制Tab页签
method IF_FPM_TABBED_CONF_EXIT~OVERRIDE_CONFIG_TABBED.
DATA: lt_tab TYPE if_fpm_tabbed=>ty_t_tab,
lo_fpm TYPE REF TO if_fpm,
ls_tab LIKE LINE OF lt_tab.
DATA lv_conttype TYPE /RER/cont_type.
DATA lv_contfclass TYPE /RER/cont_fclass.
DATA lv_str TYPE string.
DATA ls_sclass TYPE /RER/d_contscls.
CASE io_tabbed->mo_event->mv_event_id.
WHEN 'CHANGE_TAB'.
lo_fpm ?= cl_fpm_factory=>get_instance( ).
CALL METHOD lo_fpm->mo_app_parameter->get_value
EXPORTING
iv_key = 'TAB_ID'
IMPORTING
ev_value = lv_str.
TRY .
io_tabbed->set_variant( iv_variant_id = lv_str ).
io_tabbed->set_selected_tab( iv_variant_id = lv_str iv_tab_id = 'TAB_1' ).
IF /RER/cl_con_ac_root=>ss_contract-contcate = '01'
AND /RER/cl_con_ac_root=>ss_contract-contfclass = '01'.
CALL METHOD io_tabbed->set_tab_visible
EXPORTING
iv_tab_id = 'TAB_3'
iv_visible = abap_false.
CALL METHOD io_tabbed->set_tab_visible
EXPORTING
iv_tab_id = 'TAB_20'
iv_visible = abap_true.
ELSE.
CALL METHOD io_tabbed->set_tab_visible
EXPORTING
iv_tab_id = 'TAB_3'
iv_visible = abap_true.
CALL METHOD io_tabbed->set_tab_visible
EXPORTING
iv_tab_id = 'TAB_20'
iv_visible = abap_false.
ENDIF.
CATCH cx_fpm_floorplan.
ASSERT CONDITION 1 = 2.
ENDTRY.
ENDCASE.
endmethod.
5.5 控制按钮
DATA: lo_fpm TYPE REF TO cl_fpm,
lo_cnr_ovp TYPE REF TO if_fpm_cnr_ovp,
ls_button TYPE if_fpm_ovp=>ty_s_toolbar_button,
lt_toolbar_element TYPE if_fpm_ovp=>ty_t_toolbar_element.
lo_fpm ?= cl_fpm_factory=>get_instance( ).
CHECK lo_fpm IS BOUND.
lo_cnr_ovp ?= lo_fpm->if_fpm~get_service( cl_fpm_service_manager=>gc_key_cnr_ovp ).
TRY.
* Read all buttons 读取所有按钮
lo_cnr_ovp->get_toolbar_elements(
EXPORTING
iv_content_area = iv_content_area_id
IMPORTING
et_toolbar_element = lt_toolbar_element ).
LOOP AT lt_toolbar_element ASSIGNING <fs_toolbar_element>.
* IF <fs_toolbar_element>-type = 'BU'.
IF <fs_toolbar_element>-element_id <> 'FPM_SAVE_1' AND <fs_toolbar_element>-element_id <> 'FPM_CANCEL_1'
AND <fs_toolbar_element>-element_id <> 'FPM_EDIT_1' .
* Get button attribute 获取按钮属性
lo_cnr_ovp->get_toolbar_button(
EXPORTING
iv_toolbar_element_id = <fs_toolbar_element>-element_id
iv_content_area = iv_content_area_id
IMPORTING
es_toolbar_button = ls_button ).
IF iv_mode = 'E' .
ls_button-enabled = abap_false.
ELSEIF iv_mode = 'R' AND ls_cn_dsdf-estat_jf = '01' .
ls_button-enabled = abap_true.
ELSEIF iv_mode = 'R' AND ls_cn_dsdf-estat_jf = '03' .
ls_button-enabled = abap_false.
ENDIF.
IF io_event->mv_event_id = 'FPM_CANCEL'.
* AND io_event->mv_event_id = 'FPM_LOCAL_EDIT'.
ls_button-enabled = abap_true.
ENDIF.
IF lv_djz = abap_false AND <fs_toolbar_element>-element_id = 'ACTION_ID_1'.
ls_button-visibility = '01'.
ENDIF.
*Change button attribute 修改按钮属性
lo_cnr_ovp->change_toolbar_button(
EXPORTING
is_toolbar_button = ls_button
iv_content_area = iv_content_area_id
iv_override_existing_action = abap_true ).
ENDIF.
ENDLOOP.
CATCH cx_fpm_floorplan. "#EC NO_HANDLER " Floorplan exceptions
ENDTRY.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Hblog!