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

EXPAND.png

/wp-content/uploads/2013/09/collapse_285850.png

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 sscrfieldsfunctxt_02.

   LOOP AT SCREEN.

     IF screengroup1 = gc_a.

       screenactive = 1.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.



AT SELECTION SCREEN EVENT

we have to write  the code:

IF syucomm gc_fc02.

     IF sscrfieldsfunctxt_02 = icon_collapse.

       gv_var = gc_exp.

       MOVE gc_exp TO sscrfieldsfunctxt_02.

     ELSEIF sscrfieldsfunctxt_02 = icon_expand.

       gv_var = gc_collp.

       MOVE gc_collp TO sscrfieldsfunctxt_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 screengroup1 = gc_a.

         screenactive = 0.

         MODIFY SCREEN.

       ENDIF.

     ENDLOOP.

   ELSEIF gv_var = gc_collp.

     LOOP AT SCREEN.

       IF screengroup1 = gc_a.

         screenactive = 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.




To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Raymond Giuseppi

    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

    (0) 
      1. Raymond Giuseppi
        • Remove the coding in the PBO (AT SELECTION-SCREEN OUTPUT)
        • Create a variant for the report, in the save screen, check the “hide field” for the fields of the block you want to hide with collapse

        • Execute the report with this variant

        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

        (0) 
        1. Anurag Sinha Post author

          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.

          (0) 
  2. max bianchi

    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(10EXP1 USER-COMMAND EXP1 MODIF ID EX1.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN PUSHBUTTON 1(10COL1 USER-COMMAND COL1 MODIF ID BL1.

    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME.

    PARAMETERS: P_BUKRS LIKE T001BUKRS  MODIF ID BL1,

                 P_WERKS LIKE T001WWERKS MODIF ID BL1.

    SELECTION-SCREEN END   OF BLOCK BL1.

    SELECTION-SCREEN PUSHBUTTON 1(10EXP2 USER-COMMAND EXP2 MODIF ID EX2.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN PUSHBUTTON 1(10COL2 USER-COMMAND COL2 MODIF ID BL2.

    SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME.

    PARAMETERS: P_BELNR LIKE BKPFBELNR MODIF ID BL2,

                 P_GJAHR LIKE BKPFGJAHR 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 SCREENGROUP1 = ‘EX1’.

             SCREENACTIVE = 0.

             MODIFY SCREEN.

           ENDIF.

         ENDLOOP.

       ELSE.

         LOOP AT SCREEN.

           IF SCREENGROUP1 = ‘BL1’.

             SCREENACTIVE = 0.

             MODIFY SCREEN.

           ENDIF.

         ENDLOOP.

       ENDIF.

       IF L_BL2 = ‘E’.

         LOOP AT SCREEN.

           IF SCREENGROUP1 = ‘EX2’.

             SCREENACTIVE = 0.

             MODIFY SCREEN.

           ENDIF.

         ENDLOOP.

       ELSE.

         LOOP AT SCREEN.

           IF SCREENGROUP1 = ‘BL2’.

             SCREENACTIVE = 0.

             MODIFY SCREEN.

           ENDIF.

         ENDLOOP.

       ENDIF.

    AT SELECTION-SCREEN.

       CASE SYUCOMM.

         WHEN ‘EXP1’. L_BL1 = ‘E’.

         WHEN ‘COL1’. L_BL1 = ‘C’.

         WHEN ‘EXP2’. L_BL2 = ‘E’.

         WHEN ‘COL2’. L_BL2 = ‘C’.

       ENDCASE.

    Max

    (0) 

Leave a Reply