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

Display icon in alv report ?

Former Member
0 Likes
22,020

Hi All,

I am using class 'cl_gui_alv_grid' to generate an alv report. I want to display status icons like red, yellow and green in one of the coulmns. Please let me know how to achieve the same.

Regards,

Navneeth K.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
13,327

Declare a field type CHAR4 on Your ALV list and assign icon code to it like below.

ALV_LIST-ICON = '@5B@'. "green icon

ALV_LIST-ICON = '@5C@'. "red icon

Regards

Hi All,

I am using class 'cl_gui_alv_grid' to generate an alv report. I want to display status icons like red, yellow and green in one of the coulmns. Please let me know how to achieve the same.

Regards,

Navneeth K.

3 REPLIES 3
Read only

Former Member
0 Likes
13,328

Declare a field type CHAR4 on Your ALV list and assign icon code to it like below.

ALV_LIST-ICON = '@5B@'. "green icon

ALV_LIST-ICON = '@5C@'. "red icon

Regards

Read only

Former Member
0 Likes
13,327

Try to follow the below code.

Add

icon TYPE icon-id, "Status

to your output table

*----


  • Constants

*----


CONSTANTS: c_green TYPE icon-id VALUE '@08@',

c_yellow TYPE icon-id VALUE '@09@',

c_red TYPE icon-id VALUE '@0A@'.

Put your condition in which you want to display which color.

IF CONDITION.

MOVE c_yellow TO wa_out-icon.

MODIFY it_out

from wa_out.

ENDIF.

Add it in your catalog

FORM populate_fieldcat USING p_table TYPE c.

**status

CLEAR wa_fieldcat.

wa_fieldcat-tabname = p_table.

wa_fieldcat-fieldname = 'ICON'.

wa_fieldcat-seltext_l = text-010.

wa_fieldcat-outputlen = 15.

wa_fieldcat-icon = 'X'.

APPEND wa_fieldcat TO i_fieldcat.

CALL METHOD g_grid->set_table_for_first_display

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

i_structure_name = 'MARA'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

is_layout = gs_layout

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

it_outtab = it_out[]

  • IT_FIELDCATALOG = T_FIELDCAT

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

Read only

Former Member
0 Likes
13,327

Hi,

While building the field catalog give the particular filed in internal table ICON_GREEN_LIGHT ,ICON_YELLOW_LIGHT,

ICON_RED_LIGHT.

for example :

lv_fieldcat-icon= ICON_RED_LIGHT

append ls_fieldcat.

If you want to display only one light

lv_fieldcat-icon= ICON_LED_GREEN.

append ls_fieldcat.

similarly ICON_LED_RED,ICON_LED_YELLOW for red and yellow lights.

Check the TCODE ICON for different icons.

Regards,

Priyanka.