2019.03.30 Dialog demo 一个标准使用的dialog程序
Posted jxzhu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019.03.30 Dialog demo 一个标准使用的dialog程序相关的知识,希望对你有一定的参考价值。
1 PROGRAM zdemo_dialog. 2 3 INCLUDE zdemo_dialogtop. 4 INCLUDE zdemo_dialogo01. 5 INCLUDE zdemo_dialogi01. 6 INCLUDE zdemo_dialogf01. 7 INCLUDE zdemo_dialoghelp.
*&---------------------------------------------------------------------* *& 包含 ZDEMO_DIALOGTOP *&---------------------------------------------------------------------* "屏幕元素定义 DATA: "ok_code TYPE sy-ucomm, input_one TYPE char10, input_two TYPE char10, output_three TYPE char10, cb_descri TYPE char1. DATA subinput_one TYPE char10. TABLES:t001w,t001l,makt,marc. *&SPWIZARD: FUNCTION CODES FOR TABSTRIP ‘TABSTRIP_01‘ CONSTANTS: BEGIN OF c_tabstrip_01, tab1 LIKE sy-ucomm VALUE ‘TABSTRIP_01_FC1‘, "功能代码 tab2 LIKE sy-ucomm VALUE ‘TABSTRIP_01_FC2‘, tab3 LIKE sy-ucomm VALUE ‘TABSTRIP_01_FC3‘, END OF c_tabstrip_01. *&SPWIZARD: DATA FOR TABSTRIP ‘TABSTRIP_01‘ CONTROLS: tabstrip_01 TYPE TABSTRIP. DATA: BEGIN OF g_tabstrip_01, subscreen LIKE sy-dynnr, "子屏幕 prog LIKE sy-repid VALUE ‘ZDEMO_DIALOG‘, "程序名 pressed_tab LIKE sy-ucomm VALUE c_tabstrip_01-tab1, "按下去得按钮 END OF g_tabstrip_01. DATA: ok_code LIKE sy-ucomm. *排除按钮 EXCLUDING BUTTON DATA :gt_status TYPE TABLE OF sy-ucomm, "EXCLUDING GT_STATUS gs_status TYPE sy-ucomm. " *标题 TITLE DATA gv_title TYPE c LENGTH 10. "标识 SIGN DATA gv_sign_01 TYPE c. *内表 TABLE CTRL 显示 表 TYPES:BEGIN OF ty_tab, id TYPE id, matnr TYPE mard-matnr, werks TYPE mard-werks, lgort TYPE mard-lgort, END OF ty_tab. DATA: lt_tab TYPE TABLE OF ty_tab, ls_tab TYPE ty_tab. *table control 控制表 TYPES:BEGIN OF ty_tab_crl, cbox TYPE checkbox, id TYPE id, matnr TYPE mard-matnr, werks TYPE mard-werks, lgort TYPE mard-lgort, END OF ty_tab_crl. DATA:gt_tab TYPE TABLE OF ty_tab_crl, gs_tab TYPE ty_tab_crl. *TABLE CONTROL 控制表2 DATA :gt_tab_1 TYPE TABLE OF ty_tab_crl, gs_tab_1 TYPE ty_tab_crl. *&SPWIZARD: DECLARATION OF TABLECONTROL ‘TC_CTRL‘ ITSELF CONTROLS: tc_ctrl TYPE TABLEVIEW USING SCREEN 0120. "table control 的控制器 *&SPWIZARD: LINES OF TABLECONTROL ‘TC_CTRL‘ DATA: g_tc_ctrl_lines LIKE sy-loopc."行数 *DATA: OK_CODE LIKE SY-UCOMM. *&SPWIZARD: DECLARATION OF TABLECONTROL ‘TC_CTRL_TAB‘ ITSELF CONTROLS: tc_ctrl_tab TYPE TABLEVIEW USING SCREEN 0130. *&SPWIZARD: LINES OF TABLECONTROL ‘TC_CTRL_TAB‘ DATA: g_tc_ctrl_tab_lines LIKE sy-loopc. DATA gv_field TYPE lvc_s_fcat-fieldname. DATA gv_lines TYPE i. *DATA: OK_CODE LIKE SY-UCOMM. *创建选择界面 SELECTION-SCREEN BEGIN OF SCREEN 0111 AS SUBSCREEN. SELECT-OPTIONS s_werks FOR marc-werks. SELECTION-SCREEN END OF SCREEN 0111. *&SPWIZARD: DECLARATION OF TABLECONTROL ‘TC_CTRL_TAB_1‘ ITSELF CONTROLS: tc_ctrl_tab_1 TYPE TABLEVIEW USING SCREEN 0110. *&SPWIZARD: LINES OF TABLECONTROL ‘TC_CTRL_TAB_1‘ DATA: g_tc_ctrl_tab_1_lines LIKE sy-loopc. *DATA: OK_CODE LIKE SY-UCOMM.
1 *&---------------------------------------------------------------------* 2 *& 包含 ZDEMO_DIALOGO01 3 *&---------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Module STATUS_0100 OUTPUT 6 *&---------------------------------------------------------------------* 7 *& 8 *&---------------------------------------------------------------------* 9 MODULE status_0100 OUTPUT. 10 SET PF-STATUS ‘STATUS_0100‘ EXCLUDING gt_status. 11 SET TITLEBAR ‘TITLE_0100‘ WITH gv_title. 12 ENDMODULE. 13 *&---------------------------------------------------------------------* 14 *& Module PBO_0100 OUTPUT 15 *&---------------------------------------------------------------------* 16 *& 17 *&---------------------------------------------------------------------* 18 MODULE pbo_0100 OUTPUT. 19 IF input_one IS NOT INITIAL. 20 output_three = input_one. 21 ELSE. 22 output_three = ‘NONE‘. 23 ENDIF. 24 25 IF gv_sign_01 = abap_off. 26 cb_descri = ‘X‘. 27 ENDIF. 28 29 30 IF cb_descri EQ abap_on. 31 LOOP AT SCREEN . 32 IF screen-group1 = ‘GP1‘. 33 screen-active = ‘1‘. 34 ENDIF. 35 MODIFY SCREEN. 36 ENDLOOP. 37 ELSE. 38 LOOP AT SCREEN . 39 IF screen-group1 = ‘GP1‘. 40 screen-active = ‘0‘. 41 ENDIF. 42 MODIFY SCREEN. 43 ENDLOOP. 44 ENDIF. 45 46 47 ENDMODULE. 48 49 *&SPWIZARD: OUTPUT MODULE FOR TS ‘TABSTRIP_01‘. DO NOT CHANGE THIS LINE! 50 *&SPWIZARD: SETS ACTIVE TAB 51 MODULE tabstrip_01_active_tab_set OUTPUT. 52 tabstrip_01-activetab = g_tabstrip_01-pressed_tab. 53 CASE g_tabstrip_01-pressed_tab."根据 按下得页签 来 获取 子屏幕 54 WHEN c_tabstrip_01-tab1. 55 g_tabstrip_01-subscreen = ‘0110‘. 56 gv_title = ‘-Create‘. 57 WHEN c_tabstrip_01-tab2. 58 g_tabstrip_01-subscreen = ‘0120‘. 59 gv_title = ‘-Modify‘. 60 WHEN c_tabstrip_01-tab3. 61 g_tabstrip_01-subscreen = ‘0130‘. 62 gv_title = ‘-Display‘. 63 WHEN OTHERS. 64 *&SPWIZARD: DO NOTHING 65 ENDCASE. 66 ENDMODULE. 67 *&---------------------------------------------------------------------* 68 *& Module STATUS_0110 OUTPUT 69 *&---------------------------------------------------------------------* 70 *& 71 *&---------------------------------------------------------------------* 72 MODULE status_0110 OUTPUT. 73 * SET PF-STATUS ‘xxxxxxxx‘. 74 * SET TITLEBAR ‘xxx‘. 75 subinput_one = input_two. 76 77 ENDMODULE. 78 79 *&SPWIZARD: OUTPUT MODULE FOR TC ‘TC_CTRL‘. DO NOT CHANGE THIS LINE! 80 *&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR 81 MODULE tc_ctrl_change_tc_attr OUTPUT. 82 DESCRIBE TABLE lt_tab LINES tc_ctrl-lines."获取行数 83 * DESCRIBE TABLE LT_TAB OCCURS LV_LINES."初始化大小 84 DESCRIBE TABLE lt_tab OCCURS DATA(lv_lines)."初始化大小 85 DESCRIBE TABLE lt_tab KIND DATA(lv_type)."表类型 86 87 ENDMODULE. 88 89 *&SPWIZARD: OUTPUT MODULE FOR TC ‘TC_CTRL‘. DO NOT CHANGE THIS LINE! 90 *&SPWIZARD: GET LINES OF TABLECONTROL 91 MODULE tc_ctrl_get_lines OUTPUT. 92 g_tc_ctrl_lines = sy-loopc. 93 CALL FUNCTION ‘CONVERSION_EXIT_MATN1_OUTPUT‘ 94 EXPORTING 95 input = ls_tab-matnr 96 IMPORTING 97 output = ls_tab-matnr. 98 99 * CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT‘ 100 * EXPORTING 101 * input = ls_tab-id 102 * IMPORTING 103 * output = ls_tab-id. 104 ENDMODULE. 105 *&---------------------------------------------------------------------* 106 *& Module GET_TABLE_DATA OUTPUT 107 *&---------------------------------------------------------------------* 108 *& 109 *&---------------------------------------------------------------------* 110 MODULE get_table_data OUTPUT. 111 112 IF lt_tab[] IS INITIAL. 113 SELECT matnr werks lgort FROM mard INTO CORRESPONDING FIELDS OF TABLE lt_tab 114 UP TO 50 ROWS 115 ORDER BY werks lgort. 116 LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<fs>). 117 <fs>-id = sy-tabix. 118 ENDLOOP. 119 ENDIF. 120 121 ENDMODULE. 122 123 *&SPWIZARD: OUTPUT MODULE FOR TC ‘TC_CTRL_TAB‘. DO NOT CHANGE THIS LINE! 124 *&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR 125 MODULE tc_ctrl_tab_change_tc_attr OUTPUT. 126 DESCRIBE TABLE gt_tab LINES tc_ctrl_tab-lines. 127 ENDMODULE. 128 129 *&SPWIZARD: OUTPUT MODULE FOR TC ‘TC_CTRL_TAB‘. DO NOT CHANGE THIS LINE! 130 *&SPWIZARD: GET LINES OF TABLECONTROL 131 MODULE tc_ctrl_tab_get_lines OUTPUT. 132 g_tc_ctrl_tab_lines = sy-loopc. 133 CALL FUNCTION ‘CONVERSION_EXIT_MATN1_OUTPUT‘ 134 EXPORTING 135 input = gs_tab-matnr 136 IMPORTING 137 output = gs_tab-matnr. 138 139 * CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT‘ 140 * EXPORTING 141 * input = gs_tab-id 142 * IMPORTING 143 * output = gs_tab-id. 144 ENDMODULE. 145 *&---------------------------------------------------------------------* 146 *& Module GET_TABLE_DATA_130 OUTPUT 147 *&---------------------------------------------------------------------* 148 *& 149 *&---------------------------------------------------------------------* 150 MODULE get_table_data_130 OUTPUT. 151 IF gt_tab[] IS INITIAL. 152 SELECT matnr werks lgort FROM mard INTO CORRESPONDING FIELDS OF TABLE gt_tab 153 UP TO 50 ROWS 154 ORDER BY werks lgort. 155 LOOP AT gt_tab ASSIGNING FIELD-SYMBOL(<fs1>). 156 <fs1>-id = sy-tabix. 157 ENDLOOP. 158 ENDIF. 159 ENDMODULE. 160 161 *&SPWIZARD: OUTPUT MODULE FOR TC ‘TC_CTRL_TAB_1‘. DO NOT CHANGE THIS LIN 162 *&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR 163 MODULE tc_ctrl_tab_1_change_tc_attr OUTPUT. 164 DESCRIBE TABLE gt_tab_1 LINES tc_ctrl_tab_1-lines. 165 ENDMODULE. 166 167 *&SPWIZARD: OUTPUT MODULE FOR TC ‘TC_CTRL_TAB_1‘. DO NOT CHANGE THIS LIN 168 *&SPWIZARD: GET LINES OF TABLECONTROL 169 MODULE tc_ctrl_tab_1_get_lines OUTPUT. 170 g_tc_ctrl_tab_1_lines = sy-loopc. 171 ENDMODULE. 172 *&---------------------------------------------------------------------* 173 *& Module GET_TABLE_DATA_110 OUTPUT 174 *&---------------------------------------------------------------------* 175 *& 176 *&---------------------------------------------------------------------* 177 MODULE get_table_data_110 OUTPUT. 178 IF gt_tab_1[] IS INITIAL. 179 APPEND INITIAL LINE TO gt_tab_1. 180 ENDIF. 181 ENDMODULE. 182 *&---------------------------------------------------------------------* 183 *& Module TC_CTRL_TAB_CHANGE_FIELD_ATTR OUTPUT 184 *&---------------------------------------------------------------------* 185 *& 186 *&---------------------------------------------------------------------* 187 MODULE tc_ctrl_tab_change_field_attr OUTPUT. 188 * IF gs_tab-cbox = ‘X‘. 189 * LOOP AT SCREEN."控制摸个单元格可输入 可输出 190 * IF screen-name = ‘GS_TAB-ID‘. 191 * screen-input = ‘1‘. 192 * MODIFY SCREEN. 193 * ENDIF. 194 * ENDLOOP. 195 * ENDIF. 196 "光标处回车 可编辑 197 IF tc_ctrl_tab-current_line = gv_lines + tc_ctrl_tab-top_line - 1. 198 LOOP AT SCREEN. 199 IF screen-name = gv_field. 200 screen-input = ‘1‘. 201 MODIFY SCREEN. 202 ENDIF. 203 ENDLOOP. 204 ENDIF. 205 ENDMODULE.
1 *&---------------------------------------------------------------------* 2 *& 包含 ZDEMO_DIALOGI01 3 *&---------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Module USER_COMMAND_0100 INPUT 6 *&---------------------------------------------------------------------* 7 * text 8 *----------------------------------------------------------------------* 9 MODULE user_command_0100 INPUT. 10 11 ok_code = sy-ucomm. 12 13 CASE ok_code. 14 WHEN ‘BACK‘ OR ‘CANC‘. 15 LEAVE TO SCREEN 0. 16 WHEN ‘EXIT‘. 17 LEAVE PROGRAM. 18 WHEN ‘BT_BACK‘. 19 LEAVE TO SCREEN 0. 20 * WHEN ‘BT_EXIT‘. 21 * LEAVE PROGRAM. 22 ENDCASE. 23 24 "滚轮和回车都会触发 PBO 和 PAI 所以需要在function code 使用过后清空 25 CLEAR ok_code. 26 CLEAR sy-ucomm. 27 ENDMODULE. 28 *&---------------------------------------------------------------------* 29 *& Module EXIT_COMMAND INPUT 30 *&---------------------------------------------------------------------* 31 * text 32 *----------------------------------------------------------------------* 33 MODULE exit_command INPUT. 34 ok_code = sy-ucomm. 35 CASE ok_code. 36 * WHEN ‘BACK‘ OR ‘CANC‘. 37 * LEAVE TO SCREEN 0. 38 * WHEN ‘EXIT‘. 39 * LEAVE PROGRAM. 40 * WHEN ‘BT_BACK‘. 41 * LEAVE TO SCREEN 0. 42 WHEN ‘BT_EXIT‘. 43 LEAVE PROGRAM. 44 ENDCASE. 45 46 CLEAR ok_code. 47 CLEAR sy-ucomm. 48 ENDMODULE. 49 *&---------------------------------------------------------------------* 50 *& Module CHECK_PLANT INPUT 51 *&---------------------------------------------------------------------* 52 * text 53 *----------------------------------------------------------------------* 54 MODULE check_plant INPUT. 55 56 SELECT SINGLE name1 INTO t001w-name1 FROM t001w 57 WHERE werks = t001w-werks. 58 IF sy-subrc NE 0. 59 CLEAR :t001w-werks,t001w-name1. 60 ENDIF. 61 62 63 ENDMODULE. 64 *&---------------------------------------------------------------------* 65 *& Module CHECK_WAREHOUSE INPUT 66 *&---------------------------------------------------------------------* 67 * text 68 *----------------------------------------------------------------------* 69 MODULE check_warehouse INPUT. 70 71 IF t001w-werks IS NOT INITIAL. 72 SELECT SINGLE lgobe INTO t001l-lgobe FROM t001l 73 WHERE werks = t001w-werks AND lgort = t001l-lgort. 74 IF sy-subrc NE 0. 75 CLEAR: t001l-lgort,t001l-lgobe. 76 ENDIF. 77 ELSE. 78 CLEAR: t001l-lgort,t001l-lgobe. 79 ENDIF. 80 ENDMODULE. 81 *&---------------------------------------------------------------------* 82 *& Module CHECK_MATERIAL INPUT 83 *&---------------------------------------------------------------------* 84 * text 85 *----------------------------------------------------------------------* 86 MODULE check_material INPUT. 87 IF t001w-werks IS NOT INITIAL 88 AND t001l-lgort IS NOT INITIAL. 89 SELECT SINGLE maktx INTO makt-maktx FROM makt 90 WHERE matnr = makt-matnr AND spras = sy-langu. 91 ELSE. 92 CLEAR:makt-matnr,makt-maktx. 93 ENDIF. 94 ENDMODULE. 95 96 *&SPWIZARD: INPUT MODULE FOR TS ‘TABSTRIP_01‘. DO NOT CHANGE THIS LINE! 97 *&SPWIZARD: GETS ACTIVE TAB 98 MODULE tabstrip_01_active_tab_get INPUT. 99 ok_code = sy-ucomm. 100 CASE ok_code. 101 WHEN c_tabstrip_01-tab1. 102 g_tabstrip_01-pressed_tab = c_tabstrip_01-tab1. 103 REFRESH gt_status. 104 * gs_status = ‘SAVE‘."隐藏按钮 105 * APPEND gs_status TO gt_status. 106 * CLEAR gs_status. 107 WHEN c_tabstrip_01-tab2. 108 g_tabstrip_01-pressed_tab = c_tabstrip_01-tab2. 109 REFRESH gt_status. 110 WHEN c_tabstrip_01-tab3. 111 g_tabstrip_01-pressed_tab = c_tabstrip_01-tab3. 112 REFRESH gt_status. 113 gs_status = ‘SAVE‘."隐藏按钮 114 APPEND gs_status TO gt_status. 115 CLEAR gs_status. 116 WHEN OTHERS. 117 *&SPWIZARD: DO NOTHING 118 ENDCASE. 119 ENDMODULE. 120 *&---------------------------------------------------------------------* 121 *& Module SET_SIGNAL INPUT 122 *&---------------------------------------------------------------------* 123 * text 124 *----------------------------------------------------------------------* 125 MODULE set_signal INPUT. 126 gv_sign_01 = ‘X‘. 127 ENDMODULE. 128 *&---------------------------------------------------------------------* 129 *& Module USER_COMMAND_0110 INPUT 130 *&---------------------------------------------------------------------* 131 * text 132 *----------------------------------------------------------------------* 133 MODULE user_command_0110 INPUT. 134 135 ok_code = sy-ucomm. 136 137 CASE ok_code. 138 WHEN ‘SUBCK‘. 139 IF subinput_one = input_one. 140 MESSAGE ‘Data is right‘ TYPE ‘I‘ DISPLAY LIKE ‘S‘. 141 g_tabstrip_01-pressed_tab = c_tabstrip_01-tab2. 142 REFRESH gt_status. 143 ELSE. 144 MESSAGE ‘No match‘ TYPE ‘I‘ DISPLAY LIKE ‘E‘. 145 RETURN. 146 ENDIF. 147 ENDCASE. 148 149 150 ENDMODULE. 151 152 *&SPWIZARD: INPUT MODULE FOR TC ‘TC_CTRL‘. DO NOT CHANGE THIS LINE! 153 *&SPWIZARD: PROCESS USER COMMAND 154 MODULE tc_ctrl_user_command INPUT. 155 ok_code = sy-ucomm. 156 PERFORM user_ok_tc USING ‘TC_CTRL‘ 157 ‘LT_TAB‘ 158 ‘ ‘ 159 CHANGING ok_code. 160 sy-ucomm = ok_code. 161 ENDMODULE. 162 163 *&SPWIZARD: INPUT MODULE FOR TC ‘TC_CTRL_TAB‘. DO NOT CHANGE THIS LINE! 164 *&SPWIZARD: MODIFY TABLE 165 MODULE tc_ctrl_tab_modify INPUT. 166 MODIFY gt_tab 167 FROM gs_tab 168 INDEX tc_ctrl_tab-current_line."只能修改不能新增 169 ENDMODULE. 170 171 *&SPWIZARD: INPUT MODUL FOR TC ‘TC_CTRL_TAB‘. DO NOT CHANGE THIS LINE! 172 *&SPWIZARD: MARK TABLE 173 MODULE tc_ctrl_tab_mark INPUT. 174 DATA: g_tc_ctrl_tab_wa2 LIKE LINE OF gt_tab. 175 IF tc_ctrl_tab-line_sel_mode = 1 176 AND gs_tab-cbox = ‘X‘. 177 LOOP AT gt_tab INTO g_tc_ctrl_tab_wa2 178 WHERE cbox = ‘X‘. 179 g_tc_ctrl_tab_wa2-cbox = ‘‘. 180 MODIFY gt_tab 181 FROM g_tc_ctrl_tab_wa2 182 TRANSPORTING cbox. 183 ENDLOOP. 184 ENDIF. 185 MODIFY gt_tab 186 FROM gs_tab 187 INDEX tc_ctrl_tab-current_line 188 TRANSPORTING cbox."修改选中的行 189 ENDMODULE. 190 191 *&SPWIZARD: INPUT MODULE FOR TC ‘TC_CTRL_TAB‘. DO NOT CHANGE THIS LINE! 192 *&SPWIZARD: PROCESS USER COMMAND 193 MODULE tc_ctrl_tab_user_command INPUT. 194 ok_code = sy-ucomm. 195 PERFORM user_ok_tc USING ‘TC_CTRL_TAB‘ 196 ‘GT_TAB‘ 197 ‘CBOX‘ 198 CHANGING ok_code. 199 sy-ucomm = ok_code. 200 ENDMODULE. 201 202 *&SPWIZARD: INPUT MODULE FOR TC ‘TC_CTRL_TAB_1‘. DO NOT CHANGE THIS LINE 203 *&SPWIZARD: MODIFY TABLE 204 MODULE tc_ctrl_tab_1_modify INPUT. 205 MODIFY gt_tab_1 206 FROM gs_tab_1 207 INDEX tc_ctrl_tab_1-current_line. 208 ENDMODULE. 209 210 *&SPWIZARD: INPUT MODUL FOR TC ‘TC_CTRL_TAB_1‘. DO NOT CHANGE THIS LINE! 211 *&SPWIZARD: MARK TABLE 212 MODULE tc_ctrl_tab_1_mark INPUT. 213 DATA: g_tc_ctrl_tab_1_wa2 LIKE LINE OF gt_tab_1. 214 IF tc_ctrl_tab_1-line_sel_mode = 1 215 AND gs_tab_1-cbox = ‘X‘. 216 LOOP AT gt_tab_1 INTO g_tc_ctrl_tab_1_wa2 217 WHERE cbox = ‘X‘. 218 g_tc_ctrl_tab_1_wa2-cbox = ‘‘. 219 MODIFY gt_tab_1 220 FROM g_tc_ctrl_tab_1_wa2 221 TRANSPORTING cbox. 222 ENDLOOP. 223 ENDIF. 224 MODIFY gt_tab_1 225 FROM gs_tab_1 226 INDEX tc_ctrl_tab_1-current_line 227 TRANSPORTING cbox. 228 ENDMODULE. 229 230 *&SPWIZARD: INPUT MODULE FOR TC ‘TC_CTRL_TAB_1‘. DO NOT CHANGE THIS LINE 231 *&SPWIZARD: PROCESS USER COMMAND 232 MODULE tc_ctrl_tab_1_user_command INPUT. 233 ok_code = sy-ucomm. 234 PERFORM user_ok_tc USING ‘TC_CTRL_TAB_1‘ 235 ‘GT_TAB_1‘ 236 ‘CBOX‘ 237 CHANGING ok_code. 238 sy-ucomm = ok_code. 239 ENDMODULE. 240 *&---------------------------------------------------------------------* 241 *& Module USER_COMMAND_0130 INPUT 242 *&---------------------------------------------------------------------* 243 * text 244 *----------------------------------------------------------------------* 245 MODULE user_command_0130 INPUT. 246 ok_code = sy-ucomm. 247 248 CASE ok_code. 249 WHEN ‘ID_BT‘."modify table control lines 250 PERFORM frm_modify_lines. 251 WHEN OTHERS. 252 ENDCASE. 253 254 CLEAR ok_code. 255 CLEAR sy-ucomm. 256 ENDMODULE. 257 *&---------------------------------------------------------------------* 258 *& Module GET_CURSOR INPUT 259 *&---------------------------------------------------------------------* 260 * text 261 *----------------------------------------------------------------------* 262 MODULE get_cursor INPUT. 263 GET CURSOR FIELD gv_field LINE gv_lines. 264 ENDMODULE.
1 *&---------------------------------------------------------------------* 2 *& 包含 ZDEMO_DIALOGF01 3 *&---------------------------------------------------------------------* 4 5 *----------------------------------------------------------------------* 6 * INCLUDE TABLECONTROL_FORMS * 7 *----------------------------------------------------------------------* 8 9 *&---------------------------------------------------------------------* 10 *& Form USER_OK_TC 11 *& 标准FORM 标准按钮 引导自动创建 * 12 *&---------------------------------------------------------------------* 13 *&---------------------------------------------------------------------* 14 FORM user_ok_tc USING p_tc_name TYPE dynfnam 15 p_table_name 16 p_mark_name 17 CHANGING p_ok LIKE sy-ucomm. 18 19 *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 20 DATA: l_ok TYPE sy-ucomm, 21 l_offset TYPE i. 22 *&SPWIZARD: END OF LOCAL DATA------------------------------------------* 23 24 *&SPWIZARD: Table control specific operations * 25 *&SPWIZARD: evaluate TC name and operations * 26 SEARCH p_ok FOR p_tc_name. 27 IF sy-subrc <> 0. 28 EXIT. 29 ENDIF. 30 l_offset = strlen( p_tc_name ) + 1. 31 l_ok = p_ok+l_offset. 32 *&SPWIZARD: execute general and TC specific operations * 33 CASE l_ok. 34 WHEN ‘INSR‘. "insert row 35 PERFORM fcode_insert_row USING p_tc_name 36 p_table_name. 37 CLEAR p_ok. 38 39 WHEN ‘DELE‘. "delete row 40 PERFORM fcode_delete_row USING p_tc_name 41 p_table_name 42 p_mark_name. 43 CLEAR p_ok. 44 45 WHEN ‘P--‘ OR "top of list 46 ‘P-‘ OR "previous page 47 ‘P+‘ OR "next page 48 ‘P++‘. "bottom of list 49 PERFORM compute_scrolling_in_tc USING p_tc_name 50 l_ok. 51 CLEAR p_ok. 52 * WHEN ‘L--‘. "total left 53 * PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME. 54 * 55 * WHEN ‘L-‘. "column left 56 * PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME. 57 * 58 * WHEN ‘R+‘. "column right 59 * PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME. 60 * 61 * WHEN ‘R++‘. "total right 62 * PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME. 63 * 64 WHEN ‘MARK‘. "mark all filled lines 65 PERFORM fcode_tc_mark_lines USING p_tc_name 66 p_table_name 67 p_mark_name . 68 CLEAR p_ok. 69 70 WHEN ‘DMRK‘. "demark all filled lines 71 PERFORM fcode_tc_demark_lines USING p_tc_name 72 p_table_name 73 p_mark_name . 74 CLEAR p_ok. 75 76 * WHEN ‘SASCEND‘ OR 77 * ‘SDESCEND‘. "sort column 78 * PERFORM FCODE_SORT_TC USING P_TC_NAME 79 * l_ok. 80 81 ENDCASE. 82 83 ENDFORM. " USER_OK_TC 84 85 *&---------------------------------------------------------------------* 86 *& Form FCODE_INSERT_ROW * 87 *&---------------------------------------------------------------------* 88 FORM fcode_insert_row 89 USING p_tc_name TYPE dynfnam 90 p_table_name . 91 92 *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 93 DATA l_lines_name LIKE feld-name. 94 DATA l_selline LIKE sy-stepl. 95 DATA l_lastline TYPE i. 96 DATA l_line TYPE i. 97 DATA l_table_name LIKE feld-name. 98 FIELD-SYMBOLS <tc> TYPE cxtab_control. 99 FIELD-SYMBOLS <table> TYPE STANDARD TABLE. 100 FIELD-SYMBOLS <lines> TYPE i. 101 *&SPWIZARD: END OF LOCAL DATA------------------------------------------* 102 103 ASSIGN (p_tc_name) TO <tc>. 104 105 *&SPWIZARD: get the table, which belongs to the tc * 106 CONCATENATE p_table_name ‘[]‘ INTO l_table_name. "table body 107 ASSIGN (l_table_name) TO <table>. "not headerline 108 109 *&SPWIZARD: get looplines of TableControl * 110 CONCATENATE ‘G_‘ p_tc_name ‘_LINES‘ INTO l_lines_name. 111 ASSIGN (l_lines_name) TO <lines>. 112 113 *&SPWIZARD: get current line * 114 GET CURSOR LINE l_selline. 115 IF sy-subrc <> 0. " append line to table 116 l_selline = <tc>-lines + 1. 117 *&SPWIZARD: set top line * 118 IF l_selline > <lines>. 119 <tc>-top_line = l_selline - <lines> + 1 . 120 ELSE. 121 <tc>-top_line = 1. 122 ENDIF. 123 ELSE. " insert line into table 124 l_selline = <tc>-top_line + l_selline - 1. 125 l_lastline = <tc>-top_line + <lines> - 1. 126 ENDIF. 127 *&SPWIZARD: set new cursor line * 128 l_line = l_selline - <tc>-top_line + 1. 129 130 *&SPWIZARD: insert initial line * 131 INSERT INITIAL LINE INTO <table> INDEX l_selline. 132 <tc>-lines = <tc>-lines + 1. 133 *&SPWIZARD: set cursor * 134 SET CURSOR LINE l_line. 135 136 ENDFORM. " FCODE_INSERT_ROW 137 138 *&---------------------------------------------------------------------* 139 *& Form FCODE_DELETE_ROW * 140 *&---------------------------------------------------------------------* 141 FORM fcode_delete_row 142 USING p_tc_name TYPE dynfnam 143 p_table_name 144 p_mark_name . 145 146 *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 147 DATA l_table_name LIKE feld-name. 148 149 FIELD-SYMBOLS <tc> TYPE cxtab_control. 150 FIELD-SYMBOLS <table> TYPE STANDARD TABLE. 151 FIELD-SYMBOLS <wa>. 152 FIELD-SYMBOLS <mark_field>. 153 *&SPWIZARD: END OF LOCAL DATA------------------------------------------* 154 155 ASSIGN (p_tc_name) TO <tc>. 156 157 *&SPWIZARD: get the table, which belongs to the tc * 158 CONCATENATE p_table_name ‘[]‘ INTO l_table_name. "table body 159 ASSIGN (l_table_name) TO <table>. "not headerline 160 161 *&SPWIZARD: delete marked lines * 162 DESCRIBE TABLE <table> LINES <tc>-lines. 163 164 LOOP AT <table> ASSIGNING <wa>. 165 166 *&SPWIZARD: access to the component ‘FLAG‘ of the table header * 167 ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>. 168 169 IF <mark_field> = ‘X‘. 170 DELETE <table> INDEX syst-tabix. 171 IF sy-subrc = 0. 172 <tc>-lines = <tc>-lines - 1. 173 ENDIF. 174 ENDIF. 175 ENDLOOP. 176 177 ENDFORM. " FCODE_DELETE_ROW 178 179 *&---------------------------------------------------------------------* 180 *& Form COMPUTE_SCROLLING_IN_TC 181 *&---------------------------------------------------------------------* 182 * text 183 *----------------------------------------------------------------------* 184 * -->P_TC_NAME name of tablecontrol 185 * -->P_OK ok code 186 *----------------------------------------------------------------------* 187 FORM compute_scrolling_in_tc USING p_tc_name 188 p_ok. 189 *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 190 DATA l_tc_new_top_line TYPE i. 191 DATA l_tc_name LIKE feld-name. 192 DATA l_tc_lines_name LIKE feld-name. 193 DATA l_tc_field_name LIKE feld-name. 194 195 FIELD-SYMBOLS <tc> TYPE cxtab_control. 196 FIELD-SYMBOLS <lines> TYPE i. 197 *&SPWIZARD: END OF LOCAL DATA------------------------------------------* 198 199 ASSIGN (p_tc_name) TO <tc>. 200 *&SPWIZARD: get looplines of TableControl * 201 CONCATENATE ‘G_‘ p_tc_name ‘_LINES‘ INTO l_tc_lines_name. 202 ASSIGN (l_tc_lines_name) TO <lines>. 203 204 205 *&SPWIZARD: is no line filled? * 206 IF <tc>-lines = 0. 207 *&SPWIZARD: yes, ... * 208 l_tc_new_top_line = 1. 209 ELSE. 210 *&SPWIZARD: no, ... * 211 CALL FUNCTION ‘SCROLLING_IN_TABLE‘ 212 EXPORTING 213 entry_act = <tc>-top_line 214 entry_from = 1 215 entry_to = <tc>-lines 216 last_page_full = ‘X‘ 217 loops = <lines> 218 ok_code = p_ok 219 overlapping = ‘X‘ 220 IMPORTING 221 entry_new = l_tc_new_top_line 222 EXCEPTIONS 223 * NO_ENTRY_OR_PAGE_ACT = 01 224 * NO_ENTRY_TO = 02 225 * NO_OK_CODE_OR_PAGE_GO = 03 226 OTHERS = 0. 227 ENDIF. 228 229 *&SPWIZARD: get actual tc and column * 230 GET CURSOR FIELD l_tc_field_name 231 AREA l_tc_name. 232 233 IF syst-subrc = 0. 234 IF l_tc_name = p_tc_name. 235 *&SPWIZARD: et actual column * 236 SET CURSOR FIELD l_tc_field_name LINE 1. 237 ENDIF. 238 ENDIF. 239 240 *&SPWIZARD: set the new top line * 241 <tc>-top_line = l_tc_new_top_line. 242 243 244 ENDFORM. " COMPUTE_SCROLLING_IN_TC 245 246 *&---------------------------------------------------------------------* 247 *& Form FCODE_TC_MARK_LINES 248 *&---------------------------------------------------------------------* 249 * marks all TableControl lines 250 *----------------------------------------------------------------------* 251 * -->P_TC_NAME name of tablecontrol 252 *----------------------------------------------------------------------* 253 FORM fcode_tc_mark_lines USING p_tc_name 254 p_table_name 255 p_mark_name. 256 *&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------* 257 DATA l_table_name LIKE feld-name. 258 259 FIELD-SYMBOLS <tc> TYPE cxtab_control. 260 FIELD-SYMBOLS <table> TYPE STANDARD TABLE. 261 FIELD-SYMBOLS <wa>. 262 FIELD-SYMBOLS <mark_field>. 263 *&SPWIZARD: END OF LOCAL DATA------------------------------------------* 264 265 ASSIGN (p_tc_name) TO <tc>. 266 267 *&SPWIZARD: get the table, which belongs to the tc * 268 CONCATENATE p_table_name ‘[]‘ INTO l_table_name. "table body 269 ASSIGN (l_table_name) TO <table>. "not headerline 270 271 *&SPWIZARD: mark all filled lines * 272 LOOP AT <table> ASSIGNING <wa>. 273 274 *&SPWIZARD: access to the component ‘FLAG‘ of the table header * 275 ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>. 276 277 <mark_field> = ‘X‘. 278 ENDLOOP. 279 ENDFORM. "fcode_tc_mark_lines 280 281 *&---------------------------------------------------------------------* 282 *& Form FCODE_TC_DEMARK_LINES 283 *&---------------------------------------------------------------------* 284 * demarks all TableControl lines 285 *----------------------------------------------------------------------* 286 * -->P_TC_NAME name of tablecontrol 287 *----------------------------------------------------------------------* 288 FORM fcode_tc_demark_lines USING p_tc_name 289 p_table_name 290 p_mark_name . 291 *&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 292 DATA l_table_name LIKE feld-name. 293 294 FIELD-SYMBOLS <tc> TYPE cxtab_control. 295 FIELD-SYMBOLS <table> TYPE STANDARD TABLE. 296 FIELD-SYMBOLS <wa>. 297 FIELD-SYMBOLS <mark_field>. 298 *&SPWIZARD: END OF LOCAL DATA------------------------------------------* 299 300 ASSIGN (p_tc_name) TO <tc>. 301 302 *&SPWIZARD: get the table, which belongs to the tc * 303 CONCATENATE p_table_name ‘[]‘ INTO l_table_name. "table body 304 ASSIGN (l_table_name) TO <table>. "not headerline 305 306 *&SPWIZARD: demark all filled lines * 307 LOOP AT <table> ASSIGNING <wa>. 308 309 *&SPWIZARD: access to the component ‘FLAG‘ of the table header * 310 ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>. 311 312 <mark_field> = space. 313 ENDLOOP. 314 ENDFORM. "fcode_tc_mark_lines 315 *&---------------------------------------------------------------------* 316 *& Form FRM_MODIFY_LINES 317 *&---------------------------------------------------------------------* 318 *& text 319 *&---------------------------------------------------------------------* 320 *& --> p1 text 321 *& <-- p2 text 322 *&---------------------------------------------------------------------* 323 FORM frm_modify_lines . 324 DATA ls_cols LIKE LINE OF tc_ctrl_tab-cols. 325 326 LOOP AT tc_ctrl_tab-cols INTO ls_cols. 327 IF ls_cols-index = ‘1‘. 328 IF ls_cols-screen-input = ‘0‘. 329 ls_cols-screen-input = ‘1‘. 330 ELSE. 331 ls_cols-screen-input = ‘0‘. 332 ENDIF. 333 MODIFY tc_ctrl_tab-cols FROM ls_cols. 334 ENDIF. 335 ENDLOOP . 336 ENDFORM.
1 *----------------------------------------------------------------------* 2 ***INCLUDE ZDEMO_DIALOGHELP. 3 *----------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Module F4_HELP_WAREHOUSE INPUT 6 *&---------------------------------------------------------------------* 7 * text 8 *----------------------------------------------------------------------* 9 MODULE f4_help_warehouse INPUT. 10 TYPES:BEGIN OF lty_lgort, 11 werks TYPE t001l-werks, 12 lgort TYPE t001l-lgort, 13 lgobe TYPE t001l-lgobe, 14 END OF lty_lgort. 15 16 DATA:lt_lgort TYPE TABLE OF lty_lgort. 17 18 IF t001w-werks IS NOT INITIAL. 19 SELECT werks lgort lgobe INTO TABLE lt_lgort FROM t001l WHERE werks = t001w-werks. 20 21 CHECK sy-subrc EQ 0. 22 CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST‘ 23 EXPORTING 24 * DDIC_STRUCTURE = ‘ ‘ 25 retfield = ‘LGORT‘ 26 * PVALKEY = ‘ ‘ 27 dynpprog = sy-cprog 28 dynpnr = sy-dynnr 29 dynprofield = ‘T001L-LGORT‘ 30 * STEPL = 0 31 window_title = ‘WAREHOUSE SELECTION‘ 32 * VALUE = ‘ ‘ 33 value_org = ‘S‘ 34 * MULTIPLE_CHOICE = ‘ ‘ 35 * DISPLAY = ‘ ‘ 36 * CALLBACK_PROGRAM = ‘ ‘ 37 * CALLBACK_FORM = ‘ ‘ 38 * CALLBACK_METHOD = 39 * MARK_TAB = 40 * IMPORTING 41 * USER_RESET = 42 TABLES 43 value_tab = lt_lgort 44 * FIELD_TAB = 45 * RETURN_TAB = 46 * DYNPFLD_MAPPING = 47 * EXCEPTIONS 48 * PARAMETER_ERROR = 1 49 * NO_VALUES_FOUND = 2 50 * OTHERS = 3 51 . 52 IF sy-subrc <> 0. 53 * Implement suitable error handling here 54 ENDIF. 55 56 ELSE. 57 CALL FUNCTION ‘F4IF_FIELD_VALUE_REQUEST‘ 58 EXPORTING 59 tabname = ‘T001L‘ 60 fieldname = ‘LGORT‘ 61 * SEARCHHELP = ‘ ‘ 62 * SHLPPARAM = ‘ ‘ 63 dynpprog = sy-repid 64 dynpnr = sy-dynnr 65 dynprofield = ‘T001L-LGORT‘ 66 * STEPL = 0 67 * VALUE = ‘ ‘ 68 * MULTIPLE_CHOICE = ‘ ‘ 69 * DISPLAY = ‘ ‘ 70 * SUPPRESS_RECORDLIST = ‘ ‘ 71 * CALLBACK_PROGRAM = ‘ ‘ 72 * CALLBACK_FORM = ‘ ‘ 73 * CALLBACK_METHOD = 74 * SELECTION_SCREEN = ‘ ‘ 75 * IMPORTING 76 * USER_RESET = 77 * TABLES 78 * RETURN_TAB = 79 * EXCEPTIONS 80 * FIELD_NOT_FOUND = 1 81 * NO_HELP_FOR_FIELD = 2 82 * INCONSISTENT_HELP = 3 83 * NO_VALUES_FOUND = 4 84 * OTHERS = 5 85 . 86 IF sy-subrc <> 0. 87 * Implement suitable error handling here 88 ENDIF. 89 90 91 ENDIF. 92 ENDMODULE. 93 *&---------------------------------------------------------------------* 94 *& Module F4_HELP_MATERIAL INPUT 95 *&---------------------------------------------------------------------* 96 * text 97 *----------------------------------------------------------------------* 98 MODULE f4_help_material INPUT. 99 TYPES:BEGIN OF lty_matnr, 100 werks TYPE mard-werks, 101 lgort TYPE mard-lgort, 102 matnr TYPE mard-matnr, 103 maktx TYPE makt-maktx, 104 END OF lty_matnr. 105 106 DATA:lt_matnr TYPE TABLE OF lty_matnr. 107 108 IF t001w-werks IS NOT INITIAL 109 AND t001l-lgort IS NOT INITIAL. 110 SELECT a~werks a~lgort a~matnr b~maktx 111 INTO TABLE lt_matnr 112 FROM mard AS a 113 INNER JOIN makt AS b ON b~matnr = a~matnr AND b~spras = sy-langu 114 WHERE a~werks = t001w-werks 115 AND a~lgort = t001l-lgort. 116 117 CHECK sy-subrc EQ 0. 118 CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST‘ 119 EXPORTING 120 * DDIC_STRUCTURE = ‘ ‘ 121 retfield = ‘MATNR‘ 122 * PVALKEY = ‘ ‘ 123 dynpprog = sy-cprog 124 dynpnr = sy-dynnr 125 dynprofield = ‘MAKT-MATNR‘ 126 * STEPL = 0 127 window_title = ‘MATERIAL SELECTION‘ 128 * VALUE = ‘ ‘ 129 value_org = ‘S‘ 130 * MULTIPLE_CHOICE = ‘ ‘ 131 * DISPLAY = ‘ ‘ 132 * CALLBACK_PROGRAM = ‘ ‘ 133 * CALLBACK_FORM = ‘ ‘ 134 * CALLBACK_METHOD = 135 * MARK_TAB = 136 * IMPORTING 137 * USER_RESET = 138 TABLES 139 value_tab = lt_matnr 140 * FIELD_TAB = 141 * RETURN_TAB = 142 * DYNPFLD_MAPPING = 143 * EXCEPTIONS 144 * PARAMETER_ERROR = 1 145 * NO_VALUES_FOUND = 2 146 * OTHERS = 3 147 . 148 IF sy-subrc <> 0. 149 * Implement suitable error handling here 150 ENDIF. 151 152 ELSE. 153 CALL FUNCTION ‘F4IF_FIELD_VALUE_REQUEST‘ 154 EXPORTING 155 tabname = ‘MAKT‘ 156 fieldname = ‘MATNR‘ 157 * SEARCHHELP = ‘ ‘ 158 * SHLPPARAM = ‘ ‘ 159 dynpprog = sy-repid 160 dynpnr = sy-dynnr 161 dynprofield = ‘MAKT-MATNR‘ 162 * STEPL = 0 163 * VALUE = ‘ ‘ 164 * MULTIPLE_CHOICE = ‘ ‘ 165 * DISPLAY = ‘ ‘ 166 * SUPPRESS_RECORDLIST = ‘ ‘ 167 * CALLBACK_PROGRAM = ‘ ‘ 168 * CALLBACK_FORM = ‘ ‘ 169 * CALLBACK_METHOD = 170 * SELECTION_SCREEN = ‘ ‘ 171 * IMPORTING 172 * USER_RESET = 173 * TABLES 174 * RETURN_TAB = 175 * EXCEPTIONS 176 * FIELD_NOT_FOUND = 1 177 * NO_HELP_FOR_FIELD = 2 178 * INCONSISTENT_HELP = 3 179 * NO_VALUES_FOUND = 4 180 * OTHERS = 5 181 . 182 IF sy-subrc <> 0. 183 * Implement suitable error handling here 184 ENDIF. 185 186 187 ENDIF. 188 ENDMODULE.
DEMO 得效果图如下,屏幕就自己画下哈, TABLE Control he tablstrip 都是用引导功能画得
以上是关于2019.03.30 Dialog demo 一个标准使用的dialog程序的主要内容,如果未能解决你的问题,请参考以下文章
去除 android中EditText的下划线 fragment 切换调用的方法 Activity获取Fragment参数 绘制圆角矩形 普通dialog demo 使用 AlertDi