ABAP-折叠窗口

时间:2024-01-12 12:04:44

1.测试

ABAP-折叠窗口

ABAP-折叠窗口

2.代码

 *&---------------------------------------------------------------------*
*& Report ZRICO_TEST24
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zrico_test24. tables: sscrfields.
data: g_code type sscrfields-ucomm. "FUNCTION CODE parameters: p_cb0() type c no-display, "Close Block 0
p_cb1() type c no-display. "Close Block 1 selection-screen function key ."expand all blocks
selection-screen function key . "collapse all blocks ***************** Block 00 *** Description data file
selection-screen: pushbutton /() pushb_o0 "Open Block 00
user-command ucomm_o0 modif id mo0, "#EC NEEDED
pushbutton /() pushb_c0 "Close Block 00
user-command ucomm_c0 modif id mc0. "#EC NEEDED
selection-screen begin of block b0 with frame title text-.
parameters: p_down00 type downloadx as checkbox modif id mc0.
selection-screen end of block b0. ***************** Block 01 *** Report 01
selection-screen: pushbutton /() pushb_o1 "Open Block 01
user-command ucomm_o1 modif id mo1, "#EC NEEDED
pushbutton /() pushb_c1 "Close Block 01
user-command ucomm_c1 modif id mc1. "#EC NEEDED
selection-screen begin of block b1 with frame title text-.
parameters: p_rep01 as checkbox modif id mc1."DEFAULT 'X'.
parameters: p_var01 like varid-variant modif id mc1.
selection-screen end of block b1. initialization. * Close Selection-Screen
p_cb0 = 'X'. p_cb1 = 'X'.
* Set Text & Icon for application bar
concatenate icon_expand: 'Expand all blocks' into sscrfields-functxt_01.
concatenate icon_collapse: 'Collapse all blocks' into sscrfields-functxt_02. * Set Text & Icon for Pushbutton
concatenate icon_collapse: 'Block 00' into pushb_c0,
'Block 01' into pushb_c1 . concatenate icon_expand: 'Block 00' into pushb_o0,
'Block 01' into pushb_o1. at selection-screen.
g_code = sscrfields-ucomm.
case g_code.
*Expand all blocks
when 'FC01'.
perform expand_all_blocks.
*Collapse all blocks
when 'FC02'. "Collapse all blocks
perform collapse_all_blocks.
*Open/close individual block functions
when 'UCOMM_O0'. "Open Block 0
clear p_cb0.
when 'UCOMM_C0'. "Close Block 0
p_cb0 = 'X'.
when 'UCOMM_O1'. "Open Block 1
clear p_cb1.
when 'UCOMM_C1'. "Close Block 1
p_cb1 = 'X'.
endcase. at selection-screen output.
*modify screen according predefined screen group
loop at screen.
case screen-group1.
when 'MC0'.
perform close_block using: p_cb0 'MC0' space.
when 'MO0'.
perform close_block using: p_cb0 'MO0' 'X' .
when 'MC1'.
perform close_block using: p_cb1 'MC1' space.
when 'MO1'.
perform close_block using: p_cb1 'MO1' 'X' .
when others.
continue.
endcase.
endloop. *&---------------------------------------------------------------------*
*& Form close_block
*&---------------------------------------------------------------------*
form close_block using value(i_close_block) like p_cb1
value(i_modify_id) like screen-group1
value(i_convert) type char1.
if not i_convert is initial.
if i_close_block is initial.
i_close_block = 'X'.
else.
clear i_close_block.
endif.
endif. if ( screen-group1 = i_modify_id )
and ( not i_close_block is initial ).
screen-active = ''.
modify screen.
endif. endform. "close_block *&---------------------------------------------------------------------*
*& Form collapse_all_blocks
*&---------------------------------------------------------------------*
form collapse_all_blocks.
p_cb0 = 'X'.p_cb1 = 'X'.
endform. "collapse_all_blocks *&---------------------------------------------------------------------*
*& Form expand_all_blocks
*&---------------------------------------------------------------------*
form expand_all_blocks.
clear: p_cb0,p_cb1 .
endform.