Skip to Content
0
Former Member
Mar 13, 2007 at 10:30 AM

ALV Grid & Fieldcatalog

84 Views

Hello !

I want to create an alv grid via fieldcatalog.

I use an fieldcatalog generator known as "REUSE_ALV_FIELDCATALOG_MERGE".

But I've got several problems with using this function.

The MAIN problem is, that function needs as output table, this table type: "SLIS_T_FIELDCAT_ALV".

But grid control needs an fieldcatalog table of this type: "LVC_T_FCAT".

If I use the output table from the function, within the grid control method, I get an error.

Next problem: the function does create an empty fieldcatalog.

my top include

*&---------------------------------------------------------------------*
*& Include Z_SN_LISTVIEWERTEST_TOP                           Module pool      Z_SN_LISTVIEWERTEST
*&
*&---------------------------------------------------------------------*

PROGRAM  z_sn_listviewertest.

DATA: ok_code LIKE sy-ucomm.

DATA:   BEGIN OF  gs_sflight,
              carrid LIKE sflight-carrid,
              connid LIKE sflight-connid,
              fldate LIKE sflight-fldate,
              price LIKE sflight-price,
              currency LIKE sflight-currency,
              planetype LIKE sflight-planetype,
              seatsmax LIKE sflight-seatsmax,
              seatsocc LIKE sflight-seatsocc,
              paymentsum LIKE sflight-paymentsum,
              seatsmax_b LIKE sflight-seatsmax_b,
              seatsocc_b LIKE sflight-seatsocc_b,
              seatsmax_f LIKE sflight-seatsmax_f,
              seatsocc_f LIKE sflight-seatsocc_f,
            END OF gs_sflight.


DATA:       gt_sflight LIKE TABLE OF gs_sflight.


TABLES: sflight.

important part of main module


 CREATE OBJECT LOBJ_MAINCCONT
    EXPORTING
*    PARENT                      =
      CONTAINER_NAME              = 'FRM_CC_1'
*    STYLE                       =
*    LIFETIME                    = lifetime_default
*    REPID                       =
*    DYNNR                       =
*    NO_AUTODEF_PROGID_DYNNR     =
*  EXCEPTIONS
*    CNTL_ERROR                  = 1
*    CNTL_SYSTEM_ERROR           = 2
*    CREATE_ERROR                = 3
*    LIFETIME_ERROR              = 4
*    LIFETIME_DYNPRO_DYNPRO_LINK = 5
*    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 OBJECT LOBJ_ALVLISTE
    EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
      I_PARENT          = LOBJ_MAINCCONT
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
*    I_FCAT_COMPLETE   = SPACE
*  EXCEPTIONS
*    ERROR_CNTL_CREATE = 1
*    ERROR_CNTL_INIT   = 2
*    ERROR_CNTL_LINK   = 3
*    ERROR_DP_CREATE   = 4
*    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.


  DATA: lt_myalvfcat2 TYPE SLIS_T_FIELDCAT_ALV.

  DATA: lt_myalvfcat TYPE LVC_T_FCAT.



  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME               = sy-repid
   I_INTERNAL_TABNAME           = 'GT_SFLIGHT'
*  I_STRUCTURE_NAME             = 'GS_SFLIGHT'
*   I_CLIENT_NEVER_DISPLAY       = 'X'
   I_INCLNAME                   = sy-repid
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      CT_FIELDCAT                  = lt_myalvfcat2
* 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.


Break-Point.





  CALL METHOD LOBJ_ALVLISTE->SET_TABLE_FOR_FIRST_DISPLAY
*  EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              = 'SFLIGHT'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     =
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
*    IR_SALV_ADAPTER               =
    CHANGING
     IT_OUTTAB                     = gt_sflight
     IT_FIELDCATALOG               = lt_myalvfcat
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    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.

hope, you guys can help me.

best regards,

Sven