Creating EXPAND AND COLLAPSE BUTTON IN SELECTION SCREEN.
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.
You could just create a program variant, mark fields hidden in collapsed status as hidden in this variant, use it in the transaction definition. Then SAP will manage itself the expand/collapse buttons.
Regards,
Raymond
Hi raymond,
It will be a help if you can explain a bit more,
Thanks And reagards ,
Anurag Sinha
Just use this variant in the transaction definition (I would suggest to crate a CUS&nnn variant so will always been transported, and user wont be allowed to change it)
Regards,
Raymond
Hi Raymond,
It really cool but my requirement was that icon collapse needed to be shown at first. So is there any way to do that without so much coding? And more over it is need to be shown all the time whenever the t-code is called.
Hi
In generally I prefer to adds the expand and collapse buttons into the selection-screen, not in the bar, just before the section to be shown/Hidden:
SELECTION-SCREEN PUSHBUTTON 1(10) EXP1 USER-COMMAND EXP1 MODIF ID EX1.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN PUSHBUTTON 1(10) COL1 USER-COMMAND COL1 MODIF ID BL1.
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME.
PARAMETERS: P_BUKRS LIKE T001-BUKRS MODIF ID BL1,
P_WERKS LIKE T001W-WERKS MODIF ID BL1.
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN PUSHBUTTON 1(10) EXP2 USER-COMMAND EXP2 MODIF ID EX2.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN PUSHBUTTON 1(10) COL2 USER-COMMAND COL2 MODIF ID BL2.
SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME.
PARAMETERS: P_BELNR LIKE BKPF-BELNR MODIF ID BL2,
P_GJAHR LIKE BKPF-GJAHR MODIF ID BL2.
SELECTION-SCREEN END OF BLOCK BL2.
DATA: L_BL1 TYPE FLAG.
DATA: L_BL2 TYPE FLAG.
INITIALIZATION.
EXP1 = EXP2 = '@3S@'.
COL1 = COL2 = '@3T@'.
L_BL1 = 'E'.
L_BL2 = 'E'.
AT SELECTION-SCREEN OUTPUT.
IF L_BL1 = 'E'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'EX1'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'BL1'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
IF L_BL2 = 'E'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'EX2'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'BL2'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN 'EXP1'. L_BL1 = 'E'.
WHEN 'COL1'. L_BL1 = 'C'.
WHEN 'EXP2'. L_BL2 = 'E'.
WHEN 'COL2'. L_BL2 = 'C'.
ENDCASE.
Max
Hi max my requirement was to create the button on the bar only 😎 .
Thanks And regards,
Anurag Sinha
Nice....
Nice.