cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Column Texts for an ALV Grid Control.

Former Member
0 Likes
852

Hi all,

I would like to know if it is possible to display an icon along with the column text in my ALV Grid. I'm using the class CL_GUI_ALV_GRID.

I am able to display either an icon or some text but not both on the column header.

Example code which has <i><b>not</b></i> worked for me:

1. If I use : CONCATENATE '@06@' 'Text' INTO COLTEXT.

The column header just shows the icon (corresponding to the code @06@).

2. If I use : CONCATENATE 'Text' '@06@' INTO COLTEXT.

The column header shows up as : Text @06@.i.e., the icon code is not being recognized and is showing up as text.

Hope I'm clear in expressing my doubt.

Thanks very much,

Anand Mandalika.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Likes

HI:

please use this solution and try it.

1. creat the field for icon with iconname (frist you must type-pool:icon.)

2. assign value to icon.The value is like '@08Qconfirm@'.

So you can get you want.If you get it ,please send mail to me: songzc3@sohu.com

Former Member
0 Likes

Hi Song Zhi Chong,

I think I would like to make a small correction to your solution.

In the field catalog, if you set the field ICON to 'X', the column contents of the output table are output as an icon. However,the column contents must themselves contain a valid icon string - @06@ or @06\Q<i>Information</i>@. In the latter case, the column contents will get the text "Information" as Quick Info. I understand that is what the \Q means.

Please do correct me if I'm wrong.

Former Member
0 Likes

Hi there,

Not sure if you are still trying to get this to work but I have just managed to get it to work using the method described on http://www.sapdevelopment.co.uk/reporting/selscr/but_buticon.htm

Here is the code:

&----


*& Report ZSSCRBUTTONS2 *

*& *

&----


*& Adds buttons to selection screen. *

*& Demonstrates alteration of selection screen layout depending on *

*& which button is pressed. *

*& *

*& Additional Info: *

*& TEXT-FY1 = 'Fiscal Year' *

*& Selection text for SO_DATES = 'Date Period' *

&----


REPORT zsscrbuttons2.

TABLES: sscrfields.

DATA: gd_ucomm TYPE sy-ucomm.

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid.

DATA: icon_name TYPE iconname,

button_text(20) TYPE c,

quickinfo LIKE smp_dyntxt-quickinfo,

icon_str(255) TYPE c.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

  • Setup button 1 (Fiscal year)

icon_name = 'ICON_ARROW_RIGHT'. " 'ICON_DISPLAY_MORE'.

button_text = 'Fiscal Year'.

CONCATENATE button_text text-akt

INTO quickinfo

SEPARATED BY space.

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = icon_name

text = button_text

info = quickinfo

  • ADD_STDINF = 'X'

IMPORTING

RESULT = icon_str

EXCEPTIONS

OTHERS = 0. "not interested in errors

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report (www.sapdev.co.uk)

----


form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = icon_str.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

  • i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

  • i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

tables

t_outtab = it_ekko

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. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

endform. " DATA_RETRIEVAL

Former Member
0 Likes

Hi Mart,

I have almost given up on this one and told my customer that it would not be possible.

I do not doubt it for a moment when you say that it had worked for you, but unfortunately the code that you have given still does not work. At least it doesn't work on my system !!

If I run it, I still get only the icon on the column header. The text does not appear. In case you have run the program and have been able to get it work, please do re-verify once again. If you confirm that it works for you, then there might be some problem with my SAPGUI. May be I need to apply some patches or something which I will worry about later.

Thanks very much for the interest you have shown to respond to this question.

Regards,

Poornanand Mandalika.

Former Member
0 Likes

Doh! please except my appologies, for some reason i had got it into my head that you simply wanted to display an icon in the colum header and not the text as well.

Is there any way of creating new icons, if so you could create one with the icon and text you want and then add that.

sorry again

Regards

Martin

Former Member
0 Likes

Hello,

Thanks to <u>Rich Heilman</u> and <u>Mart</u> for your responses.

Unfortunately none of the two solutions worked for me. The problem that I had originally had still persists.

RichHeilman
Developer Advocate
Developer Advocate
0 Likes

Hmmm....you would think that you can do it, but I can't seem to get it to work as well. Have you ever seen this done in Standard SAP or someone else's program? Maybe ALV is not set up to handle that.

Regards,

Rich Heilman

Former Member
0 Likes

Hello Mr.Heilman,

I have not ( yet ) seen such a display in any of the Standard SAP screens that I have come across.

But well, I got this requirement, and I thought it should be possible to do it. If you have several columns which contain some values, then it is reasonable for the user to expect to see the overall status derived from the values in the column in the column-header. Don't you think so ?

Former Member
0 Likes

Not sure if this will work the same for the ALV column, but here is some code which adds an icon to a selection screen button using the function module ICON_CREATE.

http://www.sapdevelopment.co.uk/reporting/selscr/but_buticon.htm

RichHeilman
Developer Advocate
Developer Advocate
0 Likes

Have you tried this yet?

WRITE ICON_DISPLAY AS ICON TO ICONBUTTON.

CONCATENATE ICONBUTTON 'Display' INTO ICONBUTTON

SEPARATED BY SPACE.

Regards,

Rich Heilman