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: 

zebra color in alv list

Former Member
0 Kudos

Hi,

1. Is it possible to change default color (blue) of header column for REUSE_ALV_LIST_DISPLAY ?

2. Is it possible to change zebra color (blue / light blue) on alv list ? I dont want to use, info_fieldname for ls_layout property but change default colors for zebra option.

thx

5 REPLIES 5

Former Member
0 Kudos

HI,

data: fs_layout type slis_layout_alv.

fs_layout-zebra = 'X'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

it_fieldcat = fieldcat

is_layout = fs_layout

tables

t_outtab = ialv.

endform.

IF HELPFUL REWARD SOME POINTS.

WITH REGARDS,

SURESH ALURI.

Former Member
0 Kudos

Hello M K,

You can get the zebra coloring. Use the following line. in the layout of the alv there is a filed called ZEBRA. You need to check that filed using 'X'.

g_r_layout-zebra = 'X'.

For reference go through the following program.

report z_alv_ex1 .

*SET TITLEBAR 'T_MATNR'.

*----


  • TYPE-POOLS

*----


type-pools: slis. " Type pool for ALV

*----


  • TABLE USED

*----


tables: mara, " General Material Data

makt, " Material Descriptions

mard, " Storage Location Data for Material

marc, " Plant Data for Material

t001w. " Plants/Branches

*----


  • INTERNAL TABLES

*----


data: begin of g_t_itab occurs 0, " TO HOLD

sel type c,

lgort like mard-lgort, " storage location

werks like marc-werks, " plant

labst like mard-labst, " stock

matnr like mara-matnr, " material number

land1 like t001w-land1, " country i.e. branches

end of g_t_itab.

data: begin of g_t_detail occurs 0, " TO HOLD

matnr like mara-matnr, " material number

end of g_t_detail.

data: begin of g_t_makt occurs 0, " TO HOLD

matnr like makt-matnr, " material number

maktx like makt-maktx, " material description

spras like makt-spras, " language key

end of g_t_makt.

data: l_t_makt like makt occurs 0 " internal table with

with header line. " same structure like MAKT

  • Data Fields used for ALV call - Simple List

data: g_f_repid like sy-repid,

g_t_fieldcat type slis_t_fieldcat_alv,

g_r_fieldcat type slis_fieldcat_alv,

g_t_events type slis_t_event,

g_r_events type slis_alv_event,

g_r_layout type slis_layout_alv.

data: g_r_x_variant like disvariant,

g_r_variant like disvariant.

data: g_f_exit(1),

g_f_save(1).

*----


  • SELECTION SCREEN

*----


selection-screen begin of block b1 with frame title text-001.

select-options: s_matnr for mara-matnr,

s_werks for marc-werks.

parameter: p_gerplt as checkbox user-command r1.

selection-screen end of block b1.

*----


  • START OF SELECTION

*----


start-of-selection.

perform get_data.

*----


  • AT SELECTION SCREEN

*----


at selection-screen on s_matnr.

if not ( s_werks is initial ).

perform validation.

endif.

at selection-screen output.

loop at screen.

if screen-group1 eq 'G' and p_gerplt = 'X'.

screen-input = 0.

refresh s_werks.

endif.

modify screen.

endloop.

*----


  • INITIALIZATION

*----


initialization.

perform initial_selection_screen.

*----


  • AT LINE SELECTION

*----


*AT LINE-SELECTION.

  • PERFORM at_line_selection.

*----


  • END OF SELECTION

*----


end-of-selection.

perform set_alv_parameters.

perform display_list.

----


  • FORM get_data *

----


  • ........ *

----


form get_data.

if p_gerplt = 'X'.

select blgort cwerks blabst amatnr d~land1

from mara as a

inner join mard as b

on amatnr = bmatnr

inner join marc as c

on bmatnr = cmatnr

inner join t001w as d

on cwerks = dwerks

into corresponding fields of table g_t_itab

where

a~matnr in s_matnr and

d~land1 eq 'DE'.

else.

select blgort cwerks blabst amatnr

from mara as a

inner join mard as b

on amatnr = bmatnr

inner join marc as c

on bmatnr = cmatnr

into corresponding fields of table g_t_itab

where

a~matnr in s_matnr and

c~werks in s_werks.

endif.

endform.

----


  • FORM set_alv_parameters *

----


  • ........ *

----


form set_alv_parameters.

perform set_fieldcatlog.

  • Events

refresh : g_t_events.

clear : g_r_events.

  • TOP OF PAGE event for standard header

g_r_events-name = 'TOP_OF_PAGE'.

g_r_events-form = 'TOP_OF_PAGE'.

append g_r_events to g_t_events.

  • Attributes for layout

g_r_layout-zebra = 'X'.

g_r_layout-min_linesize = 119.

g_r_layout-colwidth_optimize = 'X'.

  • Field having checkbox

g_r_layout-box_fieldname = 'SEL'.

  • Field havind checkbox internal table name

g_r_layout-box_tabname = 'G_T_ITAB'.

endform.

----


  • FORM display_list *

----


  • ........ *

----


form display_list.

g_f_repid = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

  • i_callback_program = g_f_repid

