ABAP Object-Oriented Reporting
ABAP reports are traditionally written as procedural (non-object-oriented) programs. The goal of this project is to provide a small bridge that lets you structure an executable report around an OO class instead.
In other words: you keep the normal report entry points (selection screen, events, etc.), but the actual report logic lives in a class that you can design, test, and reuse more easily.
Note: There are still some limitations, because the ABAP runtime triggers certain events procedurally.
-
Create an executable report in the ABAP editor.
-
Include the bridge include:
INCLUDE zcrm_oo_report_bridge. -
Create a selection screen (optional):
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01. PARAMETERS: gv_param AS CHECKBOX. SELECTION-SCREEN END OF BLOCK b01.
-
Create your report class (for example
lcl_report).Inherit from
lcl_report_baseand redefine the abstract methodstart.CLASS lcl_report DEFINITION INHERITING FROM lcl_report_base FINAL. PUBLIC SECTION. METHODS start REDEFINITION. ENDCLASS.
-
Initialize the bridge by registering your class (one line):
set_report_class lcl_report.
-
Implement your class:
CLASS lcl_report IMPLEMENTATION. METHOD start. " Your report logic goes here ENDMETHOD. ENDCLASS.
You can also copy and adapt the provided example class ZBC_OO_REPORT_BRIDGE_EXAMPLE.
To react to selection-screen events, redefine the following methods from the superclass (lcl_report_base):
-
on_load_of_program
Triggered by the ABAP runtime when the executable program is loaded into the internal session. -
on_initialization
Used to initialize the executable program. -
on_sel_screen_output
Triggered by the selection-screen PBO (Process Before Output). -
on_sel_screen_user_command
Called for user commands (function codes). Before it can be used, you must register the relevant function codes inon_initialization:set_sel_screen_valid_for_ucomm( 'FC01' ). -
on_sel_screen_exit_command
Called when an exit command is triggered on the selection screen. -
on_sel_screen_validation
Called before report execution (beforeSTART-OF-SELECTION). -
on_sel_screen_value_request
Called for F4/value help. Register the fields that should trigger value help using the provided macros:register_value_req_for_param <param_name>. register_value_req_for_selopt <selopt_name>.
To read current selection-screen values, do not read parameters/select-options directly. Instead, call
get_sel_screen_value.