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

alv grid control

Former Member
0 Likes
625

Is it possible to change to bolded red text a row in a alv grid control? (class cl_gui_alv_grid)

As I know, it's not possible.

Could anyone confirm this? If it is possible, how to do it?

Thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
589

hi,

I think it is possible

check all the below links and information, might be useful for you

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

Coming to Colors in ALV's. Following links would help you.

color of a value in a cell

1. Not only the full row color,

we can also manipulate the color in each cell.

2.

IMPORTANT THINGS

a. Extra field in internal table

clr TYPE slis_t_specialcol_alv,

(this field will contain the colour codes)

b. assign fieldname to alv layout

alvly-coltab_fieldname = 'CLR'

c. work area for colour

DATA : clrwa TYPE slis_specialcol_alv.

d. Populating the color

Once again

Loop at ITAB.

*********logic

if itab-field < 0 "---negative

clrwa-fieldname = 'FIELDNAME'. "<--- FIELDNAME FOR COLOR

clrwa-color-col = 6. <------- COLOUR 0-9

APPEND clrwa TO itab-clr.

MODIFY ITAB.

endif.

ENDLOOP.

*----


5. just copy paste in new program

6.

REPORT abc .

*----


NECESSARY / MUST

TYPE-POOLS : slis.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

*----


ITAB DECLARATION

DATA : prg TYPE sy-repid.

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : clname(3) TYPE c,

clr TYPE slis_t_specialcol_alv,

END OF itab.

DATA : clrwa TYPE slis_specialcol_alv.

PARAMETERS : a TYPE c.

DATA : flname TYPE slis_fieldname.

*----


SELECT

START-OF-SELECTION.

SELECT * FROM t001

INTO CORRESPONDING FIELDS OF TABLE itab..

LOOP AT itab..

IF SY-TABIX <= 5.

itab-clname = 'C50'.

ELSE.

itab-clname = 'C30'.

ENDIF.

MODIFY itab.

ENDLOOP.

LOOP AT ITAB.

check itab-bukrs = '1000'

.

clrwa-fieldname = 'BUTXT'.

clrwa-color-col = 6.

APPEND clrwa TO itab-clr.

MODIFY ITAB.

clrwa-fieldname = 'LAND1'.

clrwa-color-col = 4.

APPEND clrwa TO itab-clr.

MODIFY ITAB.

ENDLOOP.

prg = sy-repid.

flname = 'CLNAME'.

  • alvly-info_fieldname = 'CLNAME'.

alvly-coltab_fieldname = 'CLR'.

LOOP AT ITAB.

if sy-tabix = 3.

clrwa-fieldname = 'BUTXT'.

clrwa-color-col = 6.

APPEND clrwa TO itab-clr.

MODIFY ITAB.

clrwa-fieldname = 'LAND1'.

clrwa-color-col = 1.

APPEND clrwa TO itab-clr.

MODIFY ITAB.

endif.

ENDLOOP

.

*

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = prg

i_internal_tabname = 'ITAB'

i_inclname = prg

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


minimum

*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

  • EXPORTING

  • it_fieldcat = alvfc

  • TABLES

  • t_outtab = itab

  • EXCEPTIONS

  • program_error = 1

  • OTHERS = 2

*.

*----


extra

sy-uname = 'XYZAB'.

prg = sy-repid.

*----


Excluding

DATA : excl TYPE slis_t_extab.

DATA : exclwa TYPE slis_extab.

exclwa = '&OUP'.

APPEND exclwa TO excl.

exclwa = '&ODN'.

APPEND exclwa TO excl.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid

is_layout = alvly

i_callback_user_command = 'ITAB_USER_COMMAND'

it_excluding =

excl

i_save = 'A'

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

&----


*& Form itab_user_command

&----


  • text

----


  • -->WHATCOMM text

  • -->WHATROW text

----


FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

BREAK-POINT.

ENDFORM. "itab_user_command

~~Guduri

Read only

Former Member
0 Likes
589

hi

You can do this...If this field is being input by the user and you want to make it Bold and Red, then use method grid->CHECK_CHANGED_DATA.

This contains a class of type ref to cl_alv_changed_data_protocol.

CALL METHOD er_data_changed->add_protocol_entry

EXPORTING

i_msgid = sy-msgid

i_msgty = sy-msgty

i_msgno = sy-msgno

i_msgv1 = sy-msgv1

i_msgv2 = sy-msgv2

i_msgv3 = sy-msgv3

i_msgv4 = sy-msgv4

i_fieldname = l_mod_cell-fieldname (fieldname)

i_row_id = l_mod_cell-row_id (particular row)

i_tabix = l_mod_cell-tabix

.

It will make that field Red and Bold if you give sy-msgty as 'E'.

Regards

Navneet

Read only

0 Likes
589

Thanks to all.

Navneet, if the field is calculated and not input by the user?

Read only

0 Likes
589

I'd like the <b>text</b> of row to be red and bold.

Read only

Former Member
0 Likes
589

Solved thanks to this thread: