WEBDYNPRO FPM 框架

发布时间:2024年01月19日

框架搭建

1、FPM_OVP_COMPONENT

 1 METHOD change_toolbar_btn .
 2 * enabled     "ABAP_TRUE可用 ABAP_FALSE不可用
 3 * visibility  "01不可见 02可见
 4   DATA: ls_btn TYPE if_fpm_ovp=>ty_s_toolbar_button.
 5   CHECK wd_this->mo_cnr IS BOUND.
 6 
 7   TRY .
 8       CLEAR:ls_btn.
 9       wd_this->mo_cnr->get_toolbar_button(
10         EXPORTING
11           iv_toolbar_element_id = id
12         IMPORTING
13           es_toolbar_button     = ls_btn
14       ).
15       CHECK ls_btn IS NOT INITIAL.
16 
17 *      IF text IS SUPPLIED.
18       ls_btn-text = text.
19 *      ENDIF.
20       IF enabled IS SUPPLIED.
21         ls_btn-enabled = enabled.
22       ENDIF.
23       IF visibility IS SUPPLIED.
24         ls_btn-visibility = visibility.
25       ENDIF.
26 
27       wd_this->mo_cnr->change_toolbar_button(
28         iv_content_area   = \'PAGE_1\'
29         is_toolbar_button = ls_btn ).
30     CATCH cx_root INTO DATA(lo_err).
31       DATA(lv_txt) = lo_err->get_text( ).
32   ENDTRY.
33 
34 ENDMETHOD.
1 METHOD fire_view_action .
2 
3   DATA: lo_action TYPE REF TO cl_wdr_action.
4   lo_action ?= wd_this->z_curr_view->get_action( action_name ).
5   CHECK lo_action IS BOUND.
6   lo_action->fire( ).
7 
8 ENDMETHOD.
 1 METHOD init_toolbar .
 2 
 3   DATA: lt_elm     TYPE if_fpm_ovp=>ty_t_toolbar_element,
 4         lv_txt     TYPE fpm_text,
 5         lv_enable  TYPE fpm_enabled,
 6         lv_visible TYPE fpm_visibility.
 7 
 8   wd_this->mo_fpm = cl_fpm_factory=>get_instance( ).
 9   wd_this->mo_cnr ?= wd_this->mo_fpm->get_service( `CNR_OVP` ).
