48 Flares Twitter 0 Facebook 48 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 48 Flares ×

It is used to display the header and item details in a hierarchical manner.

Note: REUSE_ALV_HIERSEQ_LIST_DISPLAY is the function module which is used to display the header and item details in hierarchical manner.

The input for the above function module is

1. Two internal tables one is header and another one is item data internal table

2. Key info work area

Note: whenever we are working with the hierarchical ALV we need to fill the field catalog manually.

Key info work area contains link fields of both header and item data internal tables.

Fields in the key info work area: 

Header01

Item01

Header02

Item02

Header03

Item03

And so on.

In the SLIS we have one type SLIS_KEYINFO_ALV which contains the above fields so we simply declare the work area by referring SLIS_KEYINFO_ALV.

Object: Based on the given purchasing document to display the document header (EBELN, BEDAT,LIFNR ) and item data (EBELP,MENGE,MELNS,NETPR) in a hierarchical manner.

Hierarchical ALV Example:

*&———————————————————————*
*& Report  ZHIERARCHY_REPORT
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT ZHIERARCHY_REPORT.

*// Declaration Type Group
TYPE-POOLS:SLIS,ICON.

*// Table Declaration
TABLES EKKO.
*// types Declaration for EKKO
TYPES : BEGIN OF TY_EKKO,
EBELN TYPE EBELN,
AEDAT TYPE ERDAT,
LIFNR TYPE ELIFN,
ICON  TYPE ICON_D,
EXPAND,
END   OF TY_EKKO.

*// types Dclaration for EKPO
TYPES : BEGIN OF TY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
LOEKZ TYPE ELOEK,
STATU  TYPE ASTAT,
AEDAT  TYPE PAEDT,
END   OF TY_EKPO.

*// Internal Table declaration
DATA : LT_EKKO TYPE TABLE OF TY_EKKO,
LT_EKPO TYPE TABLE OF TY_EKPO.

*// Workarea declaration
DATA : WA_EKKO TYPE TY_EKKO,
WA_EKPO TYPE TY_EKPO.

*// Data declaration for ALV Report
DATA : LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_LAYOUT   TYPE SLIS_LAYOUT_ALV,
KEY         TYPE SLIS_KEYINFO_ALV.

*// Selection screen Design
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
SELECTION-SCREEN END   OF BLOCK BLK1.

*// Populate data from Fieldcatlog
WA_FIELDCAT-COL_POS   = 1.
WA_FIELDCAT-FIELDNAME = ‘EBELN’.
WA_FIELDCAT-TABNAME   = ‘LT_EKKO’.
WA_FIELDCAT-SELTEXT_M = ‘DOC NUMBER’.
WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS   = 2.
WA_FIELDCAT-FIELDNAME = ‘AEDAT’.
WA_FIELDCAT-TABNAME   = ‘LT_EKKO’.
WA_FIELDCAT-SELTEXT_M = ‘DATE’.
*WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS   = 3.
WA_FIELDCAT-FIELDNAME = ‘LIFNR’.
WA_FIELDCAT-TABNAME   = ‘LT_EKKO’.
WA_FIELDCAT-SELTEXT_M = ‘VENDOR ACC NUM’.
*WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS   = 4.
WA_FIELDCAT-FIELDNAME = ‘EBELP’.
WA_FIELDCAT-TABNAME   = ‘LT_EKPO’.
WA_FIELDCAT-SELTEXT_M = ‘ITEM NUM’.
WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS   = 5.
WA_FIELDCAT-FIELDNAME = ‘LOEKZ’.
WA_FIELDCAT-TABNAME   = ‘LT_EKPO’.
WA_FIELDCAT-SELTEXT_M = ‘DELETION INDICATOR’.
*WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS   = 6.
WA_FIELDCAT-FIELDNAME = ‘STATU’.
WA_FIELDCAT-TABNAME   = ‘LT_EKPO’.
WA_FIELDCAT-SELTEXT_M = ‘RFQ STATUS’.
*WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

WA_FIELDCAT-COL_POS   = 7.
WA_FIELDCAT-FIELDNAME = ‘AEDAT’.
WA_FIELDCAT-TABNAME   = ‘LT_EKPO’.
WA_FIELDCAT-SELTEXT_M = ‘CHANGE DATE’.
*WA_FIELDCAT-KEY       = ‘X’.
APPEND WA_FIELDCAT TO LT_FIELDCAT.
CLEAR  WA_FIELDCAT.

*// Retrieve data from Table EKKO
SELECT EBELN AEDAT LIFNR
FROM EKKO
INTO TABLE LT_EKKO
WHERE EBELN IN S_EBELN.

IF SY-SUBRC EQ 0.
*// retrieve data from table EKPO
SELECT EBELN EBELP LOEKZ STATU AEDAT
FROM EKPO
INTO TABLE LT_EKPO
FOR ALL ENTRIES IN LT_EKKO
WHERE EBELN = LT_EKKO-EBELN.
ENDIF.

*// To Expand Header table for Item Details
IT_LAYOUT-EXPAND_FIELDNAME  = ‘EXPAND’.
IT_LAYOUT-WINDOW_TITLEBAR   = ‘Hierarchical ALV list display’.
IT_LAYOUT-LIGHTS_TABNAME    = ‘LT_EKPO’.
IT_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.

*// *key infomation for the header and item table
KEY-HEADER01 = ‘EBELN’.
KEY-ITEM01   = ‘EBELN’.

*// Display output in List Format
CALL FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT          = IT_LAYOUT
IT_FIELDCAT        = LT_FIELDCAT
I_TABNAME_HEADER   = ‘LT_EKKO’
I_TABNAME_ITEM     = ‘LT_EKPO’
IS_KEYINFO         = KEY
TABLES
T_OUTTAB_HEADER    = LT_EKKO
T_OUTTAB_ITEM      = LT_EKPO.

*// adding icon to the header table
LOOP AT LT_EKKO INTO WA_EKKO.
AT NEW EBELN.
WA_EKKO-ICON = ‘@3M@’.
MODIFY LT_EKKO FROM WA_EKKO TRANSPORTING ICON WHERE EBELN EQ WA_EKKO-EBELN.
CLEAR :  WA_EKKO.
ENDAT.
ENDLOOP.

Output:

Click on execute(F8) button.

Hierarchical ALVClick on execute(F8) button then you will get a output as shown below.

Hierarchical ALV

 

That’s it.

Enjoy 🙂

Also Read:

Blocked ALV Report in SAP ABAP using MARA, MARC and MARD.

ALV Tree Display in SAP ABAP.

Dynamic selection screen in SAP ABAP.

Implement the BADI to download the vendor Data in a excel sheet.

48 Flares Twitter 0 Facebook 48 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 48 Flares ×