一、选择屏幕字段不允许直接输入,只能通过F4
PARAMETERS: p_date TYPE sy-datum ,
p_bukrs LIKE t001-bukrs ,
p_str(10).
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-name.
WHEN ‘P_DATE’ OR ‘P_BUKRS’.
screen-input = 0.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_date.
CALL FUNCTION ‘F4_DATE’
IMPORTING
select_date = p_date.
LEAVE SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bukrs.
CALL FUNCTION ‘F4IF_FIELD_VALUE_REQUEST’
EXPORTING
tabname = ‘T001′
fieldname = ‘BUKRS’
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = ‘P_BUKRS’
display = ‘F’. ”
二、ABAP 选择屏幕应用工具栏添加按钮
TYPE-POOLS icon.
TABLES sscrfields.
DATA functxt TYPE smp_dyntxt.
PARAMETERS: p_carrid TYPE s_carr_id,
p_cityfr TYPE s_from_cit.
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
INITIALIZATION.
functxt-icon_id = icon_ws_plane.
functxt-quickinfo = 'Preselected Carrier'.
functxt-icon_text = 'LH'.
sscrfields-functxt_01 = functxt.
functxt-icon_text = 'UA'.
sscrfields-functxt_02 = functxt.
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'FC01'.
p_carrid = 'LH'.
p_cityfr = 'Frankfurt'.
WHEN 'FC02'.
p_carrid = 'UA'.
p_cityfr = 'Chicago'.
WHEN OTHERS.
...
ENDCASE.
三、selection-screen 通过 checkbox 动态隐藏或显示block里的字段
1、通过checkbox 复选框 动态显示或隐藏 选择屏幕上的block
REPORT ZTESTMODIFID.
PARAMETERS show_all AS CHECKBOX USER-COMMAND flag.
PARAMETERS show_al AS CHECKBOX USER-COMMAND flag.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p1 TYPE c LENGTH 10 MODIF ID bl1,
p2 TYPE c LENGTH 10 MODIF ID bl1,
p3 TYPE c LENGTH 10 MODIF ID bl1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
PARAMETERS: p4 TYPE c LENGTH 10 MODIF ID bl2,
p5 TYPE c LENGTH 10 MODIF ID bl2,
p6 TYPE c LENGTH 10 MODIF ID bl2.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN OUTPUT. "当show_all值改变时会触发此事件
LOOP AT SCREEN.
IF show_al <> 'X' AND
screen-group1 = 'BL1'. "
screen-active = '0'. "设置组内设置屏幕的显示和隐藏
ENDIF.
MODIFY SCREEN. "把弃置应用到当前屏幕
IF show_all <> 'X' AND
screen-group1 = 'BL2'. "
screen-active = '0'. "设置组内设置屏幕的显示和隐藏
ENDIF.
MODIFY SCREEN. "把弃置应用到当前屏幕
————————————————————————————————————————————————————
2、通过pushbutton 动态显示或隐藏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的值。
REPORT ZTESTMODIFID1.
SELECTION-SCREEN: PUSHBUTTON /1(40) pbo1 "open block 1
USER-COMMAND ucomm_o1 MODIF ID mo1,
PUSHBUTTON /1(20) pbc1 "close block 1
USER-COMMAND ucomm_c1 MODIF ID mc1.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME.
PARAMETERS: name type syuname MODIF ID mc1.
SELECT-OPTIONS: s_car FOR sflight-carrid MODIF ID mc1,
* s_con FOR sflight-connid MODIF ID mc1,
* s_fld FOR sflight-fldate MODIF ID mc1,
s_pri FOR sflight-price MODIF ID mc1.
SELECTION-SCREEN END OF BLOCK b01.
SELECTION-SCREEN: PUSHBUTTON /1(40) pbo2 "open block 1
USER-COMMAND ucomm_o2 MODIF ID mo2,
PUSHBUTTON /1(20) pbc2 "close block 1
USER-COMMAND ucomm_c2 MODIF ID mc2.
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME.
PARAMETERS: name2 type syuname MODIF ID mc2.
SELECT-OPTIONS: s_car2 FOR sflight-carrid MODIF ID mc2,
* s_con2 FOR sflight-connid MODIF ID mc2,
* s_fld2 FOR sflight-fldate MODIF ID mc2,
s_pri2 FOR sflight-price MODIF ID mc2.
SELECTION-SCREEN END OF BLOCK b02.
PARAMETERS: par_cb1(1) TYPE c NO-DISPLAY,
par_cb2(1) TYPE c NO-DISPLAY.
INITIALIZATION.
* CONCATENATE icon_expand: '打开' '' INTO pbo1,
* '打开' '' INTO pbo2.
*
* CONCATENATE icon_collapse: '关闭' '' INTO pbc1,
* '关闭' '' INTO pbc2.
par_cb1 = 'X'.
par_cb2 = 'X'.
AT SELECTION-SCREEN.
CASE sscrfields-ucomm.
WHEN 'UCOMM_O1'.
CLEAR par_cb1.
WHEN 'UCOMM_C1'.
par_cb1 = 'X'.
WHEN 'UCOMM_O2'.
CLEAR par_cb2.
WHEN 'UCOMM_C2'.
par_cb2 = 'X'.
ENDCASE.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
PERFORM close_block USING: par_cb1 'MO1' 'X',
par_cb1 'MC1' space,
par_cb2 'MO2' 'X',
par_cb2 'MC2' space.
ENDLOOP.
*&--------------------------------------------------------------------*
*& Form close_block
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->VALUE(U_CLOtextLOCK)
* -->U_MODIFY_IDtext
* -->U_CONVERT text
*---------------------------------------------------------------------*
FORM close_block USING value(u_close_block) LIKE par_cb1
u_modify_id LIKE screen-group1
u_convert.
IF NOT u_convert IS INITIAL.
IF u_close_block IS INITIAL.
u_close_block = 'X'.
ELSE.
CLEAR u_close_block.
ENDIF.
ENDIF.
IF ( screen-group1 = u_modify_id )
AND ( NOT u_close_block IS INITIAL ).
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ENDFORM.
3. 单选按钮
PARAMETERS: P_BJ RADIOBUTTON GROUP CITY USER-COMMAND sele,
P_CD RADIOBUTTON GROUP CITY DEFAULT 'X',
P_ZH RADIOBUTTON GROUP CITY.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t2.
PARAMETERS: P_LOCAL RADIOBUTTON GROUP AA MODIF ID M2 VISIBLE LENGTH 100,
P_OTHER RADIOBUTTON GROUP AA DEFAULT ’X' MODIF ID M2.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-group1.
WHEN ’M2′.
IF P_BJ = ’X’.
screen-active = ’1′.
ELSE.
screen-active = ’0′.
ENDIF.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16794144/viewspace-757431/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16794144/viewspace-757431/