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: 

ADDING COLORS TO ROWS AND HEADING

Former Member
0 Kudos

Dear all,

in the below code i want colors in rows and colors for heading could any one solve this

<removed_by_moderator>

*data declarations.....

TYPE-POOLS SLIS.

TABLES : T529T ,PA0000.

DATA : LD_COLOR(10) TYPE C.

DATA : GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV.

Data: is_fieldcat TYPE slis_fieldcat_alv.

  • it_fieldcat TYPE table of slis_fieldcat_alv,

  • is_layout TYPE slis_layout_alv.

DATA : GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA : BEGIN OF WA_TABLE,

MASSN TYPE T529T-MASSN,

MNTXT TYPE T529T-MNTXT,

userg type userg,

TOTAL TYPE I ,

begda type begda,

endda type endda,

END OF WA_TABLE,

LINE_COLOR(4) TYPE C,

IT_TABLE LIKE TABLE OF WA_TABLE.

*DATA : LINE_COLOR TYPE C.

DATA : TEMP TYPE C.

*DATA : WA_PA000 LIKE PA0000,

data : LT_PA0000 TYPE TABLE OF PA0000,

LT_PA0000_T typE TABLE OF PA0000 with header line.

DATA : LV_LINES TYPE I.

DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FCAT LIKE LINE OF IT_FCAT.

DATA : IT_EVENTS TYPE SLIS_T_EVENT,

WA_EVENTS LIKE LINE OF IT_EVENTS.

wa_events-form = 'HEADER'.

WA_EVENTS-NAME = 'TOP_OF_PAGE'.

APPEND WA_EVENTS TO IT_EVENTS.

PERFORM HEADER.

  • select-options...

selection-screen BEGIN OF BLOCK B WITH FRAME TITLE TEXT-003.

select-options : s_date for sy-datum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B.

PERFORM LAYOUT.

*SELECT STATEMENTS....

SELECT t529tMASSN t529tMNTXT INTO TABLE IT_table FROM T529T where SPRSL EQ 'E'.

  • SELECT massn FROM PA0000 INTO TABLE LT_PA0000 WHERE BEGDA GT S_DATE AND ENDDA LT S_DATE.

LOOP AT IT_TABLE INTO WA_TABLE.

select massn from pa0000 into table lt_pa0000 where begda in s_date and massn = wa_table-massn.

*write : / sy-dbcnt. gt s_date-low and endda lt s_date-high

*DESCRIBE TABLE LT_PA0000_t LINES LV_LINES.

move sy-dbcnt to wa_table-total.

  • READ TABLE lt_pa0000 INTO LT_PA0000_T WITH KEY MASSN = wa_TABLE-MASSN BINARY SEARCH.

  • DESCRIBE TABLE LT_PA0000_t LINES LV_LINES.

  • MOVE LV_LINES to wa_TABLE-TOTAL.

MODIFY IT_TABLE FROM WA_TABLE.

*

  • REFRESH : LT_PA0000_t.

  • CLEAR : LV_LINES.

ENDLOOP.

*PERFORM STATEMENTS...

  • PERFORM FCAT USING '1' 'MASSN' 'ACTIONCODE'.

  • PERFORM FCAT USING '2' 'MNTXT' 'ACTION TYPE'.

  • PERFORM fcat USING '3' 'TOTAL' 'TOTAL'.

DEFINE m_fieldcat.

is_fieldcat-fieldname = &1.

is_fieldcat-hotspot = &2.

is_fieldcat-seltext_m = &3.

is_fieldcat-col_pos = &4.

is_fieldcat-outputlen = &5.

append is_fieldcat to it_fcat.

clear is_fieldcat.

END-OF-DEFINITION.

m_fieldcat 'MASSN' 'X' Text-010 '1' '40' .

m_fieldcat 'MNTXT' 'X' Text-009 '2' '50' .

m_fieldcat 'TOTAL' 'x' Text-011 '3' '10' .

*FOR DISPLAYING THE RECORDS...

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

  • IS_LAYOUT = GD_LAYOUT

  • I_CALLBACK_USER_COMMAND = ' '

I_GRID_TITLE = 'REPORT'

  • IS_LAYOUT = IT_LAYOUT

IT_FIELDCAT = IT_FCAT

I_SAVE = 'X'

IT_EVENTS = IT_EVENTS

TABLES

T_OUTTAB = IT_TABLE.

*

*&----


**& Form FCAT

*&----


*FORM FCAT USING FP_COL_POS

  • FP_FIELDNAME

  • FP_SELTEXT_M.

  • WA_FCAT-COL_POS = FP_COL_POS.

  • WA_FCAT-FIELDNAME = FP_FIELDNAME.

  • wa_fcat-seltext_m = fp_seltext_m.

  • APPEND WA_FCAT TO IT_FCAT.

  • ENDFORM.

&----


*& Form HEADER

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM HEADER .

DATA : IT_HEADER TYPE SLIS_T_LISTHEADER,

WA_HEADER LIKE LINE OF it_header.

WA_HEADER-TYP = 'H'.

WA_HEADER-INFO = 'ACTION TYPE REPORT'.

APPEND WA_HEADER TO IT_HEADER.

wa_header-typ = 'S'.

wa_header-key = Text-022.

CONCATENATE s_date-low+6(2) '.'

s_date-low+4(2) '.'

s_date-low(4)

temp

'. TO .'

s_date-high+6(2) '.'

s_date-high+4(2) '.'

s_date-high(4)

INTO wa_header-info SEPARATED BY space.

APPEND wa_header TO it_header.

CLEAR wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_HEADER

I_LOGO = 'HRRU_51050061'.

*select single bstkd into CORRESPONDING FIELDS OF gt_vbkd

*from vbkd where vbeln = rt_outtab-vgbel

*and posnr = '000000'.

*rt_outtab-bstkd = gt_vbkd-bstkd.

ENDFORM. " HEADER

&----


*& Form LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM LAYOUT .

GD_LAYOUT-NO_INPUT = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'TOTALS'(201).

GD_LAYOUT-INFO_FIELDNAME = 'LINE_COUNT'.

ENDFORM. " LAYOUT

Edited by: Julius Bussche on Oct 2, 2008 12:25 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Its not possible to change the colour of the heading, however to change the colour of the row,

refer to the following [code sample|http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm]

regards,

Advait

4 REPLIES 4

Former Member
0 Kudos

Hi,

Its not possible to change the colour of the heading, however to change the colour of the row,

refer to the following [code sample|http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm]

regards,

Advait

0 Kudos

I want in this code please try it i couldn't get that..

Thanks.

Thiru

0 Kudos

Hi,

The example I have given is fairly simple to understand, please go through carefully and you will get an idea of how it is done.

In your layout, the fieldname that you have mentioned for the colour is GD_LAYOUT-INFO_FIELDNAME = 'LINE_COUNT'., shouldn't it be LINE_COLOUR instead ?

To set the color to your rows, Populate color variable (LINE_COLOUR) with colour properties whiel you are looping at IT_TABLE INTO WA_TABLE. as follows :

  • Char 1 = C (This is a color property)

  • Char 2 = 3 (Color codes: 1 - 7)

  • Char 3 = Intensified on/off ( 1 or 0 )

  • Char 4 = Inverse display on/off ( 1 or 0 )

  • i.e. wa_table-line_color = 'C410'

Concatenate these 4 characters together and move them to LINE_COLOUR.

Hope this helps

regards,

Advait

0 Kudos

Hi,

If the fields is more that 8 only colors for different rows is possible.. in my report there is only 4 columns..

so for that what can i do..

Thanks,

Thiru