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: 

hello

Former Member
0 Kudos

can fe fill a color in internal table or we can set a picture in it

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can set the color codes and icon codes in your internal table, that's it. The color and icons will show when using the ALV grid over your internal table, but the internal table will have only the internal code for line color and icons.

Regards,

Rich Heilman

0 Kudos

sir how to use alv grid

0 Kudos

Use the FM reuse_alv_grid_display. Other useful FMs are reuse_alv_fieldcatalog_merge and so on - please refer to the extensive help available in the FM reuse_alv_grid_display or reuse_alv_list_display for details.

0 Kudos

HEre is an example program which uses line color in ALV as well as icons.



report zrich_0004
       no standard page heading.

type-pools: slis, icon..

data: fieldcat type slis_t_fieldcat_alv.

data: begin of imara occurs 0,
      light(4) type c,
      matnr type mara-matnr,
      mtart type mara-mtart,
      maktx type makt-maktx,
      color_line(4) type c,
      tcolor type slis_t_specialcol_alv,  "cell
      end of imara.

data: xcolor type slis_specialcol_alv.

start-of-selection.

  perform get_data.
  perform write_report.


************************************************************************
*  Get_Data
************************************************************************
form get_data.

  write icon_green_light as icon to imara-light.
  imara-matnr = 'ABC'.
  imara-mtart = 'ZCFG'.
  imara-maktx = 'This is description for ABC'.
  append imara.

  write icon_yellow_light as icon to imara-light.
  imara-matnr = 'DEF'.
  imara-mtart = 'ZCFG'.
  imara-maktx = 'This is description for DEF'.
  append imara.

  write icon_red_light as icon to imara-light.
  imara-matnr = 'GHI'.
  imara-mtart = 'ZCFG'.
  imara-maktx = 'This is description for GHI'.
  append imara.

  loop at imara.

    if sy-tabix = 1.
      imara-color_line = 'C410'.   " color line
    endif.

    if sy-tabix = 2.          "color CELL
      clear xcolor.
      xcolor-fieldname = 'MTART'.
      xcolor-color-col = '3'.
      xcolor-color-int = '1'. "Intensified on/off
      xcolor-color-inv = '0'.

      append xcolor to imara-tcolor.

    endif.

    modify imara.

  endloop.

endform.

************************************************************************
*  WRITE_REPORT
************************************************************************
form write_report.

  data: layout type  slis_layout_alv.

  layout-coltab_fieldname = 'TCOLOR'.
  layout-info_fieldname = 'COLOR_LINE'.

  perform build_field_catalog.

* CALL ABAP LIST VIEWER (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            is_layout   = layout
            it_fieldcat = fieldcat
       tables
            t_outtab    = imara.

endform.

************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.

  data: fc_tmp type slis_t_fieldcat_alv with header line.
  clear: fieldcat. refresh: fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Status'.
  fc_tmp-fieldname  = 'LIGHT'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '4'.
  fc_tmp-icon       = 'X'.
  append fc_tmp to fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Number'.
  fc_tmp-fieldname  = 'MATNR'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '18'.
  append fc_tmp to fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Type'.
  fc_tmp-fieldname  = 'MTART'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '4'.
  append fc_tmp to fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material'.
  fc_tmp-fieldname  = 'MAKTX'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '40'.
  fc_tmp-emphasize = 'C610'.   " color column
  append fc_tmp to fieldcat.

endform.

Regards,

Rich Heilman