# SAP ABAP ALV: LVC_FIELDCATALOG_MERGE how to use?

- Link: https://ultimasolution.pl/lvc_fieldcatalog_merge-how-to-use/
- Published: 2026-04-10T09:05:59+02:00
- Author: Karol Preiskorn

# Field catalog

In an SAP ALV grid, the field catalog describes how each internal-table field is
displayed: its heading, position, width, visibility, alignment, data type, and whether
the user can edit it. `LVC_FIELDCATALOG_MERGE` generates this catalog from an ABAP
Dictionary (DDIC) structure so that you do not have to define every column manually.

All fields of the global structure type can then appear in the output table with
the same names. If the DDIC structure changes, the generated catalog can follow 
those changes. You can also loop over the result and change selected columns before
passing it to `CL_GUI_ALV_GRID` or another LVC-based ALV display.

## What LVC_FIELDCATALOG_MERGE does

The function module reads the metadata of a DDIC structure and fills the changing
table `CT_FIELDCAT`, whose type is normally `LVC_T_FCAT`. Each row is an `LVC_S_FCAT`
entry describing one ALV column. The generated entries include field names, DDIC
references, data types, default texts, output lengths, and other display properties.

This approach is most useful when the output table is based on a transparent table,
database view, or structure in SE11. If the output type is assembled only in ABAP
with `BEGIN OF ... END OF`, the original DDIC references may not be available. In
that case, define the field catalog manually or provide explicit references such
as `REF_TABLE` and `REF_FIELD`.

## Importing and changing parameters

For the usual DDIC-based call, pass `I_STRUCTURE_NAME` with the name of the Dictionary
structure. The main parameters are:

 * `I_STRUCTURE_NAME` – the DDIC structure used to build the catalog; this is the
   required input in the common scenario.
 * `I_INTERNAL_TABNAME` – an alternative when the field catalog should be derived
   from an internal table declared in the program.
 * `I_CLIENT_NEVER_DISPLAY` – controls whether client fields should be hidden.
 * `I_BYPASSING_BUFFER` – forces the function module to read the metadata again 
   instead of using its buffer.
 * `I_BUFFER_ACTIVE` – controls use of the field-catalog buffer.
 * `CT_FIELDCAT` – the changing table that receives the generated entries and is
   then customized.

Do not normally supply both structure sources. In a DDIC-based report, initialize`
CT_FIELDCAT`, pass `I_STRUCTURE_NAME`, and check `SY-SUBRC` after the call.

## Complete ABAP example

The following example selects flight data, generates a catalog from `SFLIGHT`, and
modifies column headings, width, visibility, and editability before displaying the
grid. The exact available fields depend on the SAP system and release.

    ```EnlighterJSRAW
    REPORT z_lvc_fieldcatalog_merge.

    TYPES: BEGIN OF ty_flight,
             carrid   TYPE sflight-carrid,
             connid   TYPE sflight-connid,
             fldate   TYPE sflight-fldate,
             seatsmax TYPE sflight-seatsmax,
           END OF ty_flight.

    DATA: gt_flight TYPE STANDARD TABLE OF ty_flight,
          gt_fcat   TYPE lvc_t_fcat,
          go_grid   TYPE REF TO cl_gui_alv_grid.

    SELECT carrid, connid, fldate, seatsmax
      FROM sflight
      INTO TABLE @gt_flight
      UP TO 100 ROWS.

    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name = 'SFLIGHT'
      CHANGING
        ct_fieldcat      = gt_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 ASSIGNING FIELD-SYMBOL(<fcat>).
      CASE <fcat>-fieldname.
        WHEN 'CARRID'.
          <fcat>-coltext = 'Airline'.
          <fcat>-scrtext_l = 'Airline carrier'.
          <fcat>-outputlen = 12.
        WHEN 'CONNID'.
          <fcat>-coltext = 'Connection'.
          <fcat>-col_pos = 2.
        WHEN 'FLDATE'.
          <fcat>-coltext = 'Flight date'.
          <fcat>-outputlen = 12.
        WHEN 'SEATSMAX'.
          <fcat>-no_out = abap_true.
      ENDCASE.
    ENDLOOP.

    CREATE OBJECT go_grid
      EXPORTING
        i_parent = cl_gui_container=>screen0.

    go_grid->set_table_for_first_display(
      CHANGING
        it_outtab       = gt_flight
        it_fieldcatalog = gt_fcat ).
    ```

