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

ICON display in ALV output

Former Member
0 Likes
13,373

Hi,

I need to create a column that will have an icon ICON_DOCUMENT displayed in the column. Now, when i clik on this icon it should check for the existance of any links existing for a material , if so, then display those links . Basically this icon should dispaly the link to material drawings . How do i include the icon in the output column in ALV?

Thanks,

Sindhu.

1 ACCEPTED SOLUTION
Read only

Former Member
4,284

Hi sindhu,

Check ICON table for icons to select in your internal table.

Include this statement in your output internal table.

ICON_FIELD LIKE ICON-ID.

like

DATA: BEGIN OF IT_test OCCURS 0,

ICON_FIELD LIKE ICON-ID,

END OF IT_TEST.

Populate this field with the icon like

IT_test-ICON_FIELD = '@5B@'. "ICON_GREEN_LIGHT

IT_test-ICON_FIELD = '@03@'. "ICON_FAILURE

IT_test-ICON_FIELD = '@5C@'. "ICON_RED_LIGHT

Hence your final internal table will have icons for all fields. now write the code for click on icon using user_command.

form user_command using u_ucomm like sy-ucomm

selfield type slis_selfield.

Hope this helps.

Please award points if helpful.

Regards,

Vivek

Hi,

I need to create a column that will have an icon ICON_DOCUMENT displayed in the column. Now, when i clik on this icon it should check for the existance of any links existing for a material , if so, then display those links . Basically this icon should dispaly the link to material drawings . How do i include the icon in the output column in ALV?

Thanks,

Sindhu.

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
4,284

You can do this simply by declaring a field in the internal table...

data: begin of itab occurs 0,
     <b> icon(4) type c,</b>
        ......

Also add this field to your field catalog, when doing so, make sure to add a line to set the icon field.


fieldcat-fieldname = 'ICON'.
<b>fieldcat-icon = 'X'.</b>
append fielcat to ifieldcat.

Now when filling the internal table, all you need to do is write the icon to the field.

write icon_document as icon to itab-icon.

Also make sure that you have the type-pool statement at the top of your program.

type-pools: icon.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
4,284

hi,

Sample code is ::

*

report zalvexer2 message-id zz .

*& TABLES DECLARATION *

tables: vbak.

*& TYPE POOLS DECLARATION *

&----


type-pools: slis.

&----


*& INTERNAL TABLE DECLARATION *

&----


data: begin of itab occurs 0,

icon type icon-id,

vbeln like vbak-vbeln,

audat like vbak-audat,

vbtyp like vbak-vbtyp,

auart like vbak-auart,

augru like vbak-augru,

netwr like vbak-netwr,

waerk like vbak-waerk,

end of itab.

*INTERNAL TABLE FOR FIELD CATALOG

data: wa_fieldcat type slis_fieldcat_alv,

it_fieldcat type slis_t_fieldcat_alv.

  • IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV

  • WITH HEADER LINE,

*INTERNAL TABLE FOR EVENTS

data: it_event type slis_t_event,

wa_event type slis_alv_event,

*INTERNAL TABLE FOR SORTING

it_sort type slis_t_sortinfo_alv,

wa_sort type slis_sortinfo_alv,

*INTERNAL TABLE FOR LAYOUT

wa_layout type slis_layout_alv.

&----


*& VARIABLE DECLARATION *

&----


data : v_repid type sy-repid,

v_pagno(4) type n,

v_date(8) type c.

&----


*& CONSTANTS *

&----


constants: c_x type c value 'X'.

&----


*& SELECTION SCREEN *

&----


selection-screen: begin of block b1 with frame title text-001.

select-options: s_vbeln for vbak-vbeln,

s_vbtyp for vbak-vbtyp default 'C'.

selection-screen: end of block b1.

selection-screen: begin of block b2 with frame title text-002.

selection-screen : begin of line.

selection-screen comment 1(20) text-003.

parameters: p_list radiobutton group rad1 default 'X'.

selection-screen : end of line.

selection-screen : begin of line.

selection-screen comment 1(20) text-004.

parameters: p_grid radiobutton group rad1.

selection-screen : end of line.

selection-screen: end of block b2.

at selection-screen.

perform validate_screen.

&----


*& START OF SELECTION *

&----


start-of-selection.

clear: itab, itab[].

  • V_REPID = SY-REPID.

perform get_data.

perform display_data.

&----


*& END OF SELECTION *

&----


end-of-selection.

*--DO ALV Process

v_repid = sy-repid.

*--Sort the Output Fields

perform sort_fields.

*--Build Field catalog for the Output fields

  • PERFORM BUILD_FIELDCAT.

*--Set the Layout for ALV

perform set_layout.

&----


*& Form GET_DATA

&----


  • text

----


  • TO GET THE DATA FROM TABLES INTO ITAB

----


form get_data .

select vbeln

audat

vbtyp

auart

augru

netwr

waerk

into corresponding fields of table itab

from vbak

where vbeln in s_vbeln and

audat > '04.04.2005'

and netwr > 0.

<b>loop at itab.

if itab-netwr < 10000.

itab-icon = '@08@'.

elseif itab-netwr > 10000 and itab-netwr < 100000.

itab-icon = '@09@'.

