04-06-2005 9:28 AM
Hi all,
My requirement is to color the last records in ALV Grid as it displays the total . i need to color with yellow. can any body give a sample prg. which illustrates the same in ALV Grid .Am Using
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' and i can only be.
Thanks
Senthil
04-06-2005 10:43 AM
search the forum. This has been discussed many times here.
If you can't find, getback.
Regards
Raja
04-06-2005 11:00 AM
Hi,
declare your output table like this.
DATA: BEGIN OF i_data OCCURS 10,
matnr type mara-matnr,
ws_color(4),
END OF i_data.
Then find the row no. in which you have to colour it yellow.
LOOP AT i_data.
cnt = cnt + 1.
IF cnt = 1."Here line 1
i_data-ws_color = 'C311'.
MODIFY i_data.
endif.
endloop.
C311 :
In that 'C' signifies colour
'3' signifies yellow color [ 1-7 allowed]
'1' intensify [ 1 -on, 0 off]
'1' display [ 1 -on, 0 off]
In layout , insert this coding
<i_layout>-info_fieldname = 'WS_COLOR'.
try this.
Regards,
J.Jayanthi
04-06-2005 11:23 AM
The steps for coloring a line .
Hi,
Try this out.
To color a line the structure of the table must include a Char 4 field for color properties
TYPES: BEGIN OF struct.
INCLUDE STRUCTURE table.
Field for line color
types: line_color(4) type c.
TYPES: END OF struct.
TYPES: ty_struct TYPE STANDARD TABLE OF struct.
DATA: i_struct TYPE ty_struct.
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 i_struct INTO wa_struct.
IF -
.
wa_struct-line_color = 'C610'(this is for red color change accordingly for yellow, hope try 310).
ENDIF.
MODIFY i_struct FROM wa_struct.
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 = 'table'
is_layout = gs_layout
CHANGING it_outtab = i_struct.
Hope this works.
Regards,
Judith
Message was edited by: Judith Jessie Selvi
04-06-2005 1:30 PM
Hi Jayanthi,
I got the output . Thanks for the information. I have a question ? can we bold some Field values (Cells) in ALV.
Thanks
Senthil
04-06-2005 1:39 PM
Hi,
try this code while building field catalog.
DATA: LINE_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR LINE_FIELDCAT.
LINE_FIELDCAT-FIELDNAME = 'MEINS'.
LINE_FIELDCAT-TABNAME = 'I_MARA'.
LINE_FIELDCAT-SELTEXT_M = 'Base Unit of Measure'.
LINE_FIELDCAT-EMPHASIZE = 'C710'. "Column colur, Bold and Inverse off
APPEND LINE_FIELDCAT TO I_FIELDCAT.
Regards,
J.Jayanthi
04-06-2005 2:11 PM
Hi Jayanthi,
This results in Emphasizing the entire coloum . but i need to bold only the last row. In more details . since there is no option for user defined total .
I need to calculte the total mannualy and add a record a with total at last , which i need to give the color and bold the total.
Thanks
Senthil
04-06-2005 2:29 PM
Hi Senthil
To color individual columns in individual rows first you have to use either class based alv or FM REUSE_ALV_GRID_DISPLAY_LVC (not REUSE_ALV_GRID_DISPLAY) as it accepts advanced field catalog. (So, it won't work on 4.0 and below).
Next, you have to add special COLOR field into the structure of your internal table. The COLOR field must be of type LVC_T_SCOL. Actually it's a table if color descriptors for particular columns in each row.
Next, you have to assign the name of the COLOR field to the layout ctab_fname field.
Finally, you have to set colors for every row in your internal table you want to display via alv.
10-28-2005 5:22 PM
I have just created a dynamic table and i´d like to know how can i refer/link this structure ( LVC_S_SCOL ) in that dynamic table ? this table is used in alv grid and the LVC_S_SCOL structure is to set color in only one cell...
Thanks.
05-10-2007 2:58 PM
Hi,
you must distinuish between 3 Scenarios fpr coloring:
1) Coloring entire column
To make an entire column be painted with the color you want, you can use the "emphasize" option of the field catalog. Simply assign a color code to this field of the row added fpr your column. Color codes are constructed as follows:
Cxyz:
x: 1-7 (1 for example is gray-blue, 6 is red)
y: intensified on/off
z: inverse on/off
e.g. C600 is red inverse off and intensified off.
2) Coloring an entire row
Coloring a row is a bit more complicated. to enable row coloring, you should add an additional field to your list data table. It should be of character type and at least 4 bit long. Thisfield will contain the color code for the row. So for example:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE <your structure>.
DATA rowcolor(4) TYPE c.
DATA: END OF gt_list.
As you guess, you should fill the color code to this field. Its format is as explained before. For second you must pass the name of the field to the layout structure:
e.g. ps_layout-info_fname = 'ROWCOLOR'.
3) Coloring individual cell:
Likely coloring rows, you must append a internal table to each line of gt_list containing the color information:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE <your structure>.
DATA cellcolors TYPE lvc_t_scol.
DATA: END OF gt_list.
If you want to modify the cell in the 5 row and the 2 column, you have to set:
DATA: cellcolor type line of lvc_t_scol.
READ TABLE gt_list INDEX 2.
cellcolor-fname = <name of the second field in your structure>'.
cellcolor-color-col = '6'.
cellcolor-color-int = '0'.
APPEND cellcolor TO gt_list-cellcolors.
modify GT_LIST INDEX 5.
As like coloring rows, you have to pass the info for coloring cell to the layout-structure:
ps_layout-info_ctab_fname = 'CELLCOLOR'.
Beset regards + hope this help + don't forget the point,
Stefan
05-10-2007 3:11 PM
Hi,
Color codes are
constructed as follows:
<i>Cxyz
x:Colornumbers
y:1/0:inverseon/off
z:1/0:intensifiedon/off</i>
<i>Color numbers are:
x color intended for
1 gray-blue headers
2 light gray list bodies
3 yellow totals
4 blue-green key columns
5 green positive threshold value
6 red negative threshold value
7 orange Control levels</i>
Check the following code:
GD_LAYOUT-info_fieldname = 'LINE_COLOR'.
LOOP AT ITab.
IF ITab-fieldname = 'TOTAL'.
MOVE 'C700' TO ITab-LINE_COLOR .
ENDIF.
MODIFY ITab .
CLEAR ITab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = 'ZRPMSLM'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP1'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
<b>IS_LAYOUT = GD_LAYOUT</b>
IT_FIELDCAT = ITFLD1[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITEQ1
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.
ENDLOOP.
Hope this helps.
reward if helpful.
Regards,
Sipra