创建FPM应用-修改
创建FPM应用 – 修改集(SET)
预定完成目标:
- 超链接页面跳转 – 点击事件
- 表单组件
第一步 对FPM应用改造
上一章的查询结果是setleaf中的明细数据,这次我们改为只取setheader中的抬头数据
第二步 集名称字段添加超链接
第三步 添加FPM事件
添加超链接后字段显示为蓝色,发现点击无反应,此时需要分配
FPM事件分配
,并把事件分配给链接;修改 IF_FPM_GUIBB_LIST~GET_DEFINITION 添加事件;
当然因为我们只加了一个链接,也可以使用标准分配不自己创建。标准分配对应的事件名为:FPM_GUIBB_LIST_CELL_ACTION,每次点击链接都会触发此事件;
此次我们直接使用标准分配,这一步可跳过
METHOD IF_FPM_GUIBB_LIST~GET_DEFINITION.
DATA:lo_structdescr TYPE REF TO cl_abap_structdescr, "设置界面字段
lo_abap_str TYPE REF TO cl_abap_structdescr,
lt_comp_tab TYPE abap_component_tab, "界面字段名
ls_comp_tab TYPE abap_componentdescr. "界面字段名
FIELD-SYMBOLS:<fs_field_des> TYPE fpmgb_s_listfield_descr.
eo_field_catalog ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_NAME( 'YTEST_S_SETLEAF_T' ).
" 界面字段的设置
lo_structdescr ?= eo_field_catalog->get_table_line_type( ).
LOOP AT lo_structdescr->components INTO DATA(ls_component).
APPEND INITIAL LINE TO et_field_description ASSIGNING <fs_field_des>.
<fs_field_des>-name = ls_component-name.
<fs_field_des>-allow_sort = abap_true.
<fs_field_des>-allow_aggregation = abap_false.
<fs_field_des>-allow_filter = abap_true.
<fs_field_des>-null_as_blank = abap_true.
<fs_field_des>-read_only = abap_true.
CASE <fs_field_des>-name.
WHEN 'Field1' or 'PLSTA' or 'PLTYP'.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
*添加事件
APPEND INITIAL LINE TO et_action_definition ASSIGNING FIELD-SYMBOL(<fs_action>).
IF sy-subrc = 0.
<fs_action>-id = 'LNK_SETNAME'."事件名称
<fs_action>-enabled = abap_true.
<fs_action>-disable_when_no_sel = abap_true.
ENDIF.
ENDMETHOD.
第四步 创建set集合的明细页面
说明:明细页上面使用表单组件显示集合的抬头信息,下部分使用列表组件显示集合的明细条目;为此我们需要再分别创建两个配置及两个feeder类
表单组件UIBB:FPM_FORM_UIBB_GL2
配置标识:ZT_WDCC_J4TEST03_H_FORM
feeder类:ZCL_J4TEST03_H_FORM – 使用接口情况
- IF_FPM_GUIBB
- IF_FPM_FEEDER_MODEL
- IF_FPM_QUICKVIEW_SOURCE
- IF_FPM_GUIBB_FORM
- IF_FPM_GUIBB_FORM_EXT
- IF_FPM_GUIBB_OVS – 搜索帮助/联合搜索帮助
配置抬头页面布局,把显示的抬头信息配置到抬头页面上
列表组件UIBB:FPM_LIST_UIBB_ATS
配置标识:ZT_WDCC_J4TEST03_H_LIST
feeder类:ZCL_J4TEST03_LIST
- IF_FPM_GUIBB
- IF_FPM_GUIBB_LIST
- IF_FPM_GUIBB_LIST_EXT
结果如下:
抬头页面布局
明细列表布局
第五步 页面跳转事件触发
前面完成了点击事件的设置,当点击链接时在Process_event中完成对事件的捕捉
事件名:FPM_GUIBB_LIST_CELL_ACTION
方法名:IF_FPM_GUIBB_LIST~PROCESS_EVENT
跳转方式(一) 打开新标签页
跳转的方法如下:
METHOD IF_FPM_GUIBB_LIST~PROCESS_EVENT.
DATA: lo_flp_navigate TYPE REF TO if_fpm_flp_navigation,
lt_app_params TYPE apb_lpd_t_params,
ls_app_param LIKE LINE OF lt_app_params[].
"获取FPM 实例
MO_FPM ?= CL_FPM_FACTORY=>GET_INSTANCE( ).
CASE IO_EVENT->MV_EVENT_ID.
WHEN 'FPM_GUIBB_LIST_CELL_ACTION'.
"获取点击的行项目数据
READ TABLE mt_result ASSIGNING FIELD-SYMBOL(<fs_data>) INDEX iv_event_index.
IF sy-subrc = 0.
lo_flp_navigate = mo_fpm->get_flp_navigation( ).
CALL METHOD lo_flp_navigate->navigate
EXPORTING
iv_semantic_object = 'setc' "
iv_action = 'manage'
it_parameter = VALUE #(
( name = /rer/if_constants=>gc_app_param-key value = <fs_data>-setname )
( name = if_fpm_constants=>gc_app_params-edit_mode value = if_fpm_constants=>gc_edit_mode-read_only )
)
.
ENDIF.
ENDCASE.
ENDMETHOD.
本次应用中同时创建了
初始页面
和主页面
。打开本应用时默认进入初始页面–查询功能页面,点击链接打开新的标签页进入详细信息页面。此时会发现,新标签页仍会进入初始页面
,为了进入主页面需要触发一 个事件cl_fpm_event=>gc_event_leave_initial_screen
。 采用方法:1.添加一个空的FORM组件–
FPM_FORM_UIBB_GL2
;2.在此组件的feeder类中添加校验,判断是否传入了集合ID,参数在mo_fpm中查找
具体内容复制于/CPD/CL_FBI_GUIBB_BOOTSTRAP
METHOD IF_FPM_GUIBB_FORM~GET_DATA.
DATA:
ls_key_provider TYPE ty_key_providers,
lv_skip_preselection TYPE xfeld,
lv_skip_initscreen TYPE boole_d,
lo_event TYPE REF TO cl_fpm_event.
* BREAK SEPRI_HANCHX.
CASE io_event->mv_event_id.
WHEN cl_fpm_event=>gc_event_start.
LOOP AT mt_key_providers INTO ls_key_provider.
lv_skip_preselection = ls_key_provider-provider->skip_preselection( ).
IF lv_skip_preselection IS NOT INITIAL.
mo_fpm->raise_event_by_id(
EXPORTING
iv_event_id = cl_fpm_event=>gc_event_leave_initial_screen
).
RETURN.
ENDIF.
ENDLOOP.
* Additionally check SKIP_INITIAL_SCREEN application parameter
mo_fpm->mo_app_parameter->get_value(
EXPORTING
* iv_key = /bofu/if_fbi_runtime_c=>sc_application_parameters-skip_initial
iv_key = /rer/if_constants=>gc_app_param-key
IMPORTING
ev_value = MV_KEY
).
IF MV_KEY IS NOT INITIAL.
mo_fpm->raise_event_by_id(
EXPORTING
iv_event_id = cl_fpm_event=>gc_event_leave_initial_screen
).
RETURN.
ENDIF.
ENDCASE.
ENDMETHOD.
跳转方式(二) 打开新窗口
具体方法这里不再赘述了,把代码贴上
* CLEAR ls_app_param.
* ls_app_param-key = 'KEY'.
* ls_app_param-value = ls_key-key.
* APPEND ls_app_param TO lt_app_params.
* CLEAR ls_app_param.
* ls_app_param-key = 'SKIP_INITIAL_SCREEN'.
* ls_app_param-value = 'X'.
* APPEND ls_app_param TO lt_app_params.
* CLEAR ls_app_param.
* ls_app_param-key = 'FPM_EDIT_MODE'.
* ls_app_param-value = 'R'.
* APPEND ls_app_param TO lt_app_params.
* CLEAR ls_app_param.
*
* IF <fs_data>-PLSTA = '02' or <fs_data>-PLSTA = '04'.
* ls_app_param-value = 'R'.
* ELSE.
* ls_app_param-value = 'E'.
* ENDIF.
* ls_app_param-key = 'CHANGE_MODE'.
* APPEND ls_app_param TO lt_app_params.
* CLEAR ls_app_param.
*
*
* zrre_cl_ps_utility=>launch_webdynpro_abap(
* EXPORTING
* iv_wda = 'ZT_WDA_J4TEST_03'
* iv_wdac = 'ZT_WDCC_J4TEST_03'
* it_parameter = lt_app_params
* ).
zrre_cl_ps_utility=>launch_webdynpro_abap
参数如下:
@78\QImporting@ IV_WDA TYPE APB_LPD_STRING
@78\QImporting@ IV_WDAC TYPE APB_LPD_STRING OPTIONAL
@78\QImporting@ IV_HEADER_TEXT TYPE APB_LPD_LINK_TEXT OPTIONAL
@78\QImporting@ IT_PARAMETER TYPE APB_LPD_T_PARAMS OPTIONAL
@78\QImporting@ IS_ADDITIONAL_PARAMETERS TYPE APB_LPD_S_ADD_WD_PARAMETERS OPTIONAL
METHOD launch_webdynpro_abap.
DATA: lr_navigate_to TYPE REF TO if_fpm_navigate_to,
lr_fpm TYPE REF TO if_fpm,
ls_webdynpro_fld TYPE fpm_s_launch_webdynpro,
ls_add_param TYPE apb_lpd_s_add_wd_parameters,
lt_message TYPE fpm_t_t100_messages,
ls_message LIKE LINE OF lt_message,
lv_error TYPE boole_d,
ls_parameter TYPE apb_lpd_s_params,
lt_parameter TYPE apb_lpd_t_params
.
lr_fpm = cl_fpm_factory=>get_instance( ).
lr_navigate_to = lr_fpm->get_navigate_to( ).
IF it_parameter IS NOT INITIAL.
lt_parameter = it_parameter.
ENDIF.
ls_parameter-key = 'sap-language'.
ls_parameter-value = sy-langu.
APPEND ls_parameter TO lt_parameter.
ls_webdynpro_fld-wd_application = iv_wda.
ls_webdynpro_fld-wd_configuration = iv_wdac.
ls_webdynpro_fld-system_alias = sy-sysid.
ls_webdynpro_fld-wd_namespace = 'sap'.
ls_webdynpro_fld-header_text = iv_header_text.
ls_webdynpro_fld-parameter = lt_parameter.
lr_fpm->get_navigate_to( )->launch_webdynpro_abap(
EXPORTING
is_webdynpro_fields = ls_webdynpro_fld
is_additional_parameters = CORRESPONDING #( is_additional_parameters )"ls_add_param
IMPORTING
et_messages = lt_message
ev_error = lv_error ).
LOOP AT lt_message INTO ls_message.
lr_fpm->mo_message_manager->report_t100_message(
EXPORTING
io_component = lr_fpm
iv_msgid = ls_message-msgid
iv_msgno = ls_message-msgno
iv_severity = ls_message-severity
iv_lifetime = ls_message-lifetime
iv_parameter_1 = ls_message-parameter_1
iv_parameter_2 = ls_message-parameter_2
iv_parameter_3 = ls_message-parameter_3
iv_parameter_4 = ls_message-parameter_4 ).
ENDLOOP.
ENDMETHOD.
跳转方式(三)打开对话框
代码如下:
DATA: lr_event_data TYPE REF TO cl_fpm_parameter,
ls_dialog_box_properties TYPE fpm_s_dialog_box_properties.
ls_dialog_box_properties-button_set = if_ehfnd_fpm_cfg_constants=>gc_dialog_button_ok_cancel . "3
ls_dialog_box_properties-height = /rer/if_common_const=>sc_dialog_height-height_300.
ls_dialog_box_properties-width = /rer/if_common_const=>sc_dialog_width-width_900.
CLEAR: lr_event_data.
CREATE OBJECT lr_event_data.
Mo_fpm->mo_app_parameter->SET_VALUE(
EXPORTING
iv_key = 'FPM_EDIT_MODE'
iv_value = 'E'
).
lr_event_data->IF_FPM_PARAMETER~SET_VALUE(
EXPORTING
iv_key = 'CHANGE_MODE'
iv_value = 'U'
).
Mo_fpm->open_dialog_box(
EXPORTING is_dialog_box_properties = ls_dialog_box_properties
iv_dialog_box_id = 'SH'
io_event_data = lr_event_data ).