cancel
Showing results for 
Search instead for 
Did you mean: 

field catalog

Former Member
0 Kudos

HI FRIENDS,

can any one exlain what is the main difference the Field catalog and field catalog Merge??

or both are same.. and what is use of field catalog Merge?

can any one explain,

regards,

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

The field catalog for an ALV report is an internal table within your ABAP program that has entries that describe how the columns of the ALV report will be presented. You need to populate this with data before calling the ALV display function module so that it knows what columns of data you have and how to display them.

REUSE_ALV_FIELDCATALOG_MERGE is a function module that can be used to help you fill in the values in the field catalog internal table. You can call this function and give it the name of a dictionary structure or a structure defined in your program code and it will add the details for each field in the structure to the field catalog internal table.

Andrew

uwe_schieferstein
Active Contributor
0 Kudos

Hello Vijay

The fieldcatalog describes the columns of your ALV list. Have a look at routine <b>BUILD_FIELDCATALOG_KNB1</b> in my sample report <b>ZUS_SDN_ALVGRID_EVENTS_HOTSPOT</b>.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_ALVGRID_EVENTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_alvgrid_events.



DATA:
  gd_okcode        TYPE ui_func,
*
  gt_fcat          TYPE lvc_t_fcat,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid.

DATA:
  go_table              TYPE REF TO cl_salv_table,
  go_grid_adapter       TYPE REF TO cl_salv_grid_adapter.


DATA:
  gt_knb1          TYPE STANDARD TABLE OF knb1.


PARAMETERS:
  p_bukrs      TYPE bukrs  DEFAULT '2000'  OBLIGATORY.



*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.

    CLASS-METHODS:
      handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
        IMPORTING
          e_row_id
          e_column_id
          es_row_no
          sender,  " grid instance that raised the event

      handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
        IMPORTING
          es_col_id
          es_row_no
          sender.

ENDCLASS.                    "lcl_eventhandler DEFINITION


*---------------------------------------------------------------------*
*       CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.

  METHOD handle_hotspot_click.
*   define local data
    DATA:
      ls_knb1     TYPE knb1,
      ls_col_id   TYPE lvc_s_col.

    READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).

    CASE e_column_id-fieldname.
      WHEN 'KUNNR'.
        SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
        SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.

        CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

      WHEN 'ERNAM'.
*        SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
*        NOTE: no parameter id available, yet simply show the priciple

        CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.

      WHEN OTHERS.
*       do nothing
    ENDCASE.




*   Set active cell to field BUKRS otherwise the focus is still on
*   field KUNNR which will always raise event HOTSPOT_CLICK
    ls_col_id-fieldname = 'BUKRS'.
    CALL METHOD go_grid1->set_current_cell_via_id
      EXPORTING
        is_row_id    = e_row_id
        is_column_id = ls_col_id.



  ENDMETHOD.                    "handle_hotspot_click


  METHOD handle_button_click.
*   define local data
    DATA:
      ls_knb1     TYPE knb1.

    READ TABLE gt_knb1 INTO ls_knb1 INDEX es_row_no-row_id.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).

    SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
    SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.

    CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

  ENDMETHOD.                    "handle_button_click

ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION


START-OF-SELECTION.

  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = p_bukrs.



  TRY.
      CALL METHOD cl_salv_table=>factory
*      EXPORTING
*      LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*      R_CONTAINER    =
*      CONTAINER_NAME =
        IMPORTING
          r_salv_table   = go_table
        CHANGING
          t_table        = gt_knb1.
    CATCH cx_salv_msg .
  ENDTRY.



  go_table->display( ).




  go_table->get_metadata( ).
  EXIT.


* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
      ratio                       = 90
    EXCEPTIONS
      OTHERS                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* Create ALV grid
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent          = go_docking
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Set event handler
  SET HANDLER:
    lcl_eventhandler=>handle_hotspot_click FOR go_grid1,
    lcl_eventhandler=>handle_button_click  FOR go_grid1.


* Build fieldcatalog and set hotspot for field KUNNR
  PERFORM build_fieldcatalog_knb1.



* Display data
  CALL METHOD go_grid1->set_table_for_first_display
    CHANGING
      it_outtab       = gt_knb1
      it_fieldcatalog = gt_fcat
    EXCEPTIONS
      OTHERS          = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.




* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* ok-code field = GD_OKCODE
  CALL SCREEN '0100'.


END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
*  SET TITLEBAR 'xxx'.


ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.


    WHEN OTHERS.
  ENDCASE.

  CLEAR: gd_okcode.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  BUILD_FIELDCATALOG_KNB1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_fieldcatalog_knb1 .
* define local data
  DATA:
    ls_fcat        TYPE lvc_s_fcat.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
*     I_BUFFER_ACTIVE              =
      i_structure_name             = 'KNB1'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
*     I_INTERNAL_TABNAME           =
    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 INTO ls_fcat
          WHERE ( fieldname = 'KUNNR'  OR
                  fieldname = 'ERNAM'  OR
                  fieldname = 'BUKRS' ).
    IF ( ls_fcat-fieldname = 'BUKRS' ).
      ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
      " column appears as button
    ELSE.
      ls_fcat-hotspot = abap_true.
    ENDIF.

    MODIFY gt_fcat FROM ls_fcat.
  ENDLOOP.


ENDFORM.                    " BUILD_FIELDCATALOG_KNB1

Regards

Uwe

Former Member
0 Kudos

HI,

Field catalog merge is a FM which provides the catalog of given structure. which shows all fields in the structure or table.

Field catalog: which has to fill manually with required fields from the structure. So u have facility to avoid some of the fields in structure in ALV.

Regards

SAB

Former Member
0 Kudos

HI,

Filed Catalgo merge is a function module which would return the field names of a strucre or internal table which can be used as a column heading in the ALV report display.

Thanks

Mahesh