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 problem

Former Member
0 Likes
1,436

i am using cell color in alv

types: begin of ty_tab,

color(3),

cell type slis_t_specialcol_alv, "deep str with fld: 'fieldname','color','nokeycol'*

vbeln type vbap-vbeln,

posnr type vbap-posnr,

matnr type vbap-matnr,

.....

.....

end of ty_tab,

typ_tab type standard table of ty_tab.

data: itab type typ_tab,

wa type ty_tab.

now if i write: loop at itab into wa.

wa-cell-fieldname = 'matnr'.

wa-cell-color-col = 2. "color is a deep str with fld 'col'/'inv'/'int'.**

wa-cell-nokeycol = 'x'.

modify itab from wa transporting cell.

endloop.

i am getting an error that 'cell' is not a part of 'wa'.

pls suggest how to do the cell coloring?

i want to do it with 'types' declaration , not with occurs 0.

12 REPLIES 12
Read only

MrWhan
Participant
0 Likes
1,333

I think you may need to append the deeper table:

instead of modify itab from wa transporting cell.


 wa-fieldname = 'POINTS'.
 wa-color-col = 5.
 APPEND wa TO itab-cell.

Edited by: Ron Mulig on Dec 6, 2010 6:49 PM

Read only

Former Member
0 Likes
1,333

Hi,

Please refer this link for coloring row.

http://wiki.sdn.sap.com/wiki/display/Snippets/ColoringaRowinanALVconditionally

Regards,

Vijeta

Read only

Former Member
0 Likes
1,333
now if i write: loop at itab into wa.
wa-cell-fieldname = 'matnr'.
wa-cell-color-col = 2. "color is a deep str with fld 'col'/'inv'/'int'.**
wa-cell-nokeycol = 'x'.
modify itab from wa transporting cell.
endloop.

I guess your work area name is wa_cell, if it is so

you need to write above as:

now if i write:

loop at itab into wa_cell.

wa_cell-fieldname = 'matnr'.

wa_cell-color_col = 2. "color is a deep str with fld 'col'/'inv'/'int'.

wa_cell-nokeycol = 'x'.

modify itab from wa_cell transporting fieldname color_col nokeycol.

endloop.

Be careful with _ and - , as - means you are accessing a component of.

Regards,

Dep

Read only

0 Likes
1,333

thnx for ur reply

no the work area name is 'wa'. cell is a fld. type slis_t_specialcol_alv.

Read only

Former Member
0 Likes
1,333

I use color in SALV, but it's same concept...put the values into a structure, append that to a table. Then set the color column in your output = the color table, like:

data:  gs_color      type lvc_s_scol,
          gt_color       type lvc_t_scol,
. . .

 gs_color-color-col = 5.
 gs_color-color-int = 0.
 gs_color-color-inv = 0.
. . .
append gs_color to gt_color.
<output table>-color = gt_color.
clear: gt_color, gs_color.

Read only

Former Member
0 Likes
1,333

Hi Surajit,

You have declared itab as a structure.Please declare it as a table.

Read only

Former Member
0 Likes
1,333

Hi,

To color a cell in ALV Grid layout format you can try with this piece code according to your program..

data:

t_fieldcatalog type slis_t_fieldcat_alv,

fs_fieldcatalog like line of t_fieldcatalog,

** Building the field catalog.........*

perform build_fieldcatalog.

Form build_fieldcatalog.

fs_fieldcatalog-fieldname = '<fieldname1>'.

fs_fieldcatalog-seltext_m = '<Short Text of field1>''.

fs_fieldcatalog-col_pos = 1.

fs_fieldcatalog-outputlen = 10.

fs_fieldcatalog-emphasize = 'C100'. " color code

append fs_fieldcatalog to t_fieldcatalog.

clear fs_fieldcatalog.

fs_fieldcatalog-fieldname = '<fieldname2>'.

fs_fieldcatalog-seltext_m = '<Short Text of field2>''.

fs_fieldcatalog-col_pos = 2.

fs_fieldcatalog-outputlen = 10.

fs_fieldcatalog-emphasize = 'C300'. " color code

append fs_fieldcatalog to t_fieldcatalog.

clear fs_fieldcatalog.

ENDFORM.

Hope this code will resolve your problem.

Regards,

Suvajit.

Read only

Former Member
0 Likes
1,333

Hi,

you have declared wa as an internal table without header line. You can't fill the columns directly without a work area!

Regards.

Klaus

Read only

Former Member
0 Likes
1,333

Hai,

You need to append this way:

Declare a Work area for the Color Table 'Cell'.

Data:
 wa_cell type slis_specialcol_alv.

Loop at itab into wa.
wa_cell-fieldname = '' 
wa_cell-color-col    = ''
wa_cell-nokeycol  = ''
append wa_cell to wa-cell. 
Modify itab from wa.
Endloop.

Best Regards,

rama

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,333

Hi,

As suggested already, this is the way.

Declare internal table for color.

Data : color TYPE lvc_s_scol. "For cell color

clear color.

color-fname = 'MATNR'. "Should be in capital letter

color-col = '5'.

color-int = '1'.

color-inv = '1'.

APPEND color TO wa-color.

MODIFY itab FROM wa INDEX 7 TRANSPORTING color.

Read only

chandra_sekhar3
Explorer
0 Likes
1,333

Hi,

Cell coloring for declare type as cell_colour TYPE lvc_s_scol " for cell colour

and declare as type TYPE-POOLS: slis. "ALV Declarations

In type- pools : slis, cell_colour type is there.

You want more clarification then follow this link. cell color alv program is there.

http://www.sap-basis-abap.com/abap/color-a-column-value-in-alv-report.htm

I hope it helps for u.

Edited by: chandrasek on Dec 19, 2010 3:27 PM

Read only

Clemenss
Active Contributor
0 Likes
1,333

Hi saurajit,

"alv problem" is no very good subject,...

in your definition

types: begin of ty_tab,
color(3),
cell type slis_t_specialcol_alv, "deep str with fld: 'fieldname','color','nokeycol'*
vbeln type vbap-vbeln,
posnr type vbap-posnr,
matnr type vbap-matnr,
.....
.....
end of ty_tab,

slis_t_specialcol_alv is an internal table without header line.

You could have copied the error message you got. It was not "'cell' is not a part of 'wa'."

To change only what is required, do like this

field-symbols:
  <cell_row> type line of slis_t_specialcol_alv,

loop at itab into wa.
  append initial line to wa-cell assigning <cell_row>,
  <cell_row>-fieldname = 'MATNR'."Use upper case
  <cell_row>-color-col = cl_gui_resources=>list_col_total. "This is yellow, use cl_gui_resources=> constants
  <cell_row>-nokeycol = 'X'.
  modify itab from wa transporting cell.
endloop.

Regards,

Clemens