Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

questions about ALV object model

Hi,

for a new report i´m planing to use the "new" ALV object model to create the ALV list. Now I´ve got two questions concerning this topic:

- is it possible to switch the ALV into the edit mode like it´s possible if the "old" CL_GUI_ALV_GRID class

is used?

- how I can encolor specific cells?

I couldn´t find any hints or demo programms for these questions

Regards,

Andy

Tags:
replied

It is not possible to do an editable ALV with the ALV object model. You can color a line or a cell like this.

REPORT  zrich_0001.

TYPE-POOLS: icon, col.

TYPES: BEGIN OF t_t000.
        INCLUDE STRUCTURE t000.
TYPES: lt_colors TYPE lvc_t_scol.
TYPES: END OF t_t000.

DATA: lt_t000 TYPE TABLE OF t_t000.
DATA: ls_t000 LIKE LINE OF lt_t000.
DATA: ls_colors LIKE LINE OF ls_t000-lt_colors.

DATA: gr_alv TYPE REF TO cl_salv_table.
DATA: gr_columns TYPE REF TO cl_salv_columns_table.

START-OF-SELECTION.
* retrieve data into internal table
  SELECT * FROM t000
    INTO CORRESPONDING FIELDS OF TABLE lt_t000.

* Color a line
  LOOP AT lt_t000 INTO ls_t000.
    IF sy-tabix = 1.
      CLEAR ls_colors.
*Leave FNAME blank, it will color the line, give a field name like MANDT, *it will color that cell of the line only.
      ls_colors-fname = ''.       "'MANDT'.
      ls_colors-color-col = col_positive.
      ls_colors-color-int = 1.
      APPEND ls_colors TO ls_t000-lt_colors.
    ENDIF.
    MODIFY lt_t000 FROM ls_t000.
  ENDLOOP.

  cl_salv_table=>factory(
      IMPORTING
        r_salv_table = gr_alv
      CHANGING
        t_table      = lt_t000 ).

  gr_columns = gr_alv->get_columns( ).
  gr_columns->set_color_column( value = 'LT_COLORS' ).
  gr_alv->display( ).

Regards,.

Rich Heilman

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question