Skip to Content

REUSE_ALV_FIELDCATALOG_MERGE not working internal table

Hi, REUSE_ALV_FIELDCATALOG_MERGE not working gt_fieldcat[] return is intial my code is like below

TYPES : BEGIN OF ty_itab,

          box(1)      TYPE c,

          id          LIKE zsd_t_dnavlun-id,

          kschl       LIKE zsd_t_dnavlun-kschl,

          kschl_t     LIKE t685t-vtext,

          tdlnr       LIKE zsd_t_dnavlun-tdlnr,

          tdlnr_t     LIKE lfa1-name1,

          zzvsart     LIKE zsd_t_dnavlun-zzvsart,

          bezei       LIKE t173t-bezei,

          kunnr       LIKE zsd_t_dnavlun-kunnr,

          kunnr_t     LIKE kna1-name1,

          inco1       LIKE zsd_t_dnavlun-inco1,

          inco1_t     LIKE tinct-bezei,

          land1z      LIKE zsd_t_dnavlun-land1z,

          landx       LIKE t005t-landx,

          zzlport     LIKE zsd_t_dnavlun-zzlport,

          lport_bezei LIKE zsd_t_portlt-bezei,

          zzdport     LIKE zsd_t_dnavlun-zzdport,

          dport_bezei LIKE zsd_t_portlt-bezei,

          zzkonttype  LIKE zsd_t_dnavlun-zzkonttype,

          ktytptx     LIKE zmm_t_sku5t-ktytptx,

          zzlsloc     LIKE zsd_t_dnavlun-zzlsloc,

          pstlzz      LIKE zsd_t_dnavlun-pstlzz,

          kbetr       LIKE zsd_t_dnavlun-kbetr,

          konwa       LIKE zsd_t_dnavlun-konwa,

          mkbetr      LIKE zsd_t_knavlun-mkbetr,

          alvrenk(4)  TYPE c,

        END OF ty_itab.



DATA it_data TYPE STANDARD TABLE OF ty_itab.
DATA gt_fieldcat TYPE slis_t_fieldcat_alv.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

      i_program_name         = sy-repid

      i_internal_tabname     = 'IT_DATA'

*     i_structure_name       = lv_structure

      i_inclname             = sy-repid

      i_bypassing_buffer     = 'X'

    CHANGING

      ct_fieldcat            = gt_fieldcat[]

    EXCEPTIONS

      inconsistent_interface = 1

      program_error          = 2

      OTHERS                 = 3.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 03, 2016 at 02:54 PM

    Hi

    It depends on how te internal table is defined:

    the function module REUSE_ALV_FIELDCATALOG_MERGE scans the program in order to get the definition of the internal table, but sometimes it can't get the definition, it's better to use the "old way" to define an internal table

    DATA : BEGIN OF it_data OCCURS 0,
              box(1)      TYPE c,
              id          LIKE zsd_t_dnavlun-id,
              kschl       LIKE zsd_t_dnavlun-kschl,
              kschl_t     LIKE t685t-vtext,
              tdlnr       LIKE zsd_t_dnavlun-tdlnr,
              tdlnr_t     LIKE lfa1-name1,
              zzvsart     LIKE zsd_t_dnavlun-zzvsart,
              bezei       LIKE t173t-bezei,
              kunnr       LIKE zsd_t_dnavlun-kunnr,
              kunnr_t     LIKE kna1-name1,
              inco1       LIKE zsd_t_dnavlun-inco1,
              inco1_t     LIKE tinct-bezei,
              land1z      LIKE zsd_t_dnavlun-land1z,
              landx       LIKE t005t-landx,
              zzlport     LIKE zsd_t_dnavlun-zzlport,
              lport_bezei LIKE zsd_t_portlt-bezei,
              zzdport     LIKE zsd_t_dnavlun-zzdport,
              dport_bezei LIKE zsd_t_portlt-bezei,
              zzkonttype  LIKE zsd_t_dnavlun-zzkonttype,
              ktytptx     LIKE zmm_t_sku5t-ktytptx,
              zzlsloc     LIKE zsd_t_dnavlun-zzlsloc,
              pstlzz      LIKE zsd_t_dnavlun-pstlzz,
              kbetr       LIKE zsd_t_dnavlun-kbetr,
              konwa       LIKE zsd_t_dnavlun-konwa,
              mkbetr      LIKE zsd_t_knavlun-mkbetr,
              alvrenk(4)  TYPE c,
            END OF it_data.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
        i_program_name         = sy-repid
        i_internal_tabname     = 'IT_DATA'
    *   i_structure_name       = lv_structure
        i_inclname             = sy-repid
        i_bypassing_buffer     = 'X'
      CHANGING
        ct_fieldcat            = gt_fieldcat[]
      EXCEPTIONS
        inconsistent_interface = 1
        program_error          = 2
        OTHERS                 = 3.<br>
    

    I suppose the logic for scanning (used by REUSE_ALV_FIELDCATALOG_MERGE) doesn't manage all ways to define an internal table.

    Perhaps there's a Sap Note

    Max

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2016 at 04:08 PM

    Hi,

    In place of using old-fashioned REUSE functions for building ALV grids, you should use CL_SALV classes.

    Basically, you can display easily the contents of a table with this code (wt_display is your internal table).

    If needed you can change attributes of the columns, I put a simple example here.

    DATA: ob_table   TYPE REF TO cl_salv_table,
          ob_column  TYPE REF TO cl_salv_column.
    
      TRY.
          cl_salv_table=>factory( IMPORTING r_salv_table = ob_table
                                   CHANGING t_table      = wt_display ).
        CATCH cx_salv_msg.
      ENDTRY.
    
      IF ob_table IS BOUND.
    *   Screen status
        ob_table->set_screen_status( EXPORTING report        = 'SAPLKKBL'
                                               pfstatus      = 'STD_LIGHT_FULLSCREEN'
                                               set_functions = ob_table->c_functions_all ).
    
    *   Optimize columns
        ob_table->get_columns( )->set_optimize( ).
    
    *   Special column: to be hidden
        ob_column = ob_table->get_columns( )->get_column( columnname = 'MY_FIELD_NAME' ).
        IF ob_column IS BOUND.
          ob_column->set_technical( ).
        ENDIF.
    
    *   Display
        ob_table->display( ).
      ENDIF.
    
    Add comment
    10|10000 characters needed characters exceeded