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: 

field catalouge help alv GRID only

Former Member
0 Kudos

I don't know how to use Field catalouge and what are the needs of it and what i should pass in field catalouge if i want to pass the following structure.

TYPES: BEGIN OF struct1,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
lugweight TYPE sbook-luggweight,
wunit TYPE sbook-wunit,
END OF struct1.

thank you,

Regards,

Jagrut Bharatlkumar Shukla

1 ACCEPTED SOLUTION

former_member386202
Active Contributor
0 Kudos

Hi,

Refer this code.

data : i_fieldcat TYPE slis_t_fieldcat_alv.

&----


*& Form sub_field_catalogmerge *

&----


  • This form builds the fieldcatalog using REUSE_ALV_FIELDCATALOG_MERGE*

  • function module *

----


FORM sub_field_catalogmerge.

CONSTANTS : lc_long_text(1) TYPE c VALUE 'L'.

*--Pass the Report name

v_repid = sy-repid.

*--Call funtion module to build the field catalog

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'I_FINAL'

i_client_never_display = c_chk

i_inclname = v_repid

CHANGING

ct_fieldcat = i_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*--Call the function module to display the ALV report

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

is_layout = wa_layout

it_fieldcat = i_fieldcat

i_default = c_chk

i_save = c_save

is_variant = wa_variant

it_events = i_events

is_print = wa_print

it_sort = li_sort

TABLES

t_outtab = i_final

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.

Regards,

Prashant

8 REPLIES 8

former_member386202
Active Contributor
0 Kudos

Hi,

Refer this code.

data : i_fieldcat TYPE slis_t_fieldcat_alv.

&----


*& Form sub_field_catalogmerge *

&----


  • This form builds the fieldcatalog using REUSE_ALV_FIELDCATALOG_MERGE*

  • function module *

----


FORM sub_field_catalogmerge.

CONSTANTS : lc_long_text(1) TYPE c VALUE 'L'.

*--Pass the Report name

v_repid = sy-repid.

*--Call funtion module to build the field catalog

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = v_repid

i_internal_tabname = 'I_FINAL'

i_client_never_display = c_chk

i_inclname = v_repid

CHANGING

ct_fieldcat = i_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*--Call the function module to display the ALV report

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

is_layout = wa_layout

it_fieldcat = i_fieldcat

i_default = c_chk

i_save = c_save

is_variant = wa_variant

it_events = i_events

is_print = wa_print

it_sort = li_sort

TABLES

t_outtab = i_final

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.

Regards,

Prashant

Former Member
0 Kudos

Hi Jagrut,

do like this

* Create the Field Catalog.
  PERFORM field_catalog USING 'CARRID' .
  PERFORM field_catalog USING 'CONNID' .
  PERFORM field_catalog USING 'FLDATE' .
  PERFORM field_catalog USING 'BOOKID' .
  PERFORM field_catalog USING 'LUGWEIGHT' .
  PERFORM field_catalog USING 'WUNIT' .

* Build Layout
  PERFORM f9300_build_layout.

*display report
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-repid
      is_layout          = gv_layout1
      it_fieldcat             = git_fieldcatalog[]
    TABLES
      t_outtab                = itab
    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.         " IF sy-subrc <> 0.


FORM field_catalog  USING    xv_fieldname TYPE slis_fieldname.
  DATA:  gv_colpos              TYPE i,
              git_fieldcatalog       TYPE slis_t_fieldcat_alv,
              lwa_fieldcatalog TYPE LINE OF slis_t_fieldcat_alv,
             gv_layout1             TYPE slis_layout_alv.

  gv_colpos = gv_colpos + 1.

  lwa_fieldcatalog-col_pos    = gv_colpos.
  lwa_fieldcatalog-fieldname  = xv_fieldname.
  APPEND lwa_fieldcatalog TO git_fieldcatalog.
  CLEAR lwa_fieldcatalog.

ENDFORM.                    " field_catalog

FORM build_layout .
  gv_layout1-colwidth_optimize = 'X'.
  gv_layout1-zebra             = 'X'.
  gv_layout1-group_change_edit = 'X'.
  gv_layout1-f2code            = 'DISPLAY'.
ENDFORM.                    " build_layout

Hope this will help you

<b>Reward points for helpful answers</b>

Satish

Former Member
0 Kudos

hi,

<b>copy this & execute ...

fcat's -- used for defining the fields of the ALV display..</b>

_______________________________________

TYPE-POOLS : SLIS.

DATA : FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

FCAT1 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

ILAYOUT TYPE SLIS_LAYOUT_ALV,

XS_EVENT TYPE SLIS_ALV_EVENT,

GT_XEVENTS TYPE SLIS_T_EVENT,

GT_YEVENTS TYPE SLIS_T_EVENT,

