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 field catalog

Former Member
0 Kudos

I am trying to create field catalog for list display in ALV report. While declaring internal table of type SLIS_T_FIELDCAT_ALV error is being shown that "it is unidentified " Why is it so? Suggest me most effficient way of creating field catalog.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

Just try to define the Type pool before declaring internal table. I think it will work. Since the structure of SLIS_T_FIELDCAT_ALV  is defined in type pool "SLIS".

ie, TYPE-POOLS:slis.

Regards,

Sajeesh

6 REPLIES 6

Former Member
0 Kudos

Hi ,

Just try to define the Type pool before declaring internal table. I think it will work. Since the structure of SLIS_T_FIELDCAT_ALV  is defined in type pool "SLIS".

ie, TYPE-POOLS:slis.

Regards,

Sajeesh

Former Member
0 Kudos

Hi,

You can create field catalog in the following way :-

Decleration

    Type-pool :SLIS

   DATA : it_fieldcat    TYPE slis_t_fieldcat_alv,
              wa_fieldcat  TYPE slis_fieldcat_alv.

  CONSTANTS : c_one       TYPE char1  VALUE 1,
                        c_two        TYPE char1  VALUE 2,

                        c_zempid  TYPE char6  VALUE 'ZEMPID',   (name of the field to be displayed)
                        c_zfname  TYPE char6  VALUE 'ZFNAME',

Create Field Catalog

PERFORM field_cat USING : c_one     c_zempid   text-001, (Create the text value for the field)
                                             c_two     c_zfname   text-002,

Field Catalog decleration

   FORM field_cat  USING    p_c_one       TYPE c
                                          p_c_zempid TYPE c
                                          p_text_020   TYPE c.

  wa_fieldcat-col_pos   = p_c_one.
  wa_fieldcat-fieldname = p_c_zempid.
  wa_fieldcat-seltext_m = p_text_020.

  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

Call the FM for ALV display.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program   = sy-repid
      it_fieldcat                 = it_fieldcat
    TABLES
      t_outtab                   = itab
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.


  IF sy-subrc NE 0.
    MESSAGE text-005 TYPE 'E'.
  ENDIF.

Hope it helps.
                

0 Kudos

Hi,  is there any specific reason for using the variables for col_pos instead of entering direct values like wa_fieldcat-col-pos = 2 ?

0 Kudos

Hi Manan,

Its a better custom to use variables/constants  to store constant values or  to avoid hard-coding the values at the point where we are assigning it to some other variables.

ie, We are using text elements for error messages rather than hard-coding it.

Regards,

Sajeesh

0 Kudos

Hi Manan,

As Sajeesh pointed out it is always better to assign some variables than hard coding the values in the report.

Regards,

Srish

thanga_prakash
Active Contributor
0 Kudos

Hello Manan,

Use function module REUSE_ALV_FIELDCATALOG_MERGE to create a fieldcatalog.

Also define TYPE-POOLS: slis in your report to use the type group SLIS.

Regards,

Thanga