Saturday, December 18, 2010
Function module REUSE_ALV_HIERSEQ_LIST_DISPLAY is used to display records in hierarchical manner.

REPORT ZTEST_PROGRAM.
DATA:
      BEGIN OF IT_EKKO OCCURS 0,
        EBELN TYPE EKKO-EBELN,
        BUKRS TYPE EKKO-BUKRS,
        BSTYP TYPE EKKO-BSTYP,
        BSART TYPE EKKO-BSART,
      END OF IT_EKKO.
DATA: BEGIN OF IT_EKPO OCCURS 0,
  EBELN TYPE EKPO-EBELN,
  EBELP TYPE EKPO-EBELP,
  LOEKZ TYPE EKPO-LOEKZ,
  TXZ01 TYPE EKPO-TXZ01,
  MATNR TYPE EKPO-MATNR,
END OF IT_EKPO.
TYPE-POOLS : SLIS.
DATA :
      IT_EVENTS   TYPE SLIS_T_EVENT,
      WA_EVENTS   TYPE SLIS_ALV_EVENT,
      IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FIELDCAT LIKE LINE OF IT_FIELDCAT,
      LIST_LAYOUT TYPE SLIS_LAYOUT_ALV,
      GS_KEYINFO  TYPE SLIS_KEYINFO_ALV.
DATA:
      PROGRAM TYPE SY-REPID.

START-OF-SELECTION.
  PROGRAM = SY-REPID.
  SELECT * FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO UP TO 100 ROWS.
  IF NOT IT_EKKO[] IS INITIAL.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_EKPO FROM EKPO FOR ALL ENTRIES IN IT_EKKO
    WHERE EBELN = IT_EKKO-EBELN.
  ENDIF.
  GS_KEYINFO-HEADER01 = 'EBELN'.
  GS_KEYINFO-ITEM01   = 'EBELN'.
  DEFINE FIELDCATALOG.
    WA_FIELDCAT-COL_POS   = &1.
    WA_FIELDCAT-FIELDNAME = &2.
    WA_FIELDCAT-TABNAME   = &3.
    WA_FIELDCAT-SELTEXT_M = &4.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    CLEAR  WA_FIELDCAT.
  END-OF-DEFINITION.
  FIELDCATALOG:
  '1' 'EBELN' 'IT_EKKO' 'EKKO-EBELN',
  '2' 'BUKRS' 'IT_EKKO' 'EKKO-BUKRS',
  '3' 'BSTYP' 'IT_EKKO' 'EKKO-BSTYP',
  '4' 'BSART' 'IT_EKKO' 'EKKO-BSART'.

  FIELDCATALOG:
  '1' 'EBELN' 'IT_EKPO' 'EKPO-EBELN',
  '2' 'EBELP' 'IT_EKPO' 'EKPO-EBELP',
  '3' 'LOEKZ' 'IT_EKPO' 'EKPO-LOEKZ',
  '4' 'TXZ01' 'IT_EKPO' 'EKPO-TXZ01',
  '5' 'MATNR' 'IT_EKPO' 'EKPO-MATNR'.
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM = PROGRAM
      IT_FIELDCAT        = IT_FIELDCAT
      I_TABNAME_HEADER   = 'IT_EKKO'
      I_TABNAME_ITEM     = 'IT_EKPO'
      IS_KEYINFO         = GS_KEYINFO
    TABLES
      T_OUTTAB_HEADER    = IT_EKKO
      T_OUTTAB_ITEM      = IT_EKPO.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.