IT_SORT TYPE SLIS_T_SORTINFO_ALV,

WA_SORT TYPE SLIS_SORTINFO_ALV.

DATA : BEGIN OF INT_PA0001 OCCURS 0.

INCLUDE TYPE PA0001.

DATA : END OF INT_PA0001.

&& DATA FROM PA0001

SELECT * FROM PA0001

UP TO 5 ROWS

INTO TABLE INT_PA0001.

&& LAYOUT DEF

ILAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ILAYOUT-ZEBRA = 'X'.

&& FCAT1

CLEAR FCAT.

FCAT-FIELDNAME = 'PERNR'.

FCAT-SELTEXT_M = 'Emp No'.

FCAT-TABNAME = 'INT_PA0001'.

APPEND FCAT.

CLEAR FCAT.

FCAT-FIELDNAME = 'BEGDA'.

FCAT-SELTEXT_M = 'St Date'.

FCAT-TABNAME = 'INT_PA0001'.

APPEND FCAT.

CLEAR FCAT.

FCAT-FIELDNAME = 'ENDDA'.

FCAT-SELTEXT_M = 'End Date'.

FCAT-TABNAME = 'INT_PA0001'.

APPEND FCAT.

CLEAR FCAT.

FCAT-FIELDNAME = 'BUKRS'.

FCAT-SELTEXT_M = 'Comp Code'.

FCAT-TABNAME = 'INT_PA0001'.

APPEND FCAT.

CLEAR FCAT.

FCAT-FIELDNAME = 'WERKS'.

FCAT-SELTEXT_M = 'Plant'.

FCAT-TABNAME = 'INT_PA0001'.

APPEND FCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

IS_LAYOUT = ILAYOUT

IT_FIELDCAT = FCAT[]

TABLES

T_OUTTAB = INT_PA0001.

reply back..

WIth Rgds,

S.Barani

Former Member
0 Kudos

Hi,

Go through this link on ALV.

http://www.geocities.com/mpioud/Abap_programs.html

Reward if helpful.

Regards,

Harini.S

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jagrut

Most importantly do not use the old-fashioned ALV lists (referencing type-pool SLIS) anymore. Thus, if you want to create your fieldcatalog automatically (for OO-based ALV lists) use LVC_FIELDCATALOG_MERGE instead of REUSE_ALV_FIELDCATALOG_MERGE.

Each row in your fieldcatalog describes the technical details of a single column of your ALV list.

Everything you need to know about ALV list (based on class CL_GUI_ALV_GRID) can be found in the excellent tutorial

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a>

Regards

Uwe

Former Member
0 Kudos

Hi,

Please refer to the link below :

<a href="http://www.sapdev.co.uk/reporting/alv/alvgrid_basic.htm">http://www.sapdev.co.uk/reporting/alv/alvgrid_basic.htm</a>

Thanks,

Sriram Ponna.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jagrut

Since all fields of your type definition belong to DDIC structure SBOOK simply use the following approach for building your fieldcatalog:

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
*     I_BUFFER_ACTIVE              =
    i_structure_name             = 'SBOOK'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
  CHANGING
    ct_fieldcat                  = gt_fcat  " of type LVC_T_FCAT
  EXCEPTIONS
    inconsistent_interface       = 1
    program_error                = 2
    OTHERS                       = 3
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

  LOOP AT gt_fcat INTO ls_fcat.
    CASE ls_fcat-fieldname.
      WHEN 'CARRID'   OR
                 'CONNID'   OR
                 '...'.
        CONTINUE.  " do not change

      WHEN OTHERS.
        ls_fcat-tech = 'X'.  " column is neither displayed nor available in layout
" OR:
        ls_fcat-no_out = 'X'.  " column is not displayed yet available in layout
      ENDCASE.

    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
  ENDLOOP.

Regards

Uwe

0 Kudos

Hi uwe,

Here i need to know is what is the type of ls_fcat if its lvc_t_fcat then it saying cannot convert gt_fcat into ls_fcat.

thank you,

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
*     I_BUFFER_ACTIVE              =
    i_structure_name             = 'SBOOK'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
  CHANGING
    ct_fieldcat                  = gt_fcat  " of type LVC_T_FCAT
  EXCEPTIONS
    inconsistent_interface       = 1
    program_error                = 2
    OTHERS                       = 3
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
  LOOP AT gt_fcat INTO ls_fcat. <b><-------- type?</b>
    CASE ls_fcat-fieldname.
      WHEN 'CARRID'   OR
                 'CONNID'   OR
                 '...'.
        CONTINUE.  " do not change
 
      WHEN OTHERS.
        ls_fcat-tech = 'X'.  " column is neither displayed nor available in layout
" OR:
        ls_fcat-no_out = 'X'.  " column is not displayed yet available in layout
      ENDCASE.
 
    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
  ENDLOOP.