SAP/ABAP Function & Method

(ABAP F&M) ICON_CREATE Function

haramang 2021. 7. 5. 23:35

출처: https://answers.sap.com/questions/6901690/iconcreate-on-button-on-a-screen.html

 

ICON_CREATE on button on a screen | SAP Community

Dear expers, I have a requirement to expand and collaspe a subscreen on click of a button. But i stuck in changing the icon of a button on every click. I have a example to change the icon of a button on selection screen but its not working on a screen with

answers.sap.com

 

 

원문:

Former Member

Jan 11, 2010 at 06:30 AM

Hi,

The example Report Program explains you how to use the code for changing the ICON for a text. But in the function module documentation of the ICON_CREATE, it is clearly mentioned that the same can be used to change the ICON of the Push Button also.

Code Snippet:

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_name

text = icon_text

info = 'Status'

add_stdinf = 'X'

IMPORTING

result = push_btn

EXCEPTIONS

icon_not_found = 1

outputfield_too_short = 2

OTHERS = 3.

push_btn should be the name of the Push button on the Screen. And change the property of it to Output enabled. And then execute the code. it will change the Icon of the Push button dynamically.

have a look at the following link:

http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba9a635c111d1829f0000e829fbfe/content.htm

"Pushbuttons have a label - the text that you specify statically in the attributes - and can also have icons. If you set the Output field attribute for a pushbutton, you can also set its text dynamically in the ABAP program. To do this, you must create a field in the ABAP program with the same name as the pushbutton. You must then assign the required text to the field before the screen is displayed. You can also assign icons to dynamic texts on pushbuttons by including the icon code in the text. The icon codes are all contained in the include program <ICON>. For example, the ICON_CANCEL () icon has the code @0W@." - This explains that you can change the icon of the Push button.

Hope this helps.

Thanks,

Samantak.