Skip to Content
0
Former Member
Jan 12, 2006 at 08:14 AM

color in 1 cell in REUSE_ALV_GRID_DISPLAY

287 Views

i made what you say an d have problem help pls.

data : begin of itab1 occurs 0,

matnr like vbap-matnr,

MAKTX like MAKT-MAKTX,

netwr like VBAP-NETWR,

kwmeng like vbap-kwmeng,

BWTAR like VBAP-BWTAR,

z_netwr_sk like VBAP-NETWR,

verpr LIKE MBEW-VERPR,

z_count like VBAP-KWMENG,

z_cost like VBAP-KWMENG,

z_calc like VBAP-KWMENG,

end of itab1.

data : begin of itab2 occurs 0,

matnr like vbap-matnr,

MAKTX like MAKT-MAKTX,

  • z_pstyv like vbap-pstyv,

netwr like VBAP-NETWR,

z_netwr_sk like VBAP-NETWR,

kwmeng like vbap-kwmeng,

BWTAR like VBAP-BWTAR,

verpr LIKE MBEW-VERPR,

z_count like VBAP-KWMENG,

z_cost like VBAP-KWMENG,

z_calc like VBAP-KWMENG,

  • z_calc TYPE slis_t_specialcol_alv,

COLOR_LINE TYPE slis_t_specialcol_alv,

loop at itab1.

clear itab2.

move-corresponding itab1 to itab2.

append itab2.

endloop.

*

Loop at ITAB2.

*********logic

if itab2-Z_CALC < 0 ."---negative

clrwa-fieldname = 'Z_CALC'. "<--- FIELDNAME FOR COLOR

clrwa-color-col = '5'.

APPEND clrwa TO itab2-COLOR_LINE.

MODIFY ITAB2.

endif.

ENDLOOP.

L_LAYOUT-info_fieldname = 'COLOR_LINE'.

*append l_layout.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

is_layout = l_layout

it_fieldcat = i_fieldcat[]

i_save = 'A'

is_variant = is_variant

it_events = gt_events[]

TABLES

t_outtab = itab1 "

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

FORM aufbauen_fieldcat USING p_fieldname

p_ref_tabname

p_name

p_sum

p_emp.

i_fieldcat-fieldname = p_fieldname .

i_fieldcat-ref_tabname = p_ref_tabname .

i_fieldcat-reptext_ddic = p_name .

i_fieldcat-seltext_l = p_name .

i_fieldcat-seltext_m = p_name .

i_fieldcat-seltext_s = p_name .

i_fieldcat-do_sum = p_sum .

i_fieldcat-emphasize = p_emp .

APPEND i_fieldcat .

ENDFORM. " AUFBAUEN_FIELDCAT

thanks.