Application Development 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: 

Colour for the subtotal in ALV

Former Member
0 Kudos

Hi to all.

I am providing subtotals in ALV.

I want to provide colour for the subtotal in ALV output based on condition.

how to provide colour of subtotal based on condition.

Regards

Raadha

4 REPLIES 4

shaik_sajid
Active Contributor
0 Kudos

Hi Radha,

Try these links,it may solve ur problem.

[[]

[]

Edited by: shaik sajid on Jun 2, 2009 12:36 PM

Former Member
0 Kudos

Hello Radha,

Follow the steps.

1. In your output internal table, add one field for color table like:

DATA: BEGIN OF itab.

INCLUDE STRUCTURE sflight.

DATA: ftype(1), <<Field type: I-Item line; T-Total

clrtab TYPE slis_t_specialcol_alv. <<Color table

DATA: END OF itab.

2. Append color table 'clrtab' for total rows:

LOOP AT itab.

IF itab-ftype = 'T'.

CLEAR: wa_clrtab.

  • wa_clrtab-fieldname = ' '. <<Leave blank to paint whole row

wa_clrtab-color-col = 5. "Green

wa_clrtab-color-int = 1.

wa_clrtab-color-inv = 0.

wa_clrtab-nokeycol = 'X'. <<Also paint key columns

APPEND wa_clrtab TO itab-clrtab.

MODIFY itab.

ENDIF.

ENDLOOP.

3. In layout structure build up, add one statement:

e05_ls_layout-coltab_fieldname = 'CLRTAB'.

Hope this gives you some idea and solves your issue

Cheers,

Suvendu

Former Member
0 Kudos

hi

Check this

data :

Cloumn color:

t_fcat type slis_t_fieldcat_alv,

fs_fcat like line of t_fcat.

fs_fcat-do_sum = 'X'.

fs_fcat-emphasize = '500'.

modify t_fcat from fs_fcat transporting do_sum where fieldname = 'PRICE'.

Row color

Set LAYOUT-info_fieldname = 'COLOR'.

thanks

Dharma

venkat_o
Active Contributor
0 Kudos

Hi radha mortha,

If you are getting subtotal by sending sort table through REUSE_ALV_LIST_DISPLAY or REUSE_ALV_LIST_DISPLAY, you can not change the subtotal color by writing some condition.

You can do two things.

1. Based on the condition, you have to decide whether you have to display subtotal or not. If you do not want subtotal on condition, color wont come.

2. You build internal table with subtotals and totals before you send through REUSE_ALV_LIST_DISPLAY. color the particular row. This is possible. See the below code make the row colored.

<pre class="alt2" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 90%; height: 1000px;">

REPORT zvenkat_alv_color_row.

&----


" Declaration

" To get color for row

" 1.Define color variable with length 3 type char in the final internal

" which is displayed

" 2.build layout structure type slis_layout_alv by specifying

" info_fieldname = 'COLOR' and pass layout structure thru FM REUSEALV

" 3.Poplate Final internal with color values for the field COLOR.

----


"types

TYPES:

BEGIN OF t_pa0001,

color(3) TYPE c, "1.Declare this

pernr TYPE pa0001-pernr,

ename TYPE pa0001-ename,

END OF t_pa0001.

"Work area

DATA:

w_pa0001 TYPE t_pa0001.

"Internal tables

DATA:

i_pa0001 TYPE STANDARD TABLE OF t_pa0001.

&----


  • ALV Declarations

----


  • Types Pools

TYPE-POOLS:

slis.

  • Types

TYPES:

t_fieldcat TYPE slis_fieldcat_alv,

t_events TYPE slis_alv_event,

t_layout TYPE slis_layout_alv.

  • Workareas

DATA:

w_fieldcat TYPE t_fieldcat,

w_events TYPE t_events,

w_layout TYPE t_layout.

  • Internal Tables

DATA:

i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,

i_events TYPE STANDARD TABLE OF t_events.

&----


*&START-OF-SELECTION

&----


START-OF-SELECTION .

PERFORM get_data.

PERFORM color_the_row. "Populate Color like this based on ur conditions

&----


*&END-OF-SELECTION

&----


END-OF-SELECTION.

PERFORM fieldcat.

PERFORM layout_build.

PERFORM dispaly .

&----


" Form fieldcat

&----


FORM fieldcat .

CLEAR :

w_fieldcat,i_fieldcat[].

w_fieldcat-col_pos = 1.

w_fieldcat-row_pos = 1.

w_fieldcat-fieldname = 'PERNR'.

w_fieldcat-tabname = 'I_PA0001'.

w_fieldcat-seltext_m = 'Employee No'.

w_fieldcat-no_zero = 'PERNR'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = 2.

w_fieldcat-row_pos = 1.

w_fieldcat-outputlen = '200'.

w_fieldcat-fieldname = 'ENAME'.

w_fieldcat-tabname = 'I_PA0001'.

w_fieldcat-seltext_l = 'ENAME'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

ENDFORM. " fieldcat

&----


*& Form dispaly

&----


FORM dispaly .

DATA :l_program TYPE sy-repid.

l_program = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = l_program

is_layout = w_layout

it_events = i_events

it_fieldcat = i_fieldcat

TABLES

t_outtab = i_pa0001.

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

&----


*& Form get_data

&----


FORM get_data .

DO 20 TIMES.

SELECT pernr ename

FROM pa0001

APPENDING CORRESPONDING FIELDS OF TABLE i_pa0001

UP TO 10 ROWS.

ENDDO.

ENDFORM. " get_data

&----


*& Form layout_build

&----


FORM layout_build .

w_layout-colwidth_optimize = 'X'.

w_layout-zebra = 'X'.

ENDFORM. " layout_build

&----


*& Form color_the_row

&----


FORM color_the_row .

LOOP AT i_pa0001 INTO w_pa0001.

IF sy-tabix > 3.

w_pa0001-color = 'C31'.

MODIFY i_pa0001 FROM w_pa0001 INDEX sy-tabix.

ENDIF.

ENDLOOP.

ENDFORM. " color_the_row

<pre>

Thanks

Venkat