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: 

Using icons as select-option/parameter value

maria_merino
Active Participant
0 Kudos
1,349

Hi,

I've been asked to add a new parameter in a program. This new field's f4 must show icon_green_light, icon_red_light and icon_yellow_light. the matchcode shows the values ok but when I select one of them the value passed to the parameter is the icon code, i.e @08@.

That's what I've done:

PARAMETERS: p_comp TYPE icon_d.

[...]

TYPES: BEGIN OF ty_fields,
icon TYPE icon_d.
TYPES: END OF ty_fields,
tt_fields TYPE TABLE OF ty_fields.

[...]

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_comp-low.
PERFORM f_completo_f4 changing s_comp-low.

[...]

 FIELD-SYMBOLS: <fs_return> TYPE ddshretval.


 DATA: li_return TYPE TABLE OF ddshretval,
l_fields TYPE ty_fields,
li_fields TYPE tt_fields.

 SELECT id
FROM icon
INTO TABLE li_fields
WHERE id IN ('@08@','@09@','@0A@').

 CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'COMPLETO'
dynprofield = 'P_COMP'
dynpprog = sy-repid
dynpnr = sy-dynnr
value_org = 'S'
TABLES
value_tab = li_fields
return_tab = li_return.

 READ TABLE li_return ASSIGNING <fs_return>
INDEX 1.
IF sy-subrc EQ 0.
WRITE <fs_return>-fieldval AS ICON TO p_comp.
ENDIF.

 REFRESH li_return.
CLEAR li_return.

How can I solve it?

thanks!

Maria

7 REPLIES 7

vijay_hariharan
Contributor
0 Kudos
1,115

Hello,

One Simple solution is to have three check-box OR Radio button if you want to allow only one of the types in the output.. each for the Green, Yellow and Red signals and in the description, you may use the Icon codes so the selection screen looks something like this signal.jpg

Hope this helps.

Regards,
Vijay

0 Kudos
1,115

Thanks, but they don't like this option..

1,115

Do they understand the difference between "like" and "technically possible"? haha

Sandra_Rossi
Active Contributor
1,115

Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

Sandra_Rossi
Active Contributor
0 Kudos
1,115

You may have a look at what is possible in BIBS transaction code. For instance > Elements > Icons > icon for "Warehouse stock" with separate button to change the icon.

Or you can do like below to make the icon a pushbutton, to simulate F4:

TABLES sscrfields.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (40) text.
SELECTION-SCREEN PUSHBUTTON (4) p_comp USER-COMMAND change_light.
SELECTION-SCREEN END OF LINE.
TYPES: BEGIN OF ty_fields,
         icon TYPE icon_d,
       END OF ty_fields,
       tt_fields TYPE TABLE OF ty_fields.

INITIALIZATION.
  text = 'Click the light icon to change it'.
  p_comp = '@08@'.

AT SELECTION-SCREEN.
  CASE sscrfields-ucomm.
    WHEN 'CHANGE_LIGHT'.
      FIELD-SYMBOLS: <fs_return> TYPE ddshretval.
      DATA: li_return TYPE TABLE OF ddshretval,
            l_fields  TYPE ty_fields,
            li_fields TYPE tt_fields.
      SELECT id
          FROM icon
          INTO TABLE li_fields
          WHERE id IN ('@08@','@09@','@0A@').
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield   = 'ICON'
          dynpprog   = sy-repid
          dynpnr     = sy-dynnr
          value_org  = 'S'
        TABLES
          value_tab  = li_fields
          return_tab = li_return.
      READ TABLE li_return ASSIGNING <fs_return>
      INDEX 1.
      IF sy-subrc EQ 0.
        p_comp = <fs_return>-fieldval.
      ENDIF.
  ENDCASE.

0 Kudos
1,115

Thanks Sandra, it's a good idea, but they want it as a select-option.

Now it seems that they don't care if they can't see the icon 🙂

0 Kudos
1,115

OK. It's not feasible to have an icon in an input field. Anyway SAP GUI is not HTML, so the client requirement should ask only for visual rendering that is known as being feasible.