Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Add Expand/Collapse button in selection screen

Former Member
0 Likes
1,969

hi,

i have to add expand button in the selection screen, afterwich, the expand button will be replaced by collapse button,

any idea?!

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,125

You should define

[DefineDynamicFunctionText|http://help.sap.com/erp2005_ehp_04/helpdata/EN/d1/801e3a454211d189710000e8322d00/frameset.htm]. for this you need to define a program field e.g data: icon type smp_dyntxt. Also you should define TYPE-POOLS: ICON. then at run time;

icon = "@3S@". (Which means expand)

After push expand button in user command you shoul assign collapse code to icon variable;

icon = "@3T@".

I tried and I see it works.

hi,

i have to add expand button in the selection screen, afterwich, the expand button will be replaced by collapse button,

any idea?!

thanks

2 REPLIES 2
Read only

Former Member
0 Likes
1,126

You should define

[DefineDynamicFunctionText|http://help.sap.com/erp2005_ehp_04/helpdata/EN/d1/801e3a454211d189710000e8322d00/frameset.htm]. for this you need to define a program field e.g data: icon type smp_dyntxt. Also you should define TYPE-POOLS: ICON. then at run time;

icon = "@3S@". (Which means expand)

After push expand button in user command you shoul assign collapse code to icon variable;

icon = "@3T@".

I tried and I see it works.

Read only

Former Member
0 Likes
1,125

Check this code..............



DATA: wf_ucomm TYPE sy-ucomm.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECTION-SCREEN PUSHBUTTON  /01(30) but1 USER-COMMAND but1.
SELECTION-SCREEN PUSHBUTTON  /01(30) but2 USER-COMMAND but2.
PARAMETERS:  p_test TYPE c.
SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.
  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name   = 'ICON_EXPAND'
    IMPORTING
      RESULT = but1
    EXCEPTIONS
      OTHERS = 0.
  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name   = 'ICON_COLLAPSE'
    IMPORTING
      RESULT = but2
    EXCEPTIONS
      OTHERS = 0.

AT SELECTION-SCREEN.

  IF sy-ucomm EQ 'BUT1'.
    wf_ucomm = 'BUT1'.
  ELSEIF sy-ucomm EQ 'BUT2'.
    wf_ucomm = 'BUT2'.
  ENDIF.

AT SELECTION-SCREEN OUTPUT.

  IF wf_ucomm IS INITIAL.
    LOOP AT SCREEN.
      IF screen-name CS 'P_TEST'OR
         screen-name EQ 'BUT2'.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSEIF wf_ucomm EQ 'BUT1'.
    LOOP AT SCREEN.
      IF screen-name CS 'P_TEST' OR
         screen-name EQ 'BUT2'.
        screen-active = 1.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name EQ 'BUT1'.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSEIF wf_ucomm EQ 'BUT2' .
    LOOP AT SCREEN.
      IF screen-name CS 'P_TEST' OR
         screen-name EQ 'BUT2'.
        screen-active = 0.
        MODIFY SCREEN.
      ENDIF.
      IF screen-name EQ 'BUT1'.
        screen-active = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.