点击选择画面中的SELECT-OPTIONS的multiple selection按钮,会看到4个条件tab页,分别是select single values,select ranges,exclude single values,exclude ranges,如下:
这些selection条件的tab页可以通过函数SELECT_OPTIONS_RESTRICT进行控制,
例子代码如下,下面代码中,只保留了第一个tab页-select single values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
REPORT ztest_del_multi. DATA:g_werks TYPE vbap-werks. SELECT-OPTIONS:s_werks FOR g_werks. *&---------------------------------------------------------------------* *& INITIALIZATION *&---------------------------------------------------------------------* INITIALIZATION. PERFORM frm_exclude_option. *&---------------------------------------------------------------------* *& Form FRM_EXCLUDE_OPTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_exclude_option . CONSTANTS: co_s TYPE char1 VALUE 'S', "Single co_key TYPE rsrest_opl VALUE 'OBJECTKEY1', "Key co_i TYPE char1 VALUE 'I', "Include co_werks TYPE char7 VALUE 'S_WERKS', "Selection name co_eq TYPE char2 VALUE 'EQ'. "Equal to DATA: "SELECT_OPTIONS_RESTRICT (to be extended) lwa_restrict TYPE sscr_restrict, " One list of options lwa_optlist TYPE sscr_opt_list, "One line of table associating selection screen object with opt lwa_ass TYPE sscr_ass. * Restricting the MATNR selection to only EQ . lwa_optlist-name = co_key. lwa_optlist-options-eq = abap_true. APPEND lwa_optlist TO lwa_restrict-opt_list_tab. lwa_ass-kind = co_s. lwa_ass-name = co_werks. lwa_ass-sg_main = co_i. lwa_ass-sg_addy = space. lwa_ass-op_main = co_key. APPEND lwa_ass TO lwa_restrict-ass_tab. CALL FUNCTION 'SELECT_OPTIONS_RESTRICT' EXPORTING restriction = lwa_restrict EXCEPTIONS too_late = 1 repeated = 2 selopt_without_options = 3 selopt_without_signs = 4 invalid_sign = 5 empty_option_list = 6 invalid_kind = 7 repeated_kind_a = 8 OTHERS = 9. ENDFORM. |
效果如下:
以上。
发表评论