In i shall show how to create a expand and collapse button in a selection screen with two blocks.
firstly we need to go to the table ICON and see what icon is required. We can find the icon text in this table. Which is needed to be written in the code. The main objective is to create this
To achieve this we have to create global or local variable
gc_collp TYPE char4 VALUE '@3T@',
gc_exp TYPE char4 VALUE '@3S@'.
This are the Icon in text fields which can be found in the table ICON.
NOW at the INITIALIZATION EVENT we have to write the code:
MOVE gc_collp TO sscrfields-functxt_02.
LOOP AT SCREEN.
IF screen-group1 = gc_a.
screen-active = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION SCREEN EVENT
we have to write the code:
IF sy-ucomm = gc_fc02.
IF sscrfields-functxt_02 = icon_collapse.
gv_var = gc_exp.
MOVE gc_exp TO sscrfields-functxt_02.
ELSEIF sscrfields-functxt_02 = icon_expand.
gv_var = gc_collp.
MOVE gc_collp TO sscrfields-functxt_02.
ENDIF.
ENDIF.
*(gc_fc02 is function code FC02 Text for pushbuttons which is generated when we press the collapse button u can hard code is as well)
and in the end we need to write in the event at selection screen output:
IF gv_var = gc_exp.
LOOP AT SCREEN.
IF screen-group1 = gc_a.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSEIF gv_var = gc_collp.
LOOP AT SCREEN.
IF screen-group1 = gc_a.
screen-active = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
*(gv_var is the variable in which the icon texts are stored).
Hope this will help for future purposes..
Thanks and Regards
Anurag Sinha.