ABAP 一个隐藏 selection-screen block的实例详解编程语言

      以下是一个演示如何通过 selection-screen 中的pushbutton来动态改变屏幕上的字段的显示状态的(即显示或者隐藏)。
      注意:显示 通过本示例可知selection-screen 中的 field 的显示状态都是 的,在程序中修改其属性 active 的值为 ‘0’ 时,该field就回隐藏起来。 但是在下一次屏幕显示前,其默认值又归为显示了。这时候可以在 at selection-screen output 事件或者 PBO中来修改active 值为 ‘0’即可。
另外,注意使用 modif id *** 来将selection screen 中的 field 指派到 screen-group1 中。 *** 是不超过三个字符的 id 名称,即指定了 screen-group1的值。

  1 *INCLUDE <icon>. 
  2 TABLES: sscrfields, 
  3         sflight. 
  4  
  5 SELECTION-SCREEN: PUSHBUTTON /1(40) pbo1      "open block 1 
  6                   USER-COMMAND ucomm_o1 MODIF ID mo1, 
  7                   PUSHBUTTON /1(20) pbc1      "close block 1 
  8                   USER-COMMAND ucomm_c1 MODIF ID mc1. 
  9  
 10 SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME. 
 11  
 12 SELECT-OPTIONS: s_car FOR sflight-carrid MODIF ID mc1, 
 13 *                s_con FOR sflight-connid MODIF ID mc1, 
 14 *                s_fld FOR sflight-fldate MODIF ID mc1, 
 15                 s_pri FOR sflight-price MODIF ID mc1. 
 16  
 17 SELECTION-SCREEN END OF BLOCK b01. 
 18  
 19 SELECTION-SCREEN: PUSHBUTTON /1(40) pbo2      "open block 1 
 20                   USER-COMMAND ucomm_o2 MODIF ID mo2, 
 21                   PUSHBUTTON /1(20) pbc2      "close block 1 
 22                   USER-COMMAND ucomm_c2 MODIF ID mc2. 
 23  
 24 SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME. 
 25  
 26 SELECT-OPTIONS: s_car2 FOR sflight-carrid MODIF ID mc2, 
 27 *                s_con2 FOR sflight-connid MODIF ID mc2, 
 28 *                s_fld2 FOR sflight-fldate MODIF ID mc2, 
 29                 s_pri2 FOR sflight-price MODIF ID mc2. 
 30  
 31 SELECTION-SCREEN END OF BLOCK b02. 
 32  
 33 PARAMETERS: par_cb1(1) TYPE c NO-DISPLAY, 
 34             par_cb2(1) TYPE c NO-DISPLAY. 
 35  
 36  
 37 INITIALIZATION. 
 38  
 39   CONCATENATE icon_expand: '打开' '' INTO pbo1, 
 40                '打开' '' INTO pbo2. 
 41  
 42   CONCATENATE icon_collapse: '关闭' '' INTO pbc1, 
 43                 '关闭' '' INTO pbc2. 
 44   par_cb1 = 'X'. 
 45   par_cb2 = 'X'. 
 46  
 47 AT SELECTION-SCREEN. 
 48   CASE sscrfields-ucomm. 
 49     WHEN 'UCOMM_O1'. 
 50       CLEAR par_cb1. 
 51     WHEN 'UCOMM_C1'. 
 52       par_cb1 = 'X'. 
 53     WHEN 'UCOMM_O2'. 
 54       CLEAR par_cb2. 
 55     WHEN 'UCOMM_C2'. 
 56       par_cb2 = 'X'. 
 57   ENDCASE. 
 58  
 59  
 60 AT SELECTION-SCREEN OUTPUT. 
 61   LOOP AT SCREEN. 
 62     PERFORM close_block USING:  par_cb1 'MO1' 'X', 
 63                                 par_cb1 'MC1' space, 
 64                                 par_cb2 'MO2' 'X', 
 65                                 par_cb2 'MC2' space. 
 66  
 67   ENDLOOP. 
 68  
 69 START-OF-SELECTION. 
 70   DO. 
 71     IF sy-index = 10. 
 72       EXIT. 
 73     ENDIF. 
 74   ENDDO. 
 75 *&--------------------------------------------------------------------* 
 76 *&      Form  close_block 
 77 *&--------------------------------------------------------------------* 
 78 *       text 
 79 *---------------------------------------------------------------------* 
 80 *      -->VALUE(U_CLOtextLOCK) 
 81 *      -->U_MODIFY_IDtext 
 82 *      -->U_CONVERT  text 
 83 *---------------------------------------------------------------------* 
 84 FORM close_block USING value(u_close_block) LIKE par_cb1 
 85                        u_modify_id LIKE screen-group1 
 86                        u_convert. 
 87  
 88   IF NOT u_convert IS INITIAL. 
 89     IF u_close_block IS INITIAL. 
 90       u_close_block = 'X'. 
 91     ELSE. 
 92       CLEAR u_close_block. 
 93     ENDIF. 
 94   ENDIF. 
 95  
 96   IF ( screen-group1 = u_modify_id ) 
 97     AND ( NOT u_close_block IS INITIAL ). 
 98     screen-active = '0'. 
 99     MODIFY SCREEN. 
100   ENDIF. 
101  
102 ENDFORM.                    "close_block

View Code

ABAP 一个隐藏 selection-screen block的实例详解编程语言ABAP 一个隐藏 selection-screen block的实例详解编程语言ABAP 一个隐藏 selection-screen block的实例详解编程语言

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

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

相关推荐

发表回复

登录后才能评论