15/05/2013

Display Hierarchical List of Purchase order and item

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

REPORT  Z_ALV_HER_PURCHASEORDER_ITEM.
TYPE-POOLS SLIS.

DATA : IT_EKKO TYPE  TABLE OF EKKO,
       IT_EKPO TYPE  TABLE OF EKPO .


DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
       IT_EVENT    TYPE SLIS_T_EVENT,
       GS_KEY_INFO TYPE slis_keyinfo_alv.


START-OF-SELECTION .
PERFORM READ_DATA .
PERFORM FILL_KEY_INFO .
PERFORM FILL_FIELDCAT  USING 'IT_EKKO'   'EKKO' .
PERFORM FILL_FIELDCAT  USING 'IT_EKPO'   'EKPO' .
PERFORM DISPLAY_HER_DATA.



*&---------------------------------------------------------------------*
*&      Form  READ_DATA
*&---------------------------------------------------------------------*

FORM READ_DATA .
SELECT * INTO TABLE IT_EKKO FROM EKKO UP TO 20 ROWS.

  IF NOT IT_EKKO IS INITIAL .
    SELECT  * INTO TABLE IT_EKPO FROM EKPO FOR ALL ENTRIES IN
                          IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
  ENDIF.
ENDFORM.                    " READ_DATA


*&---------------------------------------------------------------------*
*&      Form  FILL_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FILL_FIELDCAT USING IT_TAB  TYPE C
                         IT_STRC TYPE C .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME                =  SY-CPROG
   I_INTERNAL_TABNAME            =  IT_TAB
   I_STRUCTURE_NAME              =  IT_STRC
*   I_CLIENT_NEVER_DISPLAY       = 'X'
*   I_INCLNAME                   =
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
  CHANGING
    CT_FIELDCAT                  = IT_FIELDCAT
* 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.

ENDFORM.                    " FILL_FIELDCAT

*&---------------------------------------------------------------------*
*&      Form  FILL_KEY_INFO
*&---------------------------------------------------------------------*
FORM FILL_KEY_INFO .
CLEAR GS_KEY_INFO .
GS_KEY_INFO-HEADER01  =   'EBELN'.
GS_KEY_INFO-ITEM01    =   'EBELN' .
GS_KEY_INFO-HEADER02  =   SPACE.
GS_KEY_INFO-ITEM02    =   'EBELP'.
ENDFORM.                    " FILL_KEY_INFO

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_HER_DATA
*&---------------------------------------------------------------------*

FORM DISPLAY_HER_DATA .

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
  EXPORTING
*   I_INTERFACE_CHECK              = ' '
    I_CALLBACK_PROGRAM             = SY-CPROG
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IS_LAYOUT                      =
    IT_FIELDCAT                    = IT_FIELDCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
    I_TABNAME_HEADER               = 'IT_EKKO'
    I_TABNAME_ITEM                 = 'IT_EKPO'
*   I_STRUCTURE_NAME_HEADER        =
*   I_STRUCTURE_NAME_ITEM          =
    IS_KEYINFO                     = GS_KEY_INFO
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                =
*   IR_SALV_HIERSEQ_ADAPTER        =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    T_OUTTAB_HEADER                = IT_EKKO
    T_OUTTAB_ITEM                  = 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.

ENDFORM.                    " DISPLAY_HER_DATA

No comments:

Post a Comment