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: 

ALV Reports

Former Member
0 Kudos

Hi all,

How can we control colors in ALV Reports(i.e for simple & grid control reports),And also what is the use of REUSE_ALV_FIELDCATALOG_MERGE function module.

From,

Sri

1 ACCEPTED SOLUTION

anversha_s
Active Contributor
0 Kudos

hi,

simple chk this link.

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

u willget excellent idea.

rgds

Anver

<b><i>if hlped pls mark points</i></b>

8 REPLIES 8

anversha_s
Active Contributor
0 Kudos

hi,

simple chk this link.

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

u willget excellent idea.

rgds

Anver

<b><i>if hlped pls mark points</i></b>

Former Member
0 Kudos

hi,

Reg REUSE_ALV_FIELDCATALOG_MERGE ,

This function will create a field catalog using a strcture / table in data dictionary (SE11) or an internal table declared in your program.

However, you internal table will have to be declared in the traditional way of having a header line and the fields refrerring with the LIKE.

pls refer this link :

http://www.sap-img.com/fu015.htm

Former Member
0 Kudos

Hi

sridhar

for control of colours see this code

Do as follows

1. declare one field say color in the output table of type SLIS_T_SPECIALCOL_ALV.

2. Also declare a table color like

DATA COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.

3. After you have filled the field catalog do like this,

LOOP AT IT_ALV_DATA.

IF SY-TABIX = 2.

COLOR-FIELDNAME = 'POSNR'.

COLOR-COLOR-COL = 6.

COLOR-COLOR-INT = 0.

APPEND COLOR.

IT_ALV_DATA-COLOR = COLOR[].

MODIFY IT_ALV_DATA.

ENDIF.

ENDLOOP

Function Module REUSE_ALV_FIELDCATALOG_MERGE can built automatically the field catalog needed in ALV list functions.

Suppose you have many fields in your internal table and you want to display each and everyone of them then you can use this FM for generating the fieldcatalog.

For code related to this have a look at below link.

http://www.erpgenie.com/abap/code/abap28.htm

if helpfull allot points

-Regards

charitha.

sreemsft
Contributor
0 Kudos

Hi,

REUSE_ALV_FIELDCATALOG_MERGE will help you to build your fields in your output automatically. If you do not use this Function Module, you need to populate each and every table field manually.

Generally we use this function module if we have more number of fields, otherwise we will populate manually.

Coming to Colors in ALV's. Following links would help you.

Please do not forget to reward points

Thanks,

Sreekanth Gollamudi

Former Member
0 Kudos

hey

check it out may be helpful for you

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

Regards,

Naveen

Former Member
0 Kudos

Hi Sri,

Copy paste the following program for color in ALV


REPORT  zdemo_alvgrid                 .

TABLES:     ekko.

type-pools: slis.                                 "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  statu TYPE ekpo-statu,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
  menge TYPE ekpo-menge,
  meins TYPE ekpo-meins,
  netpr TYPE ekpo-netpr,
  peinh TYPE ekpo-peinh,
  line_color(4) type c,     "Used to store row color attributes
 END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
      wa_ekko TYPE t_ekko.

*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
      gd_tab_group type slis_t_sp_group_alv,
      gd_layout    type slis_layout_alv,
      gd_repid     like sy-repid.


************************************************************************
*Start-of-selection.
START-OF-SELECTION.

perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*       Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.


  fieldcatalog-fieldname   = 'EBELN'.
  fieldcatalog-seltext_m   = 'Purchase Order'.
  fieldcatalog-col_pos     = 0.
  fieldcatalog-outputlen   = 10.
  fieldcatalog-emphasize   = 'X'.
  fieldcatalog-key         = 'X'.
