Application Development 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: 

Changing ICON of Button in Module Pool Dynamically

Former Member
0 Kudos

Hi,

How can i Change the ICON of Button in Module Pool dynamically in my program.While designing screen, in Button attribute I have assigned an ICON. But in my program if some condition is satisfied I need to change the ICON of the same button.

Thanks,

Santosh S.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

First, create the button on the screen. Give a name like 'THISBUTTON' in the name field of the button(not the text field), click the OUTPUT Only checkbox. Now, in your ABAP program, define a field for this button that you created and set the value of the icon in the PBO.



* In this sample program, there is a button on screen 100
* which has the name of THISBUTTON, and is set as output
* only.

report zrich_0001.

<b>type-pools: icon.

data: thisbutton(30) Type c.</b>


call screen 100.
*&---------------------------------------------------------------------*
*&      Module  status_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.

<b>write icon_green_light as icon to thisbutton.
concatenate thisbutton 'This is the button' into thisbutton
            separated by space.</b>

endmodule.                 " status_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  user_command_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  leave program.

endmodule.                 " user_command_0100  INPUT

Please be sure to award points for helpful answer and mark as solved when solved completely. thanks.

Regards,

Rich Heilman

3 REPLIES 3

Former Member
0 Kudos

Hi,

use the ICON_CREATE FM to change the ICON dynamically..

Thanks,

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

First, create the button on the screen. Give a name like 'THISBUTTON' in the name field of the button(not the text field), click the OUTPUT Only checkbox. Now, in your ABAP program, define a field for this button that you created and set the value of the icon in the PBO.



* In this sample program, there is a button on screen 100
* which has the name of THISBUTTON, and is set as output
* only.

report zrich_0001.

<b>type-pools: icon.

data: thisbutton(30) Type c.</b>


call screen 100.
*&---------------------------------------------------------------------*
*&      Module  status_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.

<b>write icon_green_light as icon to thisbutton.
concatenate thisbutton 'This is the button' into thisbutton
            separated by space.</b>

endmodule.                 " status_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  user_command_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  leave program.

endmodule.                 " user_command_0100  INPUT

Please be sure to award points for helpful answer and mark as solved when solved completely. thanks.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

This works correctly for normal button.

Is it possible to change text of pushbuttons in a table control dynamically.

Please let me know.

Regards,

Ravi