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

Pushbutton with an icon inside

gastn_jareo
Active Participant
0 Likes
2,591

I'm migrating a program from 4.6 to 5.0 version. On 4.6 the program shows a pushbutton with an icon. When you press the button the icon changes and other options are displayed on screen. I'm newby on abap so I don't know how it works.

But anyway it works on 5.0 too, but the button shows an extrange code inside instead of the icon.

Every example I found of pushbutton has a text assigned to it on initialization section, but I didn't found any example with icons to try to understand how it works.

Can anybody help me?

The button is shown by:

SELECTION-SCREEN: PUSHBUTTON 72(4) PB%EXCO USER-COMMAND EXPCOL.

Thanks.

Gastó

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,186

You can do it just like this.




report zrich_0001.

<b>type-pools: icon.</b>

selection-screen begin of block b1 with frame title text-001.
selection-screen pushbutton 5(20) gocfg user-command gocfg.
selection-screen end of block b1.

start-of-selection.

<b>at selection-screen output.

* Write pushbutton text
  write icon_configuration as icon to gocfg.
  concatenate gocfg 'Configuration' into gocfg
              separated by space.</b>

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,187

You can do it just like this.




report zrich_0001.

<b>type-pools: icon.</b>

selection-screen begin of block b1 with frame title text-001.
selection-screen pushbutton 5(20) gocfg user-command gocfg.
selection-screen end of block b1.

start-of-selection.

<b>at selection-screen output.

* Write pushbutton text
  write icon_configuration as icon to gocfg.
  concatenate gocfg 'Configuration' into gocfg
              separated by space.</b>

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,186

TABLES sscrfields.

TYPE-POOLS icon.

SELECTION-SCREEN:

BEGIN OF SCREEN 500 AS WINDOW TITLE title,

PUSHBUTTON 2(10) but1 USER-COMMAND cli1,

PUSHBUTTON 12(30) but2 USER-COMMAND cli2

VISIBLE LENGTH 10,

END OF SCREEN 500.

AT SELECTION-SCREEN.

CASE sscrfields.

WHEN 'CLI1'.

...

WHEN 'CLI2'.

...

ENDCASE.

START-OF-SELECTION.

title = 'Push button'.

but1 = 'Button 1'.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_information

text = 'Button 2'

info = 'My Quickinfo'

IMPORTING

RESULT = but2

EXCEPTIONS

OTHERS = 0.

CALL SELECTION-SCREEN '0500' STARTING AT 10 10.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,186

Also, try this sample program.


report zrich_0001.

type-pools: icon.

data: switch.

selection-screen begin of block b1 with frame title text-001.
selection-screen pushbutton 5(20) gocfg user-command gocfg.
selection-screen end of block b1.

start-of-selection.

at selection-screen output.

if switch = 'X'.
clear switch.
* Write pushbutton text
  write icon_red_light as icon to gocfg.
  concatenate gocfg 'Red Light' into gocfg
              separated by space.


else.
switch = 'X'.
  write icon_Green_light as icon to gocfg.
  concatenate gocfg 'Green Light' into gocfg
              separated by space.


endif.


Regards,

Rich Heilman

Read only

gastn_jareo
Active Participant
0 Likes
1,186

Very thank you guys!

Gastó