SAP 选择屏幕隐藏selection options

2023-10-13 16:59:58 浏览数 (1)

在选择屏幕定义的时候,我们经常会运用NO INTERVALS,将字段改成单值,但是后面的选择框中还有多值输入。

具体的实现方式,是通过函数SELECT_OPTIONS_RESTRICT进行控制,具体代码如下:

代码语言:javascript复制
*定义选择屏幕
SELECT-OPTIONS : s_matnr FOR marc-matnr NO INTERVALS,
                 s_werks FOR marc-werks.

INITIALIZATION.
* 限制MATNR参数只能使用‘EQ’ 和‘BT’.
  optlist-name = 'OBJECTKEY1'.
  optlist-options-eq = 'X'.
*  optlist-options-bt = 'X'.
  APPEND optlist TO restrict-opt_list_tab.

  ass-kind = 'S'.
  ass-name = 'S_MATNR'.
  ass-sg_main = 'I'.
  ass-sg_addy = space.
  ass-op_main = 'OBJECTKEY1'.
  APPEND ass TO restrict-ass_tab.

* 限制 WERKS 参数只能使用CP, GE, LT, NE.
  optlist-name = 'OBJECTKEY2'.
  optlist-options-cp = 'X'.
  optlist-options-bt = 'X'.
  optlist-options-ge = 'X'.
  optlist-options-lt = 'X'.
  optlist-options-ne = 'X'.
  APPEND optlist TO restrict-opt_list_tab.

  ass-kind = 'S'.
  ass-name = 'S_WERKS'.
  ass-sg_main = 'I'.
  ass-sg_addy = space.
  ass-op_main = 'OBJECTKEY2'.
  APPEND ass TO restrict-ass_tab.

  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      restriction            = 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.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

0 人点赞