cancel
Showing results for 
Search instead for 
Did you mean: 

Color the sub-total row in an alv-grid

Former Member
0 Kudos

Hi all.

I work on SAP 4.7 WAS6.20 and output a table with the cl_gui_alv_grid. I´m able to color special rows (or columns) in the alv grid. But I want to color individually the sub-total lines (like the lines before) and don´t want the yellow color for all of the sub-total lines.

Do you know how to color the sub-total-lines?

Thanks a lot.

Michael

Accepted Solutions (0)

Answers (4)

Answers (4)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you can use the following sort of coding,

then you can find the record number for the sub-total.

LOOP AT output into anotherworkarea.

AT END OF new material.

SUM.

...work-area-line = sy-tabix.

APPEND .....

sy-uline.

ENDAT.

ENDLOOP.

Former Member
0 Kudos

Hi Micheal,

This topic has been discussed before also in this Forum. Please check this link:

Regards,

Anjali

Former Member
0 Kudos

Hi Anjali.

It was discussed how to color rows or columns of the output-table. I want to color the sub-total-lines for the alv-grid. This is not so easy, because you have no representative for the sub-tot-line in your output-table you give to the method set_table_for_first_display.

Do you know how to color the sub-total-lines?

Thanks a lot.

Michael

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you are able to find number of records for each sub-totals,then based on the number,you can colour the sub-total.

Suppose you are getting subtotal for four rows.So your sub-total will be your fifth row.

So read the fifth row , and colour it as you want.

Message was edited by: Jayanthi Jayaraman

Former Member
0 Kudos

Hi Jayanthi.

Where can I read the fifth row? The subtotals are not lines in my output-table.

In my program I have no access to the particular subtotal-lines. So it is not so easy to color this line.

Thanks a lot.

Michael

Former Member
0 Kudos

Hi,

U can color an individula row see the link below

Color a line

The steps for coloring a line i the grid is much the same as making a traffic light.

* To color a line the structure of the  table must include a  Char 4 field  for color properties
TYPES: BEGIN OF st_sflight.
        INCLUDE STRUCTURE zsflight.
*       Field for line color
types:  line_color(4) type c.
TYPES: END OF st_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
DATA: gi_sflight TYPE tt_sflight.
* Loop trough the table to set the color properties of each line. The color properties field is 
* Char 4 and the characters is set as follows:
* Char 1 = C = This is a color property
* Char 2 = 6 = Color code (1 - 7)
* Char 3 = Intensified on/of = 1 = on
* Char 4 = Inverse display = 0 = of
     LOOP AT gi_sflight INTO g_wa_sflight.
      IF g_wa_sflight-paymentsum < 100000.
        g_wa_sflight-line_color    = 'C610'.
      ENDIF.
      MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
* Name of the color field
gs_layout-info_fname = 'LINE_COLOR'.
* Grid setup for first display
 CALL METHOD go_grid->set_table_for_first_display
      EXPORTING i_structure_name = 'SFLIGHT'
                             is_layout                = gs_layout
      CHANGING  it_outtab                 = gi_sflight

see the link

http://www.sapgenie.com/abap/controls/alvgrid.htm