In a dialog program, replace `CL_GUI_CONTAINER=>SCREEN0` with the custom container
on screen 100. The field catalog is generated once and can be reused when the grid
is refreshed.

## Changing headings, widths, visibility, and editability

After the merge, loop over `GT_FCAT` and identify a column by `FIELDNAME`. Useful
properties include:

 * `COLTEXT`, `SCRTEXT_L`, `SCRTEXT_M`, and `SCRTEXT_S` – long, medium, short, and
   general column labels. Set all relevant text variants when the heading must remain
   consistent at different widths.
 * `OUTPUTLEN` – the displayed width in characters. Use it when automatic sizing
   is not suitable.
 * `NO_OUT = ABAP_TRUE` – hides a column initially without deleting it from the 
   catalog.
 * `TECH = ABAP_TRUE` – marks a technical field that should not be offered as a 
   normal display column.
 * `EDIT = ABAP_TRUE` – allows editing, provided the ALV grid and the underlying
   internal table are configured for input.
 * `COL_POS` – sets the initial column position.
 * `CHECKBOX = ABAP_TRUE` – renders a suitable character field as a checkbox.

Changing `EDIT` alone does not make a report transactional. The field must be compatible
with input, the grid must be ready for editing, and application code must validate
and save the changed values.

## Common errors and troubleshooting

 * **Inconsistent interface:** check that `CT_FIELDCAT` has type `LVC_T_FCAT` and
   that the structure name exists in SE11. Do not mix the LVC catalog with the older
   SLIS catalog.
 * **Program error or empty catalog:** verify spelling and capitalization of `I_STRUCTURE_NAME`,
   confirm that the caller can read the DDIC object, and check `SY-SUBRC` immediately
   after the function call.
 * **Unknown or missing fields:** make sure the output table and DDIC structure 
   describe compatible fields. For calculated fields, append an explicit `LVC_S_FCAT`
   entry and set its field name, text, type, and length.
 * **Headings are truncated or inconsistent:** set `COLTEXT`, `SCRTEXT_L`, `SCRTEXT_M`,
   and `SCRTEXT_S`, then review `OUTPUTLEN`.
 * **Edits are not accepted:** confirm `EDIT`, the grid editing settings, the screen/
   container lifecycle, and the change-data event handling. Also check that the 
   internal table is not overwritten during refresh.
 * **Stale metadata:** use `I_BYPASSING_BUFFER` when testing a recently changed 
   DDIC structure, then remove it if normal buffering is preferable.

## LVC_FIELDCATALOG_MERGE compared with REUSE_ALV_FIELDCATALOG_MERGE

`LVC_FIELDCATALOG_MERGE` creates the modern LVC catalog (`LVC_T_FCAT`) used with
object-oriented ALV controls such as `CL_GUI_ALV_GRID`. `REUSE_ALV_FIELDCATALOG_MERGE`
creates the older SLIS catalog (`SLIS_T_FIELDCAT_ALV`) used by the classic `REUSE_ALV_*`
function modules. Do not pass one catalog type to the other API. For new development,
prefer the object-oriented ALV classes or `CL_SALV_TABLE`; keep the REUSE variant
mainly for maintaining existing reports.

## Practical result

After the merge, the ALV grid opens with the DDIC field descriptions instead of 
a manually built list of columns. In the example, the user sees readable Airline,
Connection, and Flight date headings, while SEATSMAX is available in the catalog
but hidden initially. The same catalog can be adjusted for different users or screen
sizes and then passed to `SET_TABLE_FOR_FIRST_DISPLAY`. This separates data selection
from presentation rules and makes later DDIC changes easier to maintain.

## Related SAP ABAP and ALV articles

 * [Update SAP Infotype 1000 with ABAP](https://ultimasolution.pl/sap-abap-update-infotype-1000/)–
   an example of reading and updating HR object data.
 * [Timestamp display in ALV](https://ultimasolution.pl/timestamp-display-in-alv/)–
   format timestamps for an ALV output.
 * [Refresh an ALV grid while keeping the position and current cell](https://ultimasolution.pl/refresh-alv-grid-and-keep-position-and-current-cell-abap).

## External references

 * [Using the FM LVC_FIELDCATALOG_MERGE](https://answers.sap.com/questions/3380700/using-the-fm-lvcfieldcatalogmerge.html)
 * [Fieldcatalog merge in ALV report](https://answers.sap.com/questions/6058081/fieldcatalog-merge-in-alv-report.html)
 * [SAP field catalog types](https://wiki.scn.sap.com/wiki/display/ABAP/Field+catalog+types)
