[代码]在选择画面中收起/展开字段详解编程语言

下面ABAP代码实现在选择画面中收起/展开部分字段的功能,供参考。

REPORT ztest_selection_screen_expand. 
 
TYPE-POOLS icon. 
TABLES mara. 
 
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME. 
PARAMETERS p_werks TYPE werks_d. 
SELECTION-SCREEN END OF  BLOCK b1. 
 
SELECTION-SCREEN SKIP 1. 
 
SELECTION-SCREEN BEGIN OF LINE. 
SELECTION-SCREEN PUSHBUTTON 1(4) but1 USER-COMMAND button1 VISIBLE LENGTH 2. 
SELECTION-SCREEN COMMENT 6(20) com1. 
SELECTION-SCREEN END OF LINE. 
 
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME. 
SELECT-OPTIONS : s_matnr FOR mara-matnr MODIF ID bl1, 
                 s_groes FOR mara-groes MODIF ID bl1. 
SELECTION-SCREEN END OF BLOCK b2. 
 
INITIALIZATION. 
* 初始化expand按钮 
  WRITE icon_data_area_expand AS ICON TO but1. 
  com1 = 'Data Collapse'. 
 
AT SELECTION-SCREEN. 
* 切换expand和Collapse按钮 
  CASE sy-ucomm. 
    WHEN 'BUTTON1'. 
      IF but1 = '@K1@'. 
        WRITE icon_data_area_collapse AS ICON TO but1. 
        com1 = 'Data Expand'. 
      ELSE. 
        WRITE icon_data_area_expand AS ICON TO but1. 
        com1 = 'Data Collapse'. 
      ENDIF. 
  ENDCASE. 
 
AT SELECTION-SCREEN OUTPUT. 
* 隐藏group1中的字段 
  LOOP AT SCREEN. 
    IF but1 = '@K2@' AND screen-group1 = 'BL1'. 
      screen-active = 0. 
      MODIFY SCREEN. 
    ENDIF. 
  ENDLOOP.

初始化面:

[代码]在选择画面中收起/展开字段详解编程语言

点击Data Collapse按钮后,下面的两个字段收起不显示。

[代码]在选择画面中收起/展开字段详解编程语言

以上。

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19301.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论