Showing posts with label Interactive Alv Report of Purchase order. Show all posts
Showing posts with label Interactive Alv Report of Purchase order. Show all posts

13/05/2013

Interactive Alv Report of Purchase order

*&---------------------------------------------------------------------*
*& Report  Z_ALV_REPORT_PURCHASE_ORDER
*&
*&---------------------------------------------------------------------*
*& Author     tech.sap29@gmail.com
*&
*&---------------------------------------------------------------------*

REPORT  Z_ALV_REPORT_PURCHASE_ORDER.

TYPE-POOLS SLIS.
 TYPES  : BEGIN OF TY_EKKO,
                EBELN TYPE EKKO-EBELN,
                BUKRS TYPE EKKO-BUKRS,
                BSTYP TYPE EKKO-BSTYP,
                BSART TYPE EKKO-BSART,
                BSAKZ TYPE EKKO-BSAKZ,
                LOEKZ TYPE EKKO-LOEKZ,
                STATU TYPE EKKO-STATU,
                AEDAT TYPE EKKO-AEDAT,
                ERNAM TYPE EKKO-ERNAM,
                PINCR TYPE EKKO-PINCR,
                LPONR TYPE EKKO-LPONR,
              END OF TY_EKKO.

TYPES : BEGIN OF TY_EKPO,
        EBELN TYPE EKPO-EBELN,
        EBELP TYPE EKPO-EBELP,
        LOEKZ TYPE EKPO-LOEKZ,
        STATU TYPE EKPO-STATU,
        AEDAT TYPE EKPO-AEDAT,
        TXZ01 TYPE EKPO-TXZ01,
        END OF TY_EKPO.

DATA : IT_EKKO TYPE TABLE OF TY_EKKO ,
       IT_EKPO TYPE TABLE OF TY_EKPO,
       WA_EKKO TYPE          TY_EKKO,
       WA_EKPO TYPE          TY_EKPO.

DATA : IT_EVENT TYPE SLIS_T_EVENT,
       WA_EVENT TYPE SLIS_ALV_EVENT .


START-OF-SELECTION.
PERFORM GET_DATA .
PERFORM FILL_EVENT .
PERFORM DISPLAY_DATA .


*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*

FORM GET_DATA .
SELECT   EBELN
         BUKRS
         BSTYP
         BSART
         BSAKZ
         LOEKZ
         STATU
         AEDAT
         ERNAM
         PINCR
         LPONR INTO TABLE IT_EKKO FROM EKKO UP TO 20 ROWS .

ENDFORM.                    " GET_DATA


*&---------------------------------------------------------------------*
*&      Form  FILL_EVENT
*&---------------------------------------------------------------------*

FORM FILL_EVENT .
WA_EVENT-NAME = 'USER_COMMAND'.
WA_EVENT-FORM = 'VALIDATE_COMMAND'.
APPEND WA_EVENT TO IT_EVENT .
ENDFORM.                    " FILL_EVENT


*&---------------------------------------------------------------------*
*&      Form  DISPLAY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
   I_CALLBACK_PROGRAM                = SY-CPROG
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
   I_STRUCTURE_NAME                  = 'EKKO'
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
*   IT_FIELDCAT                       =
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
   IT_EVENTS                         = it_event
*   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
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
  TABLES
    T_OUTTAB                          = IT_EKKO
* 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.

ENDFORM.                    " DISPLAY_DATA

FORM VALIDATE_COMMAND USING UCOMM LIKE SY-UCOMM
                            SEL_DET TYPE SLIS_SELFIELD.
CASE UCOMM.
  WHEN '&IC1'.
     READ TABLE IT_EKKO INTO WA_EKKO INDEX SEL_DET-TABINDEX.
     SELECT  EBELN
             EBELP
             LOEKZ
             STATU
             AEDAT
             TXZ01 INTO TABLE IT_EKPO FROM EKPO WHERE EBELN = WA_EKKO-EBELN .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
   I_CALLBACK_PROGRAM                = SY-CPROG
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
   I_STRUCTURE_NAME                  = 'EKPO'
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
*   IT_FIELDCAT                       =
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
   IT_EVENTS                         = it_event
*   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
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
  TABLES
    T_OUTTAB                          = IT_EKPO
* 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.
  ENDCASE.
ENDFORM .