Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125

What is Hierarchical ALV?

  • Hierarchical ALV allows you to display header–item relationships (like parent–child data).

  • Example: One material (MARA) is the header, and its plant details (MARC) are the items.

  • Useful for showing 1:N relationships in a single ALV output.

In the SAP function module world, this is usually done using:
👉 REUSE_ALV_HIERSEQ_LIST_DISPLAY

*&———————————————————————*
*& Report  ZTEST_PROGRAM_2
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT ztest_program_2.

TYPE-POOLSslis.

DATAit_mara TYPE TABLE OF mara,
it_marc TYPE TABLE OF marc.

DATAit_fieldcat_header TYPE slis_t_fieldcat_alv,
it_fieldcat_item   TYPE slis_t_fieldcat_alv,
wa_fieldcat        TYPE slis_fieldcat_alv.

DATAgs_keyinfo TYPE slis_keyinfo_alv.

“— Fetch Data (limit for demo)
SELECT FROM mara UP TO 10 ROWS INTO TABLE it_mara.
SELECT FROM marc UP TO 50 ROWS INTO TABLE it_marc.

“— Build Field Catalog for MARA (Header)
CLEAR wa_fieldcat.
wa_fieldcatfieldname ‘MATNR’.
wa_fieldcatseltext_m ‘Material’.
APPEND wa_fieldcat TO it_fieldcat_header.

CLEAR wa_fieldcat.
wa_fieldcatfieldname ‘MTART’.
wa_fieldcatseltext_m ‘Material Type’.
APPEND wa_fieldcat TO it_fieldcat_header.

“— Build Field Catalog for MARC (Item)
CLEAR wa_fieldcat.
wa_fieldcatfieldname ‘MATNR’.
wa_fieldcatseltext_m ‘Material’.
APPEND wa_fieldcat TO it_fieldcat_item.

CLEAR wa_fieldcat.
wa_fieldcatfieldname ‘WERKS’.
wa_fieldcatseltext_m ‘Plant’.
APPEND wa_fieldcat TO it_fieldcat_item.

CLEAR wa_fieldcat.
wa_fieldcatfieldname ‘DISMM’.
wa_fieldcatseltext_m ‘MRP Type’.
APPEND wa_fieldcat TO it_fieldcat_item.

“— Key Information (join condition between header and item)
gs_keyinfoheader01 ‘MATNR’” Header Key
gs_keyinfoitem01   ‘MATNR’” Item Key

“— Display Hierarchical ALV
CALL FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
EXPORTING
i_callback_program      syrepid
is_keyinfo              gs_keyinfo
i_structure_name_header ‘MARA’
i_structure_name_item   ‘MARC’
i_tabname_header        ‘MARA’
i_tabname_item          ‘MARC’
TABLES
t_outtab_header         it_mara
t_outtab_item           it_marc
EXCEPTIONS
program_error           1
OTHERS                  2.

IF sysubrc <> 0.
MESSAGE ID symsgid TYPE symsgty NUMBER symsgno
WITH symsgv1 symsgv2 symsgv3 symsgv4.
ENDIF.

Output:

Related Questions

Leave an answer

Leave an answer