如何在列表框中设置值?

发布于 2024-12-27 01:58:07 字数 354 浏览 2 评论 0原文

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

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.

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

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷→糖丶微凉 2025-01-03 01:58:07

在屏幕的 PBO 期间(对于选择屏幕,PBO 代码在事件块内定义 在选择屏幕OUTPUT),您必须调用功能模块 VRM_SET_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.

执行:

具有 2 个国家/地区的 abap dynpro 列表框

可以通过将条目传输到中间内部表来从国家/地区数据库表 T005T 获得相同的结果:

  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.

有关信息,您 可以在 SAP 库中找到更多信息(解释对所有类型的屏幕都有效,示例仅适用于经典屏幕,但它们可以轻松适应选择屏幕):http://help.sap.com/saphelp_470/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/frameset.htm

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:

abap dynpro listbox with 2 countries

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文