How to set values in the listbox?

前端 未结 1 2020
心在旅途
心在旅途 2021-01-21 09:41

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.
SELEC         


        
1条回答
  •  温柔的废话
    2021-01-21 10:14

    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 = 'DE'.
      ls_value-text = 'Germany'.
      APPEND ls_value TO lt_value.
      ls_value-key = 'FR'.
      ls_value-text = 'France'.
      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:

    For information, you can achieve the same result from the database table of countries T005T, by transferring the entries to an intermediate internal table:

      DATA: lt_t005t TYPE TABLE OF t005t,
            ls_t005t TYPE t005t.
      SELECT * FROM t005t
          INTO TABLE lt_t005t
          WHERE spras = 'E' " English names of countries
            AND land1 IN ('FR','DE').
      LOOP AT lt_t005t INTO ls_t005t.
        ls_value-key = ls_t005t-land1.
        ls_value-text = ls_t005t-landx50.
        APPEND ls_value TO lt_value.
      ENDLOOP.
    

    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

    0 讨论(0)
提交回复
热议问题