10 
11   TRY.
12       wd_this->mo_cnr->get_toolbar_elements( IMPORTING et_toolbar_element = lt_elm ).
13     CATCH cx_root INTO DATA(lo_err).
14       DATA(lv_err_txt) = lo_err->get_text( ).
15   ENDTRY.
16 
17   LOOP AT lt_elm INTO DATA(ls_elm).
18     CLEAR:lv_txt.
19     CASE ls_elm-element_id.
20       WHEN \'FPM_SAVE_1\'.
21         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/SAVE\' ).
22         lv_enable = abap_true.
23         lv_visible = 2.
24 
25       WHEN \'FPM_CANCEL_1\'.
26         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/ZCX\' ).
27         lv_enable = abap_true.
28         lv_visible = 2.
29 
30       WHEN \'ZMDG_COMMIT\'.
31         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/COMMIT\' ).
32         lv_enable = abap_true.
33         lv_visible = 2.
34 
35       WHEN \'ZMDG_COMMITSP\'.
36         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/SP\' ).
37         lv_enable = abap_true.
38         lv_visible = 1.
39 
40       WHEN \'ZMDG_COMMITSPJJ\'.
41         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/SPJJ\' ).
42         lv_enable = abap_true.
43         lv_visible = 1.
44 
45       WHEN OTHERS.
46     ENDCASE.
47 
48     CHECK lv_txt IS NOT INITIAL.
49     change_toolbar_btn(
50       id         = ls_elm-element_id
51       text       = lv_txt
52       enabled    = lv_enable
53       visibility = lv_visible
54     ).
55   ENDLOOP.
56 
57 ENDMETHOD.
  1 METHOD modify_toolbar .
  2 
  3 *  get view context
  4   DATA lo_view_context TYPE REF TO if_wd_context_node.
  5   lo_view_context ?= wd_this->z_curr_view->get_context( )->root_node.
  6 
  7   DATA: lo_nd_read_only    TYPE REF TO if_wd_context_node,
  8         lo_nd_dispaly_only TYPE REF TO if_wd_context_node,
  9         lo_el_read_only    TYPE REF TO if_wd_context_element,
 10         lo_el_dispaly_only TYPE REF TO if_wd_context_element.
 11 
 12   DATA: lv_commitoa       TYPE wdy_boolean,
 13         lv_read_commit    TYPE wdy_boolean,
 14         lv_dispaly_commit TYPE wdy_boolean.
 15 
 16 *   get node
 17   lo_nd_read_only = lo_view_context->get_child_node( name = wd_this->wdctx_read_only ).
 18   lo_nd_dispaly_only = lo_view_context->get_child_node( name = wd_this->wdctx_dispaly_only ).
 19 
 20 *   get element
 21   lo_el_read_only = lo_nd_read_only->get_element( ).
 22   lo_el_dispaly_only = lo_nd_dispaly_only->get_element( ).
 23   CHECK lo_el_read_only IS NOT INITIAL.
 24   CHECK lo_el_dispaly_only IS NOT INITIAL.
 25 
 26 *   get single attribute
 27   lo_el_read_only->get_attribute(
 28     EXPORTING
 29       name  = `COMMITOA`
 30     IMPORTING
 31       value = lv_commitoa ).
 32   lo_el_read_only->get_attribute(
 33     EXPORTING
 34       name  = `COMMIT`
 35     IMPORTING
 36       value = lv_read_commit ).
 37   lo_el_dispaly_only->get_attribute(
 38     EXPORTING
 39       name  = `COMMIT`
 40     IMPORTING
 41       value = lv_dispaly_commit ).
 42 
 43 
 44 
 45 *  change toolbar buttons attr.
 46   DATA: lt_elm     TYPE if_fpm_ovp=>ty_t_toolbar_element,
 47         lv_txt     TYPE fpm_text,
 48         lv_enable  TYPE fpm_enabled,
 49         lv_visible TYPE fpm_visibility.
 50   TRY.
 51       wd_this->mo_cnr->get_toolbar_elements( IMPORTING et_toolbar_element = lt_elm ).
 52     CATCH cx_root INTO DATA(lo_err).
 53       DATA(lv_err_txt) = lo_err->get_text( ).
 54   ENDTRY.
 55 
 56   LOOP AT lt_elm INTO DATA(ls_elm).
 57     CASE ls_elm-element_id.
 58       WHEN \'FPM_SAVE_1\'.
 59         lv_enable = lv_commitoa.
 60         IF lv_read_commit = abap_true.
 61           lv_visible = 2. "Visible
 62         ELSE.
 63           lv_visible = 1. "Invisible
 64         ENDIF.
 65         IF lv_visible = 1.
 66           lv_enable = abap_false.
 67         ENDIF.
 68         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/SAVE\' ).
 69 
 70       WHEN \'FPM_CANCEL_1\'.
 71         lv_enable = abap_true.
 72         IF lv_read_commit = abap_true.
 73           lv_visible = 2. "Visible
 74         ELSE.
 75           lv_visible = 1. "Invisible
 76         ENDIF.
 77         IF lv_visible = 1.
 78           lv_enable = abap_false.
 79         ENDIF.
 80         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/ZCX\' ).
 81 
 82       WHEN \'ZMDG_COMMIT\'.
 83         lv_enable = lv_commitoa.
 84         IF lv_read_commit = abap_true.
 85           lv_visible = 2. "Visible
 86         ELSE.
 87           lv_visible = 1. "Invisible
 88         ENDIF.
 89         IF lv_visible = 1.
 90           lv_enable = abap_false.
 91         ENDIF.
 92         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/COMMIT\' ).
 93 
 94       WHEN \'ZMDG_COMMITSP\'.
 95         lv_enable = abap_true.
 96         IF lv_dispaly_commit = abap_true.
 97           lv_visible = 2. "Visible
 98         ELSE.
 99           lv_visible = 1. "Invisible
