How to set values in the listbox?

◇◆丶佛笑我妖孽 提交于 2020-01-03 19:34:32

问题


I have defined a list box in my selection screen, as follows:

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE ALTITLE1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (30) ALCONT4 FOR FIELD L1.
PARAMETERS: L1 AS LISTBOX VISIBLE LENGTH 20 MODIF ID AOD.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.

Now I need to propose possible values for that list box, how can I do it ?


回答1:


During the PBO of your screen (for selection screens, the PBO code is defined inside the event block AT SELECTION-SCREEN OUTPUT), you must call the function module VRM_SET_VALUES, passing the name of the field and a list of values.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE altitle1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (30) alcont4 FOR FIELD l1.
PARAMETERS: l1 AS LISTBOX VISIBLE LENGTH 20 MODIF ID aod.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

INITIALIZATION.
  alcont4 = 'Choose the country'(001).

AT SELECTION-SCREEN OUTPUT.
  DATA: lt_value TYPE vrm_values,
        ls_value TYPE vrm_value.
  ls_value-key = 'FRA'.
  ls_value-text = 'France'.
  APPEND ls_value TO lt_value.
  ls_value-key = 'GER'.
  ls_value-text = 'Germany'.
  APPEND ls_value TO lt_value.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'L1'
      values          = lt_value
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.

Execution:

You may find more information in the SAP Library (the explanations are valid for all kind of screens, the examples are only for classic screens but they may be adapted easily to selection screens): http://help.sap.com/saphelp_470/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/frameset.htm



来源:https://stackoverflow.com/questions/8847534/how-to-set-values-in-the-listbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!