*  fieldcatalog-do_sum      = 'X'.
*  fieldcatalog-no_zero     = 'X'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'EBELP'.
  fieldcatalog-seltext_m   = 'PO Item'.
  fieldcatalog-col_pos     = 1.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'STATU'.
  fieldcatalog-seltext_m   = 'Status'.
  fieldcatalog-col_pos     = 2.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'AEDAT'.
  fieldcatalog-seltext_m   = 'Item change date'.
  fieldcatalog-col_pos     = 3.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MATNR'.
  fieldcatalog-seltext_m   = 'Material Number'.
  fieldcatalog-col_pos     = 4.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MENGE'.
  fieldcatalog-seltext_m   = 'PO quantity'.
  fieldcatalog-col_pos     = 5.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'MEINS'.
  fieldcatalog-seltext_m   = 'Order Unit'.
  fieldcatalog-col_pos     = 6.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'NETPR'.
  fieldcatalog-seltext_m   = 'Net Price'.
  fieldcatalog-col_pos     = 7.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-datatype     = 'CURR'.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.

  fieldcatalog-fieldname   = 'PEINH'.
  fieldcatalog-seltext_m   = 'Price Unit'.
  fieldcatalog-col_pos     = 8.
  append fieldcatalog to fieldcatalog.
  clear  fieldcatalog.
endform.                    " BUILD_FIELDCATALOG


*&---------------------------------------------------------------------*
*&      Form  BUILD_LAYOUT
*&---------------------------------------------------------------------*
*       Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(201).
* Set layout field for row attributes(i.e. color) 
  gd_layout-info_fieldname =      'LINE_COLOR'.
*  gd_layout-totals_only        = 'X'.
*  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
*                                         "click(press f2)
*  gd_layout-zebra             = 'X'.
*  gd_layout-group_change_edit = 'X'.
*  gd_layout-header_text       = 'helllllo'.
endform.                    " BUILD_LAYOUT


*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*       Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
  gd_repid = sy-repid.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
*            i_callback_user_command = 'USER_COMMAND'
*            i_grid_title           = outtext
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
*            it_special_groups       = gd_tabgroup
*            IT_EVENTS                = GT_XEVENTS
            i_save                  = 'X'
*            is_variant              = z_template

       tables
            t_outtab                = it_ekko
       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.                    " DISPLAY_ALV_REPORT


*&---------------------------------------------------------------------*
*&      Form  DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*       Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.
data: ld_color(1) type c.

select ebeln ebelp statu aedat matnr menge meins netpr peinh
 up to 10 rows
  from ekpo
  into table it_ekko.

*Populate field with color attributes
loop at it_ekko into wa_ekko.
* Populate color variable with colour properties
* Char 1 = C (This is a color property)
* Char 2 = 3 (Color codes: 1 - 7)
* Char 3 = Intensified on/off ( 1 or 0 )
* Char 4 = Inverse display on/off ( 1 or 0 )
*           i.e. wa_ekko-line_color = 'C410'
  ld_color = ld_color + 1.

* Only 7 colours so need to reset color value
  if ld_color = 8.
    ld_color = 1.
  endif.
  concatenate 'C' ld_color '10' into wa_ekko-line_color.
*  wa_ekko-line_color = 'C410'.
  modify it_ekko from wa_ekko.
endloop.
endform.                    " DATA_RETRIEVAL

2. REUSE_ALV_FIELDCATALOG_MERGE

Supports the creation of the field catalog for the ALV function modules

based either on a structure or table defined in the ABAP Data

Dictionary, or a program-internal table.

Hope this helps.

Regards,

Kinshuk

Former Member
0 Kudos

Hi all,

The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.

<b>Attributes of REUSE_ALV_FIELDCATALOG_MERGE :</b>

This one of teh attribute to set the color.----->>>

<b>Emphasize (highlight columns in color):</b> As name suggests, this field parameter is used to highlight certain field with chosen colors.

Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off ,'1'=on).

'X' = column is colored with the default column highlight color.

'Cxyz' = column is colored with a coded color:

- C: Color (coding must begin with C)

- X: color number

- Y: bold

- Z: inverse

-


>. And one More Point we will be using the REUSE_ALV_FIELDCATALOG_MERGE function module. If u not hav any DDIC structure i.e, if u want to display from more than one or more tables u need to use this.

If u know the structure name then it is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY.

Thats why we will be using mainly the REUSE_ALV_FIELDCATALOG_MERGE function module.

i hope i answered ur question .

Regards,

Kiran Reddy.