如何在列表框中设置值? [英] How to set values in the listbox?

查看:145
本文介绍了如何在列表框中设置值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在选择屏幕中定义了一个列表框,如下所示:

 带有框架的B2块选择屏幕开始标题标题1。 
选择画面行的开始。
字段L1的选择屏幕注释(30)ALCONT4。
参数:L1作为列表框可见长度20修改ID AOD。
选择画面的行尾。 B2块的
选择屏幕结束。

现在我需要为该列表框提出可能的值,我该怎么做?

解决方案

在屏幕的PBO期间(对于选择屏幕,PBO代码在事件块



有关信息,您可以从 T005T国家/地区的数据库表中获得相同的结果c $ c>,通过将条目转移到中间内部表中:

 数据:lt_t005t t005t的类型表,
ls_t005t类型t005t。
选择*从t005t
到表lt_t005t
WHERE spras ='E'国家/地区的英文名称
和land1 IN('FR','DE')。
循环到lt_t005t INTO ls_t005t。
ls_value-key = ls_t005t-land1。
ls_value-text = ls_t005t-landx50。
APPEND ls_value到lt_value。
ENDLOOP。

您可能会在SAP Library中找到更多信息(说明适用于所有类型的屏幕,示例仅适用于经典屏幕,但它们可能很容易适应选择屏幕): http ://help.sap.com/saphelp_470/helpdata/zh/9f/dbabe435c111d1829f0000e829fbfe/frameset.htm


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 ?

解决方案

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

这篇关于如何在列表框中设置值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