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
Beginner

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-POOLS: slis.

DATA: it_mara TYPE TABLE OF mara,
it_marc TYPE TABLE OF marc.

DATA: it_fieldcat_header TYPE slis_t_fieldcat_alv,
it_fieldcat_item   TYPE slis_t_fieldcat_alv,
wa_fieldcat        TYPE slis_fieldcat_alv.

DATA: gs_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_fieldcat–fieldname = ‘MATNR’.
wa_fieldcat–seltext_m = ‘Material’.
APPEND wa_fieldcat TO it_fieldcat_header.

CLEAR wa_fieldcat.
wa_fieldcat–fieldname = ‘MTART’.
wa_fieldcat–seltext_m = ‘Material Type’.
APPEND wa_fieldcat TO it_fieldcat_header.

“— Build Field Catalog for MARC (Item)
CLEAR wa_fieldcat.
wa_fieldcat–fieldname = ‘MATNR’.
wa_fieldcat–seltext_m = ‘Material’.
APPEND wa_fieldcat TO it_fieldcat_item.

CLEAR wa_fieldcat.
wa_fieldcat–fieldname = ‘WERKS’.
wa_fieldcat–seltext_m = ‘Plant’.
APPEND wa_fieldcat TO it_fieldcat_item.

CLEAR wa_fieldcat.
wa_fieldcat–fieldname = ‘DISMM’.
wa_fieldcat–seltext_m = ‘MRP Type’.
APPEND wa_fieldcat TO it_fieldcat_item.

“— Key Information (join condition between header and item)
gs_keyinfo–header01 = ‘MATNR’. ” Header Key
gs_keyinfo–item01   = ‘MATNR’. ” Item Key

“— Display Hierarchical ALV
CALL FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
EXPORTING
i_callback_program      = sy–repid
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 sy–subrc <> 0.
MESSAGE ID sy–msgid TYPE sy–msgty NUMBER sy–msgno
WITH sy–msgv1 sy–msgv2 sy–msgv3 sy–msgv4.
ENDIF.

Output:

Related Questions

Leave an answer

Leave an answer