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

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

问题描述

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

块 B2 的选择屏幕开始,框架标题为 ALTITLE1.选择屏幕开始.选择屏幕注释 (30) 字段 L1 的 ALCONT4.参数:L1 作为列表框可见长度 20 MODIF ID AOD.选择屏幕行尾.块 B2 的选择屏幕结束.

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

解决方案

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

有关信息,您可以从国家T005T的数据库表中获得相同的结果,通过将条目传输到中间内部表:

 数据:lt_t005t t005t 类型表,ls_t005t 类型 t005t.选择 * 从 t005t进入表 lt_t005tWHERE spras = 'E' " 国家英文名称AND land1 IN ('FR','DE').在 lt_t005t 处循环进入 ls_t005t.ls_value-key = ls_t005t-land1.ls_value-text = ls_t005t-landx50.将 ls_value 附加到 lt_value.端环.

您可以在 SAP 库中找到更多信息(解释适用于所有类型的屏幕,示例仅适用于经典屏幕,但它们可以轻松适应选择屏幕):http://help.sap.com/saphelp_470/helpdata/en/9350000e829fbfe/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天全站免登陆