- SAP ABAP Reports
- Report Types and Events
- Message Class
- Example of Classical Report
- Example of Interactive Report
- Example of ALV Report
- Example of Blocked ALV Report
- Example of Hierarchical Report
- Module Pool Programming
- Screen Painter Components
- Events in Flow Logic Editor
- Screen Elements and Creation Steps
- Working with Validations
- Database Operations
- OO Programming in ABAP
- Types of Programming Structure
- Key Features of OO Programming
- Classes and Objects
- Types of Visibility Section
- Class Defination and Implementation
- Object Creation for Class
- Method Declaration and Implementation
- Types of Component Class
- Global Class and implement GLOBAL methods
- OOP's ALV
- OOP's BDC
24REPORT1808 – Hierarchical Report Example
*&———————————————————————*
*& Report Z_HIERARCHICAL_REPORT
*&———————————————————————*
*&
*&———————————————————————*
REPORT Z_HIERARCHICAL_REPORT.
TABLES: EKKO, EKPO.
TYPE-POOLS: slis.
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EKKO-EBELN,
BUKRS TYPE EKKO-BUKRS,
AEDAT TYPE EKKO-AEDAT,
ERNAM TYPE EKKO-ERNAM,
EXPAND,
END OF TY_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO,
WA_EKKO TYPE TY_EKKO.
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATKL TYPE EKPO-MATKL,
END OF TY_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF TY_EKPO,
WA_EKPO TYPE TY_EKPO.
DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV,
IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_KEY TYPE SLIS_KEYINFO_ALV.
INITIALIZATION.
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN.
START-OF-SELECTION.
PERFORM GET_EKKO.
PERFORM GET_EKPO.
PERFORM FIELD_CATALOG.
PERFORM ALV_LAYOUT.
PERFORM KEY_INFO.
PERFORM ALV_HIERSEQ_LIST_DISPLAY.
*&———————————————————————*
*& Form GET_EKKO
*&———————————————————————*
*
*———————————————————————-*
FORM GET_EKKO.
IF S_EBELN[] IS NOT INITIAL.
SELECT EBELN
BUKRS
AEDAT
ERNAM
FROM EKKO INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
IF sy-subrc = 0.
SORT IT_EKKO.
ELSE.
MESSAGE ‘PO doesn”t exist’ TYPE ‘I’.
ENDIF.
ELSE.
MESSAGE ‘Enter a Valid PO’ TYPE ‘I’.
ENDIF.
ENDFORM.
*&———————————————————————*
*&———————————————————————*
* Get data from PO item
*———————————————————————-*
FORM GET_EKPO.
IF IT_EKKO IS NOT INITIAL.
SELECT EBELN
EBELP
AEDAT
MATKL
FROM EKPO INTO TABLE IT_EKPO
FOR ALL ENTRIES IN IT_EKKO
WHERE EBELN = IT_EKKO-EBELN.
IF sy-subrc = 0.
SORT IT_EKPO.
ENDIF.
ENDIF.
ENDFORM.
*&———————————————————————*
*& Form field_catalog
*&———————————————————————*
*
*———————————————————————-*
FORM FIELD_CATALOG.
IF IT_EKKO IS NOT INITIAL.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = ‘EBELN’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Purchase Order’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = ‘BUKRS’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Company Code’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = ‘AEDAT’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Creation Date’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = ‘ERNAM’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Created By’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDIF.
IF it_ekpo IS NOT INITIAL.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = ‘EBELN’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Purchase Order’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = ‘EBELP’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Item’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = ‘MATKL’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Material Group’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 8.
wa_fcat-fieldname = ‘AEDAT’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Creation Date’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDIF.
ENDFORM.
*&———————————————————————*
*& Form alv_layout
*&———————————————————————*
* ALV layout
*———————————————————————-*
FORM alv_layout .
wa_layout-zebra = ‘X’.
wa_layout-colwidth_optimize = ‘X’.
wa_layout-expand_fieldname = ‘EXPAND’.
wa_layout-window_titlebar = ‘Hierarchical PO Header & Item Display’.
ENDFORM.
*&———————————————————————*
*&———————————————————————*
*———————————————————————-*
FORM key_info.
wa_key-header01 = ‘EBELN’. “Purchase Order number
wa_key-item01 = ‘EBELN’.
ENDFORM.
*&———————————————————————*
*& Form alv_hierseq_list_display
*&———————————————————————*
* Calling the ALV Hierseq List Display
*———————————————————————-*
FORM alv_hierseq_list_display .
IF it_fcat IS NOT INITIAL.
CALL FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
EXPORTING
i_callback_program = sy-repid
is_layout = wa_layout
it_fieldcat = it_fcat
i_tabname_header = ‘IT_EKKO’
i_tabname_item = ‘IT_EKPO’
is_keyinfo = wa_key
TABLES
t_outtab_header = it_ekko
t_outtab_item = it_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ‘Internal Error’ TYPE ‘I’.
ENDIF.
ENDIF.
ENDFORM.
Output:
Author : Aniket Pawar, 9373518385
24REPORT1808 – Hierarchical Report Example
*&———————————————————————*
*& Report Z_HIERARCHICAL_REPORT
*&———————————————————————*
*&
*&———————————————————————*
REPORT Z_HIERARCHICAL_REPORT.
TABLES: EKKO, EKPO.
TYPE-POOLS: slis.
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EKKO-EBELN,
BUKRS TYPE EKKO-BUKRS,
AEDAT TYPE EKKO-AEDAT,
ERNAM TYPE EKKO-ERNAM,
EXPAND,
END OF TY_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO,
WA_EKKO TYPE TY_EKKO.
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATKL TYPE EKPO-MATKL,
END OF TY_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF TY_EKPO,
WA_EKPO TYPE TY_EKPO.
DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV,
IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_KEY TYPE SLIS_KEYINFO_ALV.
INITIALIZATION.
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN.
START-OF-SELECTION.
PERFORM GET_EKKO.
PERFORM GET_EKPO.
PERFORM FIELD_CATALOG.
PERFORM ALV_LAYOUT.
PERFORM KEY_INFO.
PERFORM ALV_HIERSEQ_LIST_DISPLAY.
*&———————————————————————*
*& Form GET_EKKO
*&———————————————————————*
*
*———————————————————————-*
FORM GET_EKKO.
IF S_EBELN[] IS NOT INITIAL.
SELECT EBELN
BUKRS
AEDAT
ERNAM
FROM EKKO INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
IF sy-subrc = 0.
SORT IT_EKKO.
ELSE.
MESSAGE ‘PO doesn”t exist’ TYPE ‘I’.
ENDIF.
ELSE.
MESSAGE ‘Enter a Valid PO’ TYPE ‘I’.
ENDIF.
ENDFORM.
*&———————————————————————*
*&———————————————————————*
* Get data from PO item
*———————————————————————-*
FORM GET_EKPO.
IF IT_EKKO IS NOT INITIAL.
SELECT EBELN
EBELP
AEDAT
MATKL
FROM EKPO INTO TABLE IT_EKPO
FOR ALL ENTRIES IN IT_EKKO
WHERE EBELN = IT_EKKO-EBELN.
IF sy-subrc = 0.
SORT IT_EKPO.
ENDIF.
ENDIF.
ENDFORM.
*&———————————————————————*
*& Form field_catalog
*&———————————————————————*
*
*———————————————————————-*
FORM FIELD_CATALOG.
IF IT_EKKO IS NOT INITIAL.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = ‘EBELN’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Purchase Order’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = ‘BUKRS’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Company Code’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = ‘AEDAT’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Creation Date’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = ‘ERNAM’.
wa_fcat-tabname = ‘IT_EKKO’.
wa_fcat-seltext_l = ‘Created By’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDIF.
IF it_ekpo IS NOT INITIAL.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = ‘EBELN’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Purchase Order’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = ‘EBELP’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Item’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = ‘MATKL’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Material Group’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-col_pos = 8.
wa_fcat-fieldname = ‘AEDAT’.
wa_fcat-tabname = ‘IT_EKPO’.
wa_fcat-seltext_l = ‘Creation Date’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDIF.
ENDFORM.
*&———————————————————————*
*& Form alv_layout
*&———————————————————————*
* ALV layout
*———————————————————————-*
FORM alv_layout .
wa_layout-zebra = ‘X’.
wa_layout-colwidth_optimize = ‘X’.
wa_layout-expand_fieldname = ‘EXPAND’.
wa_layout-window_titlebar = ‘Hierarchical PO Header & Item Display’.
ENDFORM.
*&———————————————————————*
*&———————————————————————*
*———————————————————————-*
FORM key_info.
wa_key-header01 = ‘EBELN’. “Purchase Order number
wa_key-item01 = ‘EBELN’.
ENDFORM.
*&———————————————————————*
*& Form alv_hierseq_list_display
*&———————————————————————*
* Calling the ALV Hierseq List Display
*———————————————————————-*
FORM alv_hierseq_list_display .
IF it_fcat IS NOT INITIAL.
CALL FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
EXPORTING
i_callback_program = sy-repid
is_layout = wa_layout
it_fieldcat = it_fcat
i_tabname_header = ‘IT_EKKO’
i_tabname_item = ‘IT_EKPO’
is_keyinfo = wa_key
TABLES
t_outtab_header = it_ekko
t_outtab_item = it_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ‘Internal Error’ TYPE ‘I’.
ENDIF.
ENDIF.
ENDFORM.
Output:
Author : Aniket Pawar, 9373518385