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

Dynamic button in Dynpro

Former Member
0 Likes
2,303

Hi,

I've designed a Dynpro with some buttons whose icon has to change dynamically. For example, if a process goes ok it should be ICON_OKAY, or if it goes ko, ICON_CANCEL.

Does anyone know how to do this?

Thanks!

Carles

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,442

hi,

Check the FM 'ICON_CREATE', maybe it could be useful.

regards

3 REPLIES 3
Read only

Former Member
0 Likes
1,443

hi,

Check the FM 'ICON_CREATE', maybe it could be useful.

regards

Read only

Former Member
0 Likes
1,442

Hello Carles,

Please refer the standard code "DEMO_DYNPRO_STATUS_ICONS" in se38

on click of a button it is changing the status

here..in your case..with the click of different buttons we get different sy-ucomms

and based on value of sy-ucomm we can change the icon

Simple steps

***********************

When 'OK'.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = 'ICON_OKAY' "name of icon u want

text = 'ok' "text of the icon

info = 'Status' "tool -tip text

add_stdinf = 'X'

IMPORTING

result = status_icon

EXCEPTIONS

icon_not_found = 1

outputfield_too_short = 2

OTHERS = 3.

when 'CANCEL'

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = 'ICON_CANCEL' "name of icon u want

text = 'cancel' "text of the icon

info = 'Status' "tool -tip text

add_stdinf = 'X'

IMPORTING

result = status_icon

EXCEPTIONS

icon_not_found = 1

outputfield_too_short = 2

OTHERS = 3.

endcase.

Similarly for others ..we can change the icon based on function code recieved

sy-subrc = 0.

"success

sy-subrc = 1.

Icon does not exist

sy-subrc = 2.

Icon and text do not fit on screen

sy-subrc = 3.

Error displaying status icon

<b><REMOVED BY MODERATOR></b>

Regards

Byju

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
1,442

HI,

in the screen painter go to the attributes of that push button.select the check box <b>WITH ICON</b> and

in the lower tab strip(program tab)

select the check box <b>OUTPUT FIELD</b>.

now in the pbo of the screen write like below.

data:<button name>(30).

data:but_name(30).

concatenate <icon_name> <icon text> into but_name sepatared by space.

<button name> = but_name.

rgds,

bharat.