Saturday, 24 March 2012

ALV Report

* FIELD CATALOG MANUALLY BUILT *

REPORT  ZCLASS_G14.

TABLES VBAK.

SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.

DATA: BEGIN OF IT_VBAK OCCURS 0,
        VBELN LIKE VBAK-VBELN,
        ERDAT LIKE VBAK-ERDAT,
        ERNAM LIKE VBAK-ERNAM,
        KUNNR LIKE VBAK-KUNNR,
        NETWR LIKE VBAK-NETWR,
      END OF IT_VBAK.

TYPE-POOLS SLIS.

DATA IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA IT_SORT TYPE SLIS_T_SORTINFO_ALV.

DATA WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA WA_SORT TYPE SLIS_SORTINFO_ALV.

START-OF-SELECTION.

  SELECT VBELN
         ERDAT
         ERNAM
         KUNNR
         NETWR INTO TABLE IT_VBAK
               FROM VBAK
               WHERE VBELN IN S_VBELN.

END-OF-SELECTION.

  WA_FIELDCAT-FIELDNAME = 'VBELN'.
  WA_FIELDCAT-SELTEXT_L = 'Sales Doc'.
  WA_FIELDCAT-KEY = 'X'.
  WA_FIELDCAT-OUTPUTLEN = 20.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.
  CLEAR WA_FIELDCAT.

  WA_FIELDCAT-FIELDNAME = 'ERDAT'.
  WA_FIELDCAT-SELTEXT_L = 'Date'.
  WA_FIELDCAT-OUTPUTLEN = 10.
  WA_FIELDCAT-EDIT_MASK = '__-__-____'.
*
  APPEND WA_FIELDCAT TO IT_FIELDCAT.
  CLEAR WA_FIELDCAT.


  WA_FIELDCAT-FIELDNAME = 'ERNAM'.
  WA_FIELDCAT-SELTEXT_L = 'USER'.
*  WA_FIELDCAT-EDIT = 'X'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.
  CLEAR WA_FIELDCAT.


  WA_FIELDCAT-FIELDNAME = 'KUNNR'.
  WA_FIELDCAT-SELTEXT_L = 'Cutomer'.
  WA_FIELDCAT-EMPHASIZE = 'C710'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.
  CLEAR WA_FIELDCAT.

  WA_FIELDCAT-FIELDNAME = 'NETWR'.
  WA_FIELDCAT-SELTEXT_L = 'Amount'.
  WA_FIELDCAT-DO_SUM = 'X'.

  APPEND WA_FIELDCAT TO IT_FIELDCAT.
  CLEAR WA_FIELDCAT.

*---
  WA_LAYOUT-ZEBRA = 'X'.
  WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

*--
  WA_SORT-FIELDNAME = 'KUNNR'.
  WA_SORT-UP = 'X'.
  WA_SORT-SUBTOT = 'X'.

  APPEND WA_SORT TO IT_SORT.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ' '
*   I_CALLBACK_PROGRAM             = ' '
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      = WA_LAYOUT
   IT_FIELDCAT                    = IT_FIELDCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
   IT_SORT                        = IT_SORT
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
    TABLES
      T_OUTTAB                       = IT_VBAK
* EXCEPTIONS
*   PROGRAM_ERROR                  = 1
*   OTHERS                         = 2
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.