SAP ABAP Hierarchial ALV
REPORT Z_HIERARCHIAL_ALV.
TABLES: VBAK.
TYPES: BEGIN OF ST_VBAK,
VBELN TYPE VBELN_VA,
ERDAT TYPE ERDAT,
ERNAM TYPE ERNAM,
VBTYP TYPE VBTYP,
END OF ST_VBAK,
BEGIN OF ST_VBAP,
VBELN TYPE VBELN_VA,
POSNR TYPE POSNR,
MATNR TYPE MATNR,
MATKL TYPE MATKL,
END OF ST_VBAP.
DATA: IT_VBAK TYPE STANDARD TABLE OF ST_VBAK,
IT_VBAP TYPE STANDARD TABLE OF ST_VBAP,
IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
W_VBAK TYPE ST_VBAK,
W_VBAP TYPE ST_VBAP,
W_FCAT TYPE SLIS_FIELDCAT_ALV,
V_KEY TYPE slis_keyinfo_alv.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
SELECT VBELN
ERDAT
ERNAM VBTYP FROM VBAK
INTO TABLE IT_VBAK
WHERE VBELN IN S_VBELN.
SELECT VBELN
POSNR
MATNR
MATKL FROM VBAP
INTO TABLE IT_VBAP
FOR ALL ENTRIES IN IT_VBAK
WHERE VBELN = IT_VBAK-VBELN.
W_FCAT-COL_POS = '1'.
W_FCAT-FIELDNAME = 'VBELN'.
W_FCAT-SELTEXT_M = 'Sales Ord No'.
W_fCAT-TABNAME = 'VBAK'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '2'.
W_FCAT-FIELDNAME = 'ERDAT'.
W_FCAT-SELTEXT_M = 'Created On'.
W_fCAT-TABNAME = 'VBAK'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '3'.
W_FCAT-FIELDNAME = 'ERNAM'.
W_FCAT-SELTEXT_M = 'Created By'.
W_fCAT-TABNAME = 'VBAK'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '4'.
W_FCAT-FIELDNAME = 'VBTYP'.
W_FCAT-SELTEXT_M = 'Sales Type'.
W_fCAT-TABNAME = 'VBAK'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '5'.
W_FCAT-FIELDNAME = 'VBELN'.
W_FCAT-SELTEXT_M = 'Sales Ord No'.
W_fCAT-TABNAME = 'VBAP'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '6'.
W_FCAT-FIELDNAME = 'POSNR'.
W_FCAT-SELTEXT_M = 'Doc type'.
W_fCAT-TABNAME = 'VBAP'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '7'.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-SELTEXT_M = 'Mat No'.
W_fCAT-TABNAME = 'VBAP'.
APPEND W_FCAT TO IT_FCAT.
W_FCAT-COL_POS = '8'.
W_FCAT-FIELDNAME = 'MATKL'.
W_FCAT-SELTEXT_M = 'Mat Group'.
W_fCAT-TABNAME = 'VBAP'.
APPEND W_FCAT TO IT_FCAT.
v_key-HEADER01 = 'VBELN'.
v_key-ITEM01 = 'VBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_CALLBACK_PROGRAM =
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* 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 = 'VBAK'
i_tabname_item = 'VBAP'
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = V_KEY
* 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_VBAK
t_outtab_item = IT_VBAP
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com
Social Plugin