100         ENDIF.
101         IF lv_visible = 1.
102           lv_enable = abap_false.
103         ENDIF.
104         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/SP\' ).
105 
106       WHEN \'ZMDG_COMMITSPJJ\'.
107         lv_enable = abap_true.
108         IF lv_dispaly_commit = abap_true.
109           lv_visible = 2. "Visible
110         ELSE.
111           lv_visible = 1. "Invisible
112         ENDIF.
113         IF lv_visible = 1.
114           lv_enable = abap_false.
115         ENDIF.
116         lv_txt = cl_wd_utilities=>get_otr_text_by_alias( alias = \'ZMDG01/SPJJ\' ).
117 
118       WHEN OTHERS.
119     ENDCASE.
120 
121     change_toolbar_btn(
122       id         = ls_elm-element_id
123       text       = lv_txt
124       enabled    = lv_enable
125       visibility = lv_visible
126     ).
127 
128   ENDLOOP.
129 
130 ENDMETHOD.
 1 METHOD needs_confirmation .
 2 
 3   CASE io_event->mv_event_id.
 4     WHEN \'FPM_CLOSE\'.
 5       DATA(lo_win_mngr) = wd_this->wd_get_api( )->get_window_manager( ).
 6       DATA: lt_text TYPE string_table.
 7       lt_text = VALUE #( ( `未保存的数据将会丢失,是否继续?` ) ).
 8       CALL METHOD lo_win_mngr->create_popup_to_confirm
 9         EXPORTING
10           text         = lt_text
11           button_kind  = 5    "Yes,No,Cancel
12           message_type = if_wd_message_manager=>co_type_warning
13 *         close_button = ABAP_TRUE
14 *         window_title =
15 *         window_left_position =
16 *         window_top_position  =
17 *         window_position      =
18 *         window_width =
19 *         window_height        =
20 *         default_button       =
21         RECEIVING
22           result       = DATA(lo_popup_window).
23 *      IF lO_POPUP_WINDOW NE 1.
24 *        wd_this->wd_get_api( )->cancel_navigation( ).
25 *      ENDIF.
26 
27     WHEN OTHERS.
28   ENDCASE.
29 
30 ENDMETHOD.
 1 METHOD popup_confirm .
 2 
 3   DATA(lo_win_mngr) = wd_this->wd_get_api( )->get_window_manager( ).
 4   DATA: lt_text TYPE string_table.
 5   lt_text = VALUE #( ( `未保存的数据将会丢失,是否继续?` ) ).
 6   CALL METHOD lo_win_mngr->create_popup_to_confirm
 7     EXPORTING
 8       text         = lt_text
 9       button_kind  = 4    "Yes,No
10       message_type = if_wd_message_manager=>co_type_warning
11       close_button = abap_false
12 *     window_title =
13 *     window_left_position =
14 *     window_top_position  =
15 *     window_position      =
16 *     window_width =
17 *     window_height        =
18 *     default_button       =
19     RECEIVING
20       result       = DATA(lo_popup_window).
21 
22   lo_popup_window->subscribe_to_button_event(
23     button      = if_wd_window=>co_button_yes
24 *   BUTTON_TEXT = \'\'
25 *   TOOLTIP     =
26     action_name = \'ZYES\'
27     action_view = wd_this->z_curr_view
28   ).
29 
30   lo_popup_window->subscribe_to_button_event(
31     button      = if_wd_window=>co_button_no
32 *   BUTTON_TEXT = \'\'
33 *   TOOLTIP     =
34     action_name = \'ZNO\'
35     action_view = wd_this->z_curr_view
36   ).
37 
38   lo_popup_window->open( ).
39 
40 
41 
42 
43 ENDMETHOD.
 1 METHOD process_event .
 2 
 3   CASE io_event->mv_event_id.
 4     WHEN \'FPM_SAVE\'.
 5       fire_view_action( \'SAVE_DATA\' ).
 6 
 7     WHEN \'FPM_CANCEL\'.
 8 *      fire_view_action( \'ZCX\' ).
 9       wd_this->zf_close = abap_true.
10       wd_this->mo_fpm->raise_event_by_id( \'FPM_CLOSE\' ).
11 
12     WHEN \'FPM_CLOSE\'.
13       popup_confirm( ).
14 
15     WHEN \'ZMDG_COMMIT\'.
16       fire_view_action( \'COMMITOA\' ).
17 
18     WHEN \'ZMDG_COMMITSP\'.
19       fire_view_action( \'COMMIT_APPROVE\' ).
20 
21     WHEN \'ZMDG_COMMITSPJJ\'.
22       fire_view_action( \'COMMIT_SPJJ\' ).
23 
24     WHEN OTHERS.
25   ENDCASE.
26 
27   modify_toolbar( ).
28 
29 ENDMETHOD.
 1 METHOD report_msg .
 2 
 3 *   get message manager
 4   DATA lo_api_controller     TYPE REF TO if_wd_controller.
 5   DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
 6 
 7   lo_api_controller ?= wd_This->Wd_Get_Api( ).
 8 
 9   CALL METHOD lo_api_controller->get_message_manager
10     RECEIVING
11       message_manager = lo_message_manager.
12 
13 *   report message
14   CALL METHOD lo_message_manager->report_message
15     EXPORTING
16       message_text = text
17       message_type = type.
18 
19 ENDMETHOD.
1 METHOD wddobeforenavigation .
2 
3   IF wd_this->z_inited = abap_true.
4     DATA(lo_navi_to) = wd_this->mo_fpm->get_navigate_to( ).
5     popup_confirm( ).
6   ENDIF.
7 
8 ENDMETHOD.
  1 METHOD wddoinit .
  2 
  3   DATA lo_nd_header_data TYPE REF TO if_wd_context_node.
  4   DATA lo_nd_header_data_info TYPE REF TO if_wd_context_node_info.
  5   DATA ls_header_data TYPE wd_this->element_header_data.
  6 
  7   DATA lt_value_set TYPE wdr_context_attr_value_list.
  8   DATA ls_value_set TYPE wdr_context_attr_value.
  9   lo_nd_header_data = wd_context->get_child_node( name = wd_this->wdctx_header_data ).
 10   lo_nd_header_data_info = lo_nd_header_data->get_node_info( ).
 11 * define list of raddiobuttons by changing type infos of attribute bound to property selectedKey
 12 
 13   SELECT * INTO TABLE @DATA(lt_tvtwt) FROM tvtwt WHERE spras = @sy-langu AND vtweg >= \'10\' AND vtweg <= \'50\'.
 14   LOOP AT lt_tvtwt INTO DATA(ls_tvtwt).
 15     ls_value_set-text  = ls_tvtwt-vtext.
 16     ls_value_set-value = ls_tvtwt-vtweg.
 17     APPEND ls_value_set TO lt_value_set.
 18   ENDLOOP.
 19   lo_nd_header_data_info->set_attribute_value_set( name = \'VTWEG\' value_set = lt_value_set ).
 20 
 21   REFRESH lt_value_set.
 22   SELECT * INTO TABLE @DATA(lt_t077x) FROM t077x WHERE spras = @sy-langu AND ( ktokd = \'Z001\' OR ktokd = \'Z002\') .
 23   LOOP AT lt_t077x INTO DATA(ls_t077x).
 24     ls_value_set-text  = ls_t077x-txt30.
 25     ls_value_set-value = ls_t077x-ktokd.
 26     APPEND ls_value_set TO lt_value_set.
 27   ENDLOOP.
 28   lo_nd_header_data_info->set_attribute_value_set( name = \'KTOKD\' value_set = lt_value_set ).
 29   REFRESH lt_value_set.
 30 
 31   SELECT * INTO TABLE @DATA(lt_T005T) FROM t005t WHERE spras = @sy-langu  .
 32   LOOP AT lt_T005T INTO DATA(ls_T005T).
 33     ls_value_set-text  = ls_T005T-landx.
 34     ls_value_set-value = ls_T005T-land1.
 35     APPEND ls_value_set TO lt_value_set.
 36   ENDLOOP.
 37   lo_nd_header_data_info->set_attribute_value_set( name = \'LAND1\' value_set = lt_value_set ).
 38   REFRESH lt_value_set.
 39 
 40   DATA: i_input  TYPE dd07v,o_output TYPE dd07v.
 41   i_input-domname = \'ZDCJLXS\'.
 42 
 43   i_input-domvalue_l = \'A1\'.
 44   CALL FUNCTION \'ZMDG_GET_DD07V\'
 45     EXPORTING
 46       i_input  = i_input
 47     IMPORTING
 48       o_output = o_output.
 49   ls_value_set-text  = o_output-ddtext ."\'新增客户代码\'.
 50   ls_value_set-value = \'A1\'.
 51   APPEND ls_value_set TO lt_value_set.
 52   i_input-domvalue_l = \'A2\'.
 53   CALL FUNCTION \'ZMDG_GET_DD07V\'
 54     EXPORTING
 55       i_input  = i_input
 56     IMPORTING
 57       o_output = o_output.
 58   ls_value_set-text  = o_output-ddtext ."\'客户抬头变更\'.
 59   ls_value_set-value = \'A2\'.
 60   APPEND ls_value_set TO lt_value_set.
 61   i_input-domvalue_l = \'A3\'.
 62   CALL FUNCTION \'ZMDG_GET_DD07V\'
 63     EXPORTING
 64       i_input  = i_input
 65     IMPORTING
 66       o_output = o_output.
 67   ls_value_set-text  = o_output-ddtext ."\'送达方变售达方\'.
 68   ls_value_set-value = \'A3\'.
 69   APPEND ls_value_set TO lt_value_set.
 70   i_input-domvalue_l = \'A4\'.
 71   CALL FUNCTION \'ZMDG_GET_DD07V\'
 72     EXPORTING
 73       i_input  = i_input
 74     IMPORTING
 75       o_output = o_output.
 76   ls_value_set-text  = o_output-ddtext ."\'与关联企业共用编码\'.
 77   ls_value_set-value = \'A4\'.
 78   APPEND ls_value_set TO lt_value_set.
 79 
 80   lo_nd_header_data_info->set_attribute_value_set( name = \'ZCJLX\' value_set = lt_value_set ).
 81   REFRESH lt_value_set.
 82 
 83   DATA lo_el_header_data TYPE REF TO if_wd_context_element.
 84 
 85 * navigate from <CONTEXT> to <HEADER_DATA> via lead selection
 86   lo_nd_header_data = wd_context->get_child_node( name = wd_this->wdctx_header_data ).
 87 
 88 * get element via lead selection
 89   lo_el_header_data = lo_nd_header_data->get_element( ).
 90 
 91   SELECT SINGLE bname name_text zssbm zssgs zcqb
 92    INTO (ls_header_data-bname,ls_header_data-bnametext,ls_header_data-zssbm,ls_header_data-zssgs,ls_header_data-zcqb)
 93    FROM v_username
 94   INNER JOIN ztoasapuser ON ztoasapuser~zsapuname = v_username~bname
 95   WHERE bname = sy-uname .
 96 
 97 *   set all declared attributes
 98   lo_el_header_data->set_static_attributes(
 99      static_attributes = ls_header_data ).
100 
101 
102 
103   init_toolbar( ).
104 
105 ENDMETHOD.

PFCG配置

文章来源:https://blog.csdn.net/champaignwolf/article/details/135699115
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。