前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >matinal:SAP ABAP 实现动态下拉框

matinal:SAP ABAP 实现动态下拉框

作者头像
matinal
发布2023-10-14 15:15:00
2140
发布2023-10-14 15:15:00
举报
文章被收录于专栏:SAP Technical

SAP ABAP 实现动态下拉框

自己用的小功能

代码语言:javascript
复制
REPORT z_matinal.
TYPE-POOLS:vrm.

DATA: name TYPE vrm_id.
DATA:num TYPE i. "内表判断字段长度的变量

TYPES: BEGIN OF wa ,
         key(40),
         text(80) TYPE c,
       END OF wa.

DATA:gt LIKE t179t OCCURS 0 WITH HEADER LINE.
DATA:wa1 TYPE TABLE OF wa WITH HEADER LINE. "111
DATA:wa2 TYPE TABLE OF wa WITH HEADER LINE .                "111222
DATA:wa3 TYPE TABLE OF wa WITH HEADER LINE.                 "111222333

DATA:itab LIKE t179t OCCURS 0 WITH HEADER LINE.

DATA: ps_t(15) TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK t1 WITH FRAME TITLE title1.

  SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 1(31) TEXT-003.

    PARAMETERS: pl1 LIKE ps_t AS LISTBOX VISIBLE LENGTH 15 USER-COMMAND p1 ."一级类

  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN SKIP 1.

  SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 1(31) TEXT-004.

    PARAMETERS: pl2 LIKE ps_t AS LISTBOX VISIBLE LENGTH 15 USER-COMMAND p2."二级类

  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN SKIP 1.

  SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 1(31) TEXT-005.

    PARAMETERS: pl3 LIKE ps_t AS LISTBOX VISIBLE LENGTH 15."三级类

  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN END OF BLOCK t1.

INITIALIZATION.

  gt-vtext = '1'.
  gt-prodh = 'YI111'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI222'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI11145678'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI11198765'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI11112345'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI11156789'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI1114567812345678'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI1114567887654321'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI1115678123456789'.
  APPEND gt .
  gt-vtext = '1'.
  gt-prodh = 'YI1115678987654321'.
  APPEND gt .

AT SELECTION-SCREEN OUTPUT.

   CLEAR:wa1,wa1[].

  name = 'PL1'.

  LOOP AT gt.

    num = strlen( gt-prodh ).

    IF num = 5.

      wa1-text  = gt-vtext.

      wa1-key   = gt-prodh.

      APPEND: wa1.

    ENDIF.

    CLEAR: gt,num,wa1.

  ENDLOOP.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = name
      values = wa1[].

AT SELECTION-SCREEN.

  CASE sy-ucomm.

    WHEN 'P1'.

      CLEAR: pl2,pl3.        "清空2、3级下拉空默认值,当用户在选择屏幕上重新选择时需要清除

      CLEAR:wa2,wa2[].       "清空2级下拉内表对应的值,当用户在选择屏幕上重新选择时需要清除

      CLEAR num.

      LOOP AT gt .

        num = strlen( gt-prodh ).

        IF num = 10 AND gt-prodh+0(5) = pl1.

          wa2-text  = gt-vtext.

          wa2-key   = gt-prodh.

          APPEND: wa2.

        ENDIF.

        CLEAR:gt,num,wa2.

      ENDLOOP.

      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = 'PL2'
          values = wa2[].

      CLEAR pl2.

    WHEN 'P2'.

      CLEAR pl3.               "清空3级下拉空默认值,当用户在选择屏幕上重新选择时需要清除

      CLEAR:wa3,wa3[].         "清空3级下拉内表对应的值,当用户在选择屏幕上重新选择时需要清除

      CLEAR num.

      LOOP AT gt .

        num = strlen( gt-prodh ).

        IF num = 18 AND gt-prodh+0(10) = pl2.

          wa3-text  = gt-vtext.

          wa3-key   = gt-prodh.

          APPEND: wa3.

        ENDIF.

        CLEAR:gt,num,wa3.

      ENDLOOP.
* 公众号:matinal
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = 'PL3'
          values = wa3[].

      CLEAR pl3.

  ENDCASE.
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-09-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档