Skip to Content
author's profile photo Former Member
Former Member

REUSE_ALV_FIELDCATALOG_MERGE

Hi Experts,

If an Itab contains fields from different DDIC tables then can't we use this FM REUSE_ALV_FIELDCATALOG_MERGE on this itab?

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 09:33 AM

    Hi ravi,

    1. The fieldnames can be different.

    2. But if the field names are defined using

    abc LIKE TABLENAME-FIELDNAME,

    3. only then this FM will work.

    4. LIKE should be used, and not type.

    5. If we simply use

    abc(5) type c,

    def type i,

    then the FM won't understand anything,

    and moreover, from where it will get the

    text/labels of this field ?

    regards,

    amit m.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Ravi

      Here is another dynamic approach:

      *&---------------------------------------------------------------------*
      *& Report  ZUS_SDN_FIELDCATALOG_MULTIPLE                               *
      *&                                                                     *
      *&---------------------------------------------------------------------*
      *&                                                                     *
      *&                                                                     *
      *&---------------------------------------------------------------------*
      
      REPORT  zus_sdn_fieldcatalog_multiple                               .
      
      
      TYPE-POOLS: abap, slis.
      
      
      DATA: BEGIN OF it_purchase OCCURS 0,
        ebeln TYPE ekko-ebeln,
        bukrs TYPE ekko-bukrs,
        bsart TYPE ekko-bsart,
        aedat TYPE ekko-aedat,
        matnr TYPE ekpo-matnr,
        txz01 TYPE ekpo-txz01,
        menge TYPE ekpo-menge,
        netpr TYPE ekpo-netpr,
        werks TYPE ekpo-werks,
      END OF it_purchase.
      
      
      DATA:
        gd_idx          TYPE i,
        gs_comp         TYPE abap_compdescr,
        go_typedescr    TYPE REF TO cl_abap_typedescr,
        go_struct       TYPE REF TO cl_abap_structdescr,
        gt_fcat         TYPE slis_t_fieldcat_alv,
        gs_fcat         LIKE LINE OF gt_fcat.
      
      
      
      START-OF-SELECTION.
      
      * Get the run-time information of your itab
        CALL METHOD cl_abap_typedescr=>describe_by_data
          EXPORTING
            p_data      = it_purchase
          RECEIVING
            p_descr_ref = go_typedescr.
        IF sy-subrc <> 0.
      *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        go_struct ?= go_typedescr.
      
      
      * Get fieldcatalog for each DB table used for data definition
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            i_structure_name       = 'EKKO'
          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.
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            i_structure_name       = 'EKPO'
          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.
      
      
      * Remove unwanted fields from catalog
        LOOP AT gt_fcat INTO gs_fcat.
          gd_idx = syst-tabix.
      
          READ TABLE go_struct->components TRANSPORTING NO FIELDS
               WITH KEY name = gs_fcat-fieldname.
          IF ( syst-subrc NE 0 ).
            DELETE gt_fcat INDEX gd_idx.
          ENDIF.
        ENDLOOP.
      
      * Renumbering of the columns (according to itab definition)
        LOOP AT go_struct->components INTO gs_comp.
          gd_idx = syst-tabix.
      
          READ TABLE gt_fcat INTO gs_fcat
               WITH KEY fieldname = gs_comp-name.
          IF ( syst-subrc = 0 ).
            DELETE gt_fcat INDEX syst-tabix.
      
            gs_fcat-col_pos = syst-tabix.
            APPEND gs_fcat TO gt_fcat.
          ENDIF.
      
        ENDLOOP.
      
        LOOP AT gt_fcat INTO gs_fcat.
          gs_fcat-col_pos = syst-tabix.
      
          WRITE: / gs_fcat-col_pos, gs_fcat-fieldname.
      
          MODIFY gt_fcat FROM gs_fcat.
        ENDLOOP.
      
      END-OF-SELECTION.

      Regards

      Uwe

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 09:32 AM

    Hi

    We can use this FM. What problem are you facing?

    Regards,

    Raj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 09:32 AM

    Yes you can ! but is it required ? you can directly assign the internal table structure to the field catalog

    regards,

    Sandeep Josyula

    *Mark helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 09:33 AM

    we can use this function module for any any number of fields from any table , no problem with that as we will be moving these fields into one final table, it does not matter.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 09:33 AM

    Hi Ravi,

    i have no Problems with this FM. I use it

    in this way (My itab has several DDICs):

    PROGNAME = SY-REPID.

    *

    • Feldkatatalog vorbereiten auf Basis der ITAB-Definitionen

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = PROGNAME

    I_INTERNAL_TABNAME = 'ITAB'

    I_CLIENT_NEVER_DISPLAY = 'X'

    I_INCLNAME = PROGNAME

    CHANGING

    CT_FIELDCAT = FIELDCAT

    EXCEPTIONS

    INCONSISTENT_INTERFACE = 1

    PROGRAM_ERROR = 2

    OTHERS = 3.

    *

    Regards, Dieter

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 25, 2006 at 09:34 AM

    Hi,

    Define a types in your program say

    types : begin of ty,

    field descriptions,

    end of ty.

    data itab type standard table of ty.

    pass

    I_PROGRAM_NAME & I_INTERNAL_TABNAME in the function module

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.