OOPS ABAP ALV PROGRAM USING FIELD CATALOG


********************************************************************************
" FOR INTERNAL TABLE ,WORK AREA,OBJECTS AND STRUCTURE FOR VEPO TABLE DECLARATION
********************************************************************************

 
INCLUDE zoops_field_top.






START-OF-SELECTION.
*********************************************************************************
" CALL SCREEN 200 AND CLICK ON LAYOUT OPTION AND CREATE CUSTOM CONTAINER
" AND ASSIGN A NAME TO IT
*********************************************************************************
CALL SCREEN 200.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0200 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.
PERFORM create_objects.       " HERE WE CREATE OBJECTS FOR CL_GUI_CUSTOM_CONTAINER AND CL_GUI_ALV_GRID
PERFORM get_data.             " DATA FETCHING FROM VEPO TABLE
PERFORM field_catalog.        " COLLECTION OF FIELDS ALONG WITH PROPERTIES IS CALLED FIELD CATALOG
PERFORM display.              " DISPLAYING THE REQUIRED DATA

ENDMODULE.                 " STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  CREATE_OBJECTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_objects .
CREATE OBJECT container
  EXPORTING
    container_name              'CONTAINER'.

CREATE OBJECT display
  EXPORTING
    i_parent          CONTAINER.
ENDFORM.                    " CREATE_OBJECTS
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
SELECT VENUM VEPOS
       VELIN VBELN
       POSNR VEMNG
       VEMNG_FLO VEMEH FROM VEPO
       INTO TABLE ITAB UP TO 500 ROWS.

ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  FIELD_CATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM field_catalog .
 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '1'.
 WA_FCAT-FIELDNAME 'VENUM'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'INTERNAL HANDLING UNIT NUMBER'.
 APPEND WA_FCAT TO IT_FCAT.

 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '2'.
 WA_FCAT-FIELDNAME 'VEPOS'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'HANDLING UNIT ITEM'.
 APPEND WA_FCAT TO IT_FCAT.

 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '3'.
 WA_FCAT-FIELDNAME 'VELIN'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'TYPE OF HANDLING-UNIT ITEM CONTENT'.
 APPEND WA_FCAT TO IT_FCAT.

 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '4'.
 WA_FCAT-FIELDNAME 'VBELN'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'DELIVERY'.
 APPEND WA_FCAT TO IT_FCAT.

CLEAR WA_FCAT.
 WA_FCAT-COL_POS '5'.
 WA_FCAT-FIELDNAME 'POSNR'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'DELIVERY ITEM'.
 APPEND WA_FCAT TO IT_FCAT.

 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '6'.
 WA_FCAT-FIELDNAME 'VEMNG'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'BASED QUANTITY PACKED IN THE HANDLING UNIT TEAM'.
 APPEND WA_FCAT TO IT_FCAT.

 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '7'.
 WA_FCAT-FIELDNAME 'VEMNG_FLO'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'INTERNAL FIELD'.
 APPEND WA_FCAT TO IT_FCAT.

 CLEAR WA_FCAT.
 WA_FCAT-COL_POS '8'.
 WA_FCAT-FIELDNAME 'VEMEH'.
 WA_FCAT-TABNAME 'IT_FACT'.
 WA_FCAT-SCRTEXT_M 'BASE UNIT OF THE MEASURE IN THE QUANTITY'.
 APPEND WA_FCAT TO IT_FCAT.
ENDFORM.                    " FIELD_CATALOG
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display .
CALL METHOD display->set_table_for_first_display
*  EXPORTING
*    i_buffer_active               =
*    i_bypassing_buffer            =
*    i_consistency_check           =
*    i_structure_name              =
*    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                     ITAB
    it_fieldcatalog               IT_FCAT
*    it_sort                       =
*    it_filter                     =
*  EXCEPTIONS
*    invalid_parameter_combination = 1
*    program_error                 = 2
*    too_many_lines                = 3
*    others                        = 4
        .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


ENDFORM.                    " DISPLAY
  



OUTPUT