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

creating buttons at runtime.

Former Member
0 Likes
761

Hi Gurus,

I am trying to create buttons at runtime, is there any method to create the buttons without using module pool programming. Also further i will be adding some functionality to the buttons.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
600

Check The following test code

selection-screen begin of block b1.
selection-screen begin of line.
selection-screen pushbutton (4) icon1 user-command uc_icon1."1x1
selection-screen pushbutton (4) icon2 user-command uc_icon2."2x1
selection-screen pushbutton (4) icon3 user-command uc_icon3."3x1
selection-screen end of line.
selection-screen skip 1.
selection-screen begin of line.
selection-screen pushbutton (4) icon4 user-command uc_icon4."1x2
selection-screen pushbutton (4) icon5 user-command uc_icon5."2x2
selection-screen pushbutton (4) icon6 user-command uc_icon6."3x2
selection-screen end of line.
selection-screen skip 1.
selection-screen begin of line.
selection-screen pushbutton (4) icon7 user-command uc_icon7."1x3
selection-screen pushbutton (4) icon8 user-command uc_icon8."2x3
selection-screen pushbutton (4) icon9 user-command uc_icon9."3x3
selection-screen end of line.

selection-screen skip 1.
selection-screen begin of line.
selection-screen pushbutton (12) restart user-command uc_restart.
selection-screen end of line.

selection-screen end of block b1.
**----------------------------------------------------------------------*
**                        AT SELECTION-SCREEN                           *
**----------------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'UC_ICON1'.
      PERFORM push_button USING icon1.
    WHEN 'UC_ICON2'.
      PERFORM push_button USING icon2.
    WHEN 'UC_ICON3'.
      PERFORM push_button USING icon3.
    WHEN 'UC_ICON4'.
      PERFORM push_button USING icon4.
    WHEN 'UC_ICON5'.
      PERFORM push_button USING icon5.
    WHEN 'UC_ICON6'.
      PERFORM push_button USING icon6.
    WHEN 'UC_ICON7'.
      PERFORM push_button USING icon7.
    WHEN 'UC_ICON8'.
      PERFORM push_button USING icon8.
    WHEN 'UC_ICON9'.
      PERFORM push_button USING icon9.

**----------------------------------------------------------------------*
**                         INITIALIZATION                               *
**----------------------------------------------------------------------*
INITIALIZATION.
  PERFORM clear_buttons.

FORM clear_buttons .
  icon1 = '@5F@' .
  icon2 = '@5F@' .
  icon3 = '@5F@' .
  icon4 = '@5F@' .
  icon5 = '@5F@' .
  icon6 = '@5F@' .
  icon7 = '@5F@' .
  icon8 = '@5F@' .
  icon9 = '@5F@' .

  restart = 'Restart'.
ENDFORM." clear_buttons

FORM push_button USING p_icon.
* Exit if button pushed.
  IF p_icon <> '@5F@'.
    EXIT.
  ENDIF.

* Change icon.
  IF v_turn IS INITIAL.
    p_icon = '@7C@'.
    v_turn = 'X'.
  ELSE.
    p_icon = '@C9@'.
    CLEAR v_turn.
  ENDIF.
endform.



Edited by: tahir naqqash on Feb 23, 2009 4:16 PM

3 REPLIES 3
Read only

Former Member
0 Likes
601

Check The following test code

selection-screen begin of block b1.
selection-screen begin of line.
selection-screen pushbutton (4) icon1 user-command uc_icon1."1x1
selection-screen pushbutton (4) icon2 user-command uc_icon2."2x1
selection-screen pushbutton (4) icon3 user-command uc_icon3."3x1
selection-screen end of line.
selection-screen skip 1.
selection-screen begin of line.
selection-screen pushbutton (4) icon4 user-command uc_icon4."1x2
selection-screen pushbutton (4) icon5 user-command uc_icon5."2x2
selection-screen pushbutton (4) icon6 user-command uc_icon6."3x2
selection-screen end of line.
selection-screen skip 1.
selection-screen begin of line.
selection-screen pushbutton (4) icon7 user-command uc_icon7."1x3
selection-screen pushbutton (4) icon8 user-command uc_icon8."2x3
selection-screen pushbutton (4) icon9 user-command uc_icon9."3x3
selection-screen end of line.

selection-screen skip 1.
selection-screen begin of line.
selection-screen pushbutton (12) restart user-command uc_restart.
selection-screen end of line.

selection-screen end of block b1.
**----------------------------------------------------------------------*
**                        AT SELECTION-SCREEN                           *
**----------------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'UC_ICON1'.
      PERFORM push_button USING icon1.
    WHEN 'UC_ICON2'.
      PERFORM push_button USING icon2.
    WHEN 'UC_ICON3'.
      PERFORM push_button USING icon3.
    WHEN 'UC_ICON4'.
      PERFORM push_button USING icon4.
    WHEN 'UC_ICON5'.
      PERFORM push_button USING icon5.
    WHEN 'UC_ICON6'.
      PERFORM push_button USING icon6.
    WHEN 'UC_ICON7'.
      PERFORM push_button USING icon7.
    WHEN 'UC_ICON8'.
      PERFORM push_button USING icon8.
    WHEN 'UC_ICON9'.
      PERFORM push_button USING icon9.

**----------------------------------------------------------------------*
**                         INITIALIZATION                               *
**----------------------------------------------------------------------*
INITIALIZATION.
  PERFORM clear_buttons.

FORM clear_buttons .
  icon1 = '@5F@' .
  icon2 = '@5F@' .
  icon3 = '@5F@' .
  icon4 = '@5F@' .
  icon5 = '@5F@' .
  icon6 = '@5F@' .
  icon7 = '@5F@' .
  icon8 = '@5F@' .
  icon9 = '@5F@' .

  restart = 'Restart'.
ENDFORM." clear_buttons

FORM push_button USING p_icon.
* Exit if button pushed.
  IF p_icon <> '@5F@'.
    EXIT.
  ENDIF.

* Change icon.
  IF v_turn IS INITIAL.
    p_icon = '@7C@'.
    v_turn = 'X'.
  ELSE.
    p_icon = '@C9@'.
    CLEAR v_turn.
  ENDIF.
endform.



Edited by: tahir naqqash on Feb 23, 2009 4:16 PM

Read only

0 Likes
600

i am getting an error that Relational operator "'@5F@'" is not supported even after creating texts.

Read only

Former Member
0 Likes
600

The relational error appears because there's a missing equal sign.

where it says

IF p_icon '@5F@'.

it should say

IF p_icon = '@5F@'.