i_callback_pf_status_set = 'PF_STATUS_SET'

i_callback_user_command = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

is_layout = g_r_layout

it_fieldcat = g_t_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

is_variant = g_r_variant

it_events = g_t_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 = g_t_itab

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.

endform.

----


  • FORM set_fieldcatlog *

----


  • ........ *

----


form set_fieldcatlog.

data: l_r_fieldcat type slis_fieldcat_alv.

clear : g_t_fieldcat,

g_t_fieldcat[].

  • Check - box

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'SEL'.

l_r_fieldcat-col_pos = 1.

l_r_fieldcat-checkbox = 'X'.

l_r_fieldcat-input = 'X'.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Plant

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'WERKS'.

l_r_fieldcat-ref_tabname = 'MARC'.

l_r_fieldcat-ref_fieldname = 'WERKS'.

  • l_r_fieldcat-no_out = ' '.

  • l_r_fieldcat-input = ' '.

  • l_r_fieldcat-key = 'X'.

l_r_fieldcat-col_pos = 2.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Storage Location

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'LGORT'.

l_r_fieldcat-ref_tabname = 'MARD'.

l_r_fieldcat-ref_fieldname = 'LGORT'.

l_r_fieldcat-col_pos = 3.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Material Number

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'MATNR'.

l_r_fieldcat-ref_tabname = 'MARA'.

l_r_fieldcat-ref_fieldname = 'MATNR'.

l_r_fieldcat-col_pos = 4.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

  • Stock (Un Restricted)

l_r_fieldcat-tabname = 'G_T_ITAB'.

l_r_fieldcat-fieldname = 'LABST'.

l_r_fieldcat-ref_tabname = 'MARD'.

l_r_fieldcat-ref_fieldname = 'LABST'.

l_r_fieldcat-col_pos = 5.

append l_r_fieldcat to g_t_fieldcat.

clear l_r_fieldcat.

endform.

----


  • FORM top_of_page *

----


  • ........ *

----


form top_of_page.

write: 'TOP OF PAGE'.

endform.

----


  • FORM user_command *

----


  • ........ *

----


  • --> I_F_UCOMM *

  • --> I_R_SELFIELD *

----


form user_command using i_f_ucomm like sy-ucomm

i_r_selfield type slis_selfield.

if i_f_ucomm = 'DESCR'.

perform display_mat_desc.

endif.

endform.

----


  • FORM pf_status_set *

----


  • ........ *

----


  • --> I_T_EXTAB *

----


form pf_status_set using i_t_extab type slis_t_extab.

set pf-status 'S_MATNR'.

endform.

----


  • FORM display_mat_desc *

----


  • ........ *

----


form display_mat_desc.

read table g_t_itab with key sel = 'X'.

if sy-subrc ne 0.

message e001(00) with text-002.

endif.

clear : g_t_makt.

refresh : g_t_makt.

loop at g_t_itab where sel eq 'X'.

select matnr maktx spras

from makt

appending table g_t_makt

where

matnr eq g_t_itab-matnr.

endloop.

loop at g_t_makt.

write: / g_t_makt-matnr, g_t_makt-maktx, g_t_makt-spras.

endloop.

endform.

----


  • FORM initial_selection_screen *

----


  • ........ *

----


form initial_selection_screen.

s_matnr-sign = 'I'.

s_matnr-option = 'EQ'.

s_matnr-low = '000000000000000012'.

s_matnr-high = ' '.

append s_matnr.

clear s_matnr.

s_matnr-sign = 'I'.

s_matnr-option = 'NE'.

s_matnr-low = '000000000000000002'.

s_matnr-high = ' '.

append s_matnr.

clear s_matnr.

s_matnr-sign = 'I'.

s_matnr-option = 'EQ'.

s_matnr-low = '000000000000000015'.

s_matnr-high ='000000000010000012'.

append s_matnr.

clear s_matnr.

endform.

----


  • FORM validation *

----


  • ........ *

----


form validation.

select single * from marc

where matnr in s_matnr and

werks in s_werks.

if sy-subrc ne 0.

message e047(m3).

endif.

endform.

Reward IF Helpful.

Regards

--

Sasidhar Reddy Matli.

Former Member
0 Kudos

Hi again,

nobody understood me

I know about fs_layout-zebra = 'X' option but if I check it, alv list is collored with blue and light blue color - I want to change this default colors. How can I do it ?

The same about the header of table - head cols are blue - need to change it.

thx

Former Member
0 Kudos

Hi

You need define a field in your table for color, for example:

line_color(4) TYPE c,

And then in your table you assing the color :

it_item-line_color = 'C510'.

Very important in the layout you define:

IT_layout-info_fieldname = 'LINE_COLOR'.

Regards

Gregory

Former Member
0 Kudos

Is my english really so poor ? I said: "I dont want to use, info_fieldname for ls_layout" . I need to change default colors for zebra. When I'm using info_fieldname and set one of column as keyfiled, line_color does not work ,becauce for key column there is defined other , standard ,dark blue color - I need to change default setting of zebra. There are some standard, blue / dark blue etc colors for zebra, I guess they are configured somewhere - I need to find out this place, thx