2007 Sep 19 2:14 AM
Hi,
Is it possible to change the ICON and the Function Code of a Push Button in a Screen, dynamically in the Dialog Programming? Please suggest me a suitable solution.
Appreciate Your Help.
Thanks,
Kannan.
2007 Sep 19 3:27 AM
Hi,
It is possible to change icon dynamically based on function code of a button or based on a values like ...if a particular vaiable is outputted one icon and so on
It is not right to change the function code of a button dynamically(dont believe it is possible too) ...coz the purpose of push button and therby uniquely identifying the action on a button with a function code is lost....so it is better to use multiple buttons...(including radiobuttons/push buttons/check boxes) and uniquely identify them and then change icons accordingly
For dynamic changes in icon please refer the following code
Simple steps
***********************
First create a status icon Box on the screen required(go to screen painter..left side...last icon at the bottom with a 'Tick and Cross' Mark.
so in PBO
case itab-status. "checkin status if itab-status
"if we are using table control drag and drop the icon box into the column so that we can loop at the table control and change status icons for each line
When 'OPEN'.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = 'ICON_GREEN_LIGHT' "name of icon u want
text = 'open' "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 other 'Complete' also follow similar steps
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
Please refer the standard code "DEMO_DYNPRO_STATUS_ICONS" in se38
on click of a button it is changing the status
Regards
Byju
2007 Sep 19 3:27 AM
Hi,
It is possible to change icon dynamically based on function code of a button or based on a values like ...if a particular vaiable is outputted one icon and so on
It is not right to change the function code of a button dynamically(dont believe it is possible too) ...coz the purpose of push button and therby uniquely identifying the action on a button with a function code is lost....so it is better to use multiple buttons...(including radiobuttons/push buttons/check boxes) and uniquely identify them and then change icons accordingly
For dynamic changes in icon please refer the following code
Simple steps
***********************
First create a status icon Box on the screen required(go to screen painter..left side...last icon at the bottom with a 'Tick and Cross' Mark.
so in PBO
case itab-status. "checkin status if itab-status
"if we are using table control drag and drop the icon box into the column so that we can loop at the table control and change status icons for each line
When 'OPEN'.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = 'ICON_GREEN_LIGHT' "name of icon u want
text = 'open' "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 other 'Complete' also follow similar steps
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
Please refer the standard code "DEMO_DYNPRO_STATUS_ICONS" in se38
on click of a button it is changing the status
Regards
Byju