如何在选择画面中创建下拉列表(drop down list)-as list box

下面介绍一下如何在选择画面中创建下拉列表字段(drop down list box),语法使用到parameter中的as list box,如下:

下拉列表创建完毕后,使用函数VRM_SET_VALUES填入下拉列表值。

例子代码如下:

REPORT ztest_dropdown_list.

PARAMETERS:p_prtmv TYPE char25 AS LISTBOX VISIBLE LENGTH 25.

INITIALIZATION.
  PERFORM frm_init.

*&---------------------------------------------------------------------*
*&      Form  FRM_INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_init .

  DATA: l_field     TYPE vrm_id,
        lit_listbox TYPE vrm_values,
        lwa_listbox LIKE LINE OF lit_listbox.


* Do not print
  lwa_listbox-key  = 'A'.
  lwa_listbox-text = 'Do not print'.
  APPEND lwa_listbox TO lit_listbox.

* Print
  lwa_listbox-key  = 'B'.
  lwa_listbox-text = 'Print'.
  APPEND lwa_listbox TO lit_listbox.

* Print and move stock
  lwa_listbox-key  = 'C'.
  lwa_listbox-text = 'Print and move stock'.
  APPEND lwa_listbox TO lit_listbox.

  l_field = 'P_PRTMV'.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = l_field
      values = lit_listbox.

ENDFORM.

运行如下:

以上。

posted @ 2019-08-30 09:46  真的是很难  阅读(502)  评论(0编辑  收藏  举报