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: 

CellColor in CL_GUI_ALV_GRID_EXT

Former Member
0 Kudos

Hi everybody,

there are many threads abouts my problem; but I can't make a concludion.

Here is my OUT_TAB:

TYPES: BEGIN OF GS_OUTTAB.
TYPES: CHECKBOX TYPE C.                "field for checkbox
* §B1.Extend your output table by a field to dis- or enable
*     cells for input.
TYPES: CELLTAB TYPE LVC_T_STYL.        "field to switch editability
         INCLUDE STRUCTURE ls_REGIO_CITY_STUR.
TYPES: CellColor TYPE LVC_T_SCOL.        "field to switch editability
TYPES: END OF GS_OUTTAB.

DATA: GT_OUTTAB TYPE GS_OUTTAB OCCURS 0 WITH HEADER LINE.


I try to change the color:

LOOP AT GT_OUTTAB assigning <OUTTAB>.
     CLEAR : wa_lvc_scol.
      wa_lvc_scol-fname = 'CITY_CODE_POST'.    " Column Name to be colored
      wa_lvc_scol-color-col = '3'.         " Color code
      wa_lvc_scol-color-int = '1'.          " Intensify
      wa_lvc_scol-color-inv = '0'.          " Inverse
      APPEND wa_lvc_scol TO <OUTTAB>-CellColor.

ENDLOOP.



   PERFORM BUILD_FIELDCAT CHANGING iT_FIELDCAT.

   GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY(
     EXPORTING
       IS_VARIANT       = LS_VARIANT
       I_SAVE           = 'A'
       IS_LAYOUT        = LS_LAYOUT
       I_STRUCTURE_NAME = 'MYSTRU'
     CHANGING
       IT_OUTTAB        = GT_OUTTAB[]
       IT_FIELDCATALOG               = IT_FIELDCAT
     EXCEPTIONS
       OTHERS           = 1 ).

But nothing happens 🙂

Any ideas?

Regards

mario

1 ACCEPTED SOLUTION

vijay_hariharan
Contributor
0 Kudos

Hi Mario,

As mentioned in the above answers, you need to set the LS_LAYOUT-ctab_fname field with 'CELLCOLOR'.

Just for your better understanding, please check the below SDN link:

http://wiki.sdn.sap.com/wiki/display/Snippets/Color+individual+cells+of+an+ALV+GRID

Hope this helps.

Regards,

Vijay

6 REPLIES 6

former_member195402
Active Contributor
0 Kudos

Hi,

did you set

LS_LAYOUT-ctab_fname = 'CELLCOLOR'.

?

In the layout the column of the color table is required for displaying colors.

Regards,

Klaus

former_member188827
Active Contributor
0 Kudos

Make sure that you give:

  ls_layout-ctab_fname = 'CELLCOLOR'.

Regards

0 Kudos

Hi,

after I added

  ls_layout-ctab_fname = 'CELLCOLOR'.

I get an runtime-error

What happened?

    Error in the ABAP Application Program

    The current ABAP program "SAPLSLVC" had to be terminated because it has

    come across a statement that unfortunately cannot be executed.

Line  SourceCde

  301               ls_layout_local.

  302

  303 ***********************************************************************

  304 * prepare group level tables

  305 ***********************************************************************

  306 * Totals should be given out behind the related items

  307   if rs_layout-totals_bef is initial.

  308     sort rt_grouplevels by index_to ascending

  309                            index_from descending

  310                            level    descending.

  311 * Totals should be given out before the related items

  312   else.

  313     sort rt_grouplevels by index_from ascending

  314                            index_to descending

  315                            level    ascending.

  316   endif.

  317

  318

  319 ***********************************************************************

  320 * carry out global assigns for some subroutines

  321 ***********************************************************************

  322   assign rt_data[]       to <gt_table>.

  323   assign rt_filter_index to <gt_filter>.

  324

  325 ***********************************************************************

  326 * color

  327 ***********************************************************************

  328   if not rs_layout-ctab_fname is initial.

  329     assign component rs_layout-ctab_fname

  330            of structure rt_data to <fs_component>.

>>>>>     lr_type_descr =

  332             cl_abap_typedescr=>describe_by_data( <fs_component> ).

  333     case lr_type_descr->type_kind.

vijay_hariharan
Contributor
0 Kudos

Hi Mario,

As mentioned in the above answers, you need to set the LS_LAYOUT-ctab_fname field with 'CELLCOLOR'.

Just for your better understanding, please check the below SDN link:

http://wiki.sdn.sap.com/wiki/display/Snippets/Color+individual+cells+of+an+ALV+GRID

Hope this helps.

Regards,

Vijay

former_member188827
Active Contributor
0 Kudos

In your internal table, data type of cellcolor should be:

cellcolor  TYPE STANDARD TABLE OF LVC_T_SCOL.

Regards

0 Kudos

LVC_T_SCOL is a table type of line type LVC_S_SCOL.

You shouldn't declare it as TYPE STANDARD TABLE OF LVC_T_SCOL, because it's a table itself.