elseif itab-netwr > 100000.

itab-icon = '@0A@'.

endif.

modify itab index sy-tabix.

endloop.</b>

endform. " GET_DATA

&----


*& Form sort_fields

&----


form sort_fields .

clear wa_sort.

wa_sort-fieldname = 'VBTYP'.

wa_sort-spos = '1'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

clear wa_sort.

wa_sort-fieldname = 'NETWR'.

wa_sort-spos = '2'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

append wa_sort to it_sort.

endform. " sort_fields

*

&----


*& Form set_layout

&----


form set_layout .

if p_list = c_x .

wa_layout-window_titlebar = 'LIST DISPLAY'(016).

wa_layout-zebra = 'X'.

*-- ALV LIST DISPLAY

perform list_display tables itab.

*-- ALV GRID DISPLAY

elseif p_grid = c_x.

wa_layout-window_titlebar = 'GRID DISPLAY'(017).

wa_layout-zebra = 'X'.

perform grid_display tables itab.

endif.

endform. " set_layout

&----


*& Form list_display

&----


form list_display tables p_itab .

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = v_repid

is_layout = wa_layout

it_fieldcat = it_fieldcat[]

it_sort = it_sort[]

i_save = 'U'

tables

t_outtab = itab

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " list_display

&----


*& Form GRID_DISPLAY

&----


form grid_display tables p_itab .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = v_repid

is_layout = wa_layout

it_fieldcat = it_fieldcat[]

it_sort = it_sort[]

it_events = it_event

tables

t_outtab = itab

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " GRID_DISPLAY

&----


*& Form VALIDATE_SCREEN

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form validate_screen .

data: lv_vbeln like vbak-vbeln.

if not s_vbeln is initial.

select vbeln

into lv_vbeln

up to 1 rows

from vbak

where vbeln in s_vbeln.

endselect.

if sy-subrc <> 0.

message e000 with 'INVALID SALES DOC'.

endif.

endif.

endform. " VALIDATE_SCREEN

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_data .

define m_fieldcat.

add 1 to wa_fieldcat-col_pos.

wa_fieldcat-fieldname = &1.

wa_fieldcat-ref_tabname = 'VBAK'.

wa_fieldcat-do_sum = &2.

wa_fieldcat-cfieldname = &3.

append wa_fieldcat to it_fieldcat.

end-of-definition.

data:

ls_fieldcat type slis_fieldcat_alv,

lt_fieldcat type slis_t_fieldcat_alv.

m_fieldcat 'ICON' '' ''.

m_fieldcat 'VBELN' '' ''.

m_fieldcat 'AUDAT' '' ''.

m_fieldcat 'VBTYP' '' ''.

m_fieldcat 'AUART' '' ''.

m_fieldcat 'AUGRU' '' ''.

m_fieldcat 'NETWR' 'C' 'WAERK'.

m_fieldcat 'WAERK' '' ''.

endform. " display_data[/code]

Message was edited by: Ashok Parupalli

Message was edited by: Ashok Parupalli

Read only

Former Member
0 Likes
4,284

Hi,

First add a new field in your field catalog and while assigning the data move the relevant icon to the new field as follows(you can get the list of icons from the table "ICON")

FYI, wa_it_mass_item-rmrk = '@0Q@'.

And in the double click method based on the selected colomn you can write the code.

Regards,

Suman

Assign points if useful.

Read only

Former Member
4,285

Hi sindhu,

Check ICON table for icons to select in your internal table.

Include this statement in your output internal table.

ICON_FIELD LIKE ICON-ID.

like

DATA: BEGIN OF IT_test OCCURS 0,

ICON_FIELD LIKE ICON-ID,

END OF IT_TEST.

Populate this field with the icon like

IT_test-ICON_FIELD = '@5B@'. "ICON_GREEN_LIGHT

IT_test-ICON_FIELD = '@03@'. "ICON_FAILURE

IT_test-ICON_FIELD = '@5C@'. "ICON_RED_LIGHT

Hence your final internal table will have icons for all fields. now write the code for click on icon using user_command.

form user_command using u_ucomm like sy-ucomm

selfield type slis_selfield.

Hope this helps.

Please award points if helpful.

Regards,

Vivek

Read only

Former Member
0 Likes
4,284

Hi,

loop at it_vbak.

if it_vbak-netwr < 10000.

it_vbak-indic = '@08@'.

it_vbak-symbl_n = 'C'.

elseif it_vbak-netwr > 100000.

it_vbak-indic = '@0A@'.

it_vbak-symbl_n = 'D'.

else.

it_vbak-indic = '@09@'.

it_vbak-symbl_n = ' '.

endif.

modify it_vbak index sy-tabix.

endloop.

while customizing fieldcat,

loop at it_fieldcat into wa_fieldcat.

case wa_fieldcat-fieldname.

when 'INDIC'.

wa_fieldcat-seltext_l = 'Indicator'.

wa_fieldcat-seltext_m = 'Ind.'.

wa_fieldcat-seltext_s = 'Ind.'.

wa_fieldcat-ddictxt = 'M'.

wa_fieldcat-col_pos = 1.

endcase.

modify it_fieldcat from wa_fieldcat.

endloop.

Regards,

Sailaja.