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: 

in ALV, how do u get alternate colors in output

Former Member
0 Kudos

In ALV, how do u get alternate colors in output

3 REPLIES 3

former_member583013
Active Contributor
0 Kudos

DATA: GS_LAYOUT TYPE LVC_S_LAYO.

GS_LAYOUT-ZEBRA = 'X'.

  CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING IS_VARIANT       = GS_VARIANT
                 I_SAVE           = X_SAVE
                 I_DEFAULT        = 'X'
                 IS_LAYOUT        = GS_LAYOUT
       CHANGING  IT_FIELDCATALOG  = GT_FIELDCAT
                 IT_SORT          = GT_SORT[]
                 IT_OUTTAB        = GI_ZTBCOMCON[].

Greetings,

Blag.

Former Member
0 Kudos

Hi,

Check the following link:

http://www.sap-img.com/abap/line-color-in-alv-example.htm

Regards,

Bhaskar

Former Member
0 Kudos

For a non OO ALV...

TYPE-POOLS: slis.

DATA: xfield TYPE slis_t_fieldcat_alv,

gs_layout TYPE slis_layout_alv.

In your data structure you have tu put a field for the color, example:

DATA: BEGIN OF xdata OCCURS 1.

DATA: ebeln LIKE ekko-ebeln,

name1 LIKE lfa1-name1,

txz01 LIKE ekpo-txz01,

color_line(4) TYPE c, " <==== this is the color line

END OF xdata.

You have create a form for the layout like this:

FORM init_layout.

gs_layout-info_fieldname = 'COLOR_LINE'. "<==the name of de field of the structure

ENDFORM.

Perform the init_layout in the initialization.

Your call alv function, have to be like this:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_buffer_active = 'X'

i_callback_program = 'YOUR_PROGRAM'

i_callback_user_command = 'USER_COMMAND'

is_layout = gs_layout

it_fieldcat = xfield[]

TABLES

t_outtab = xdata

EXCEPTIONS

program_error = 1

OTHERS = 2.