Skip to content

oxgl/AbapOOReports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AbapOOReports

ABAP Object-Oriented Reporting

Overview

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.


How to create an OO report

  1. Create an executable report in the ABAP editor.

  2. Include the bridge include:

    INCLUDE zcrm_oo_report_bridge.
  3. 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.
  4. Create your report class (for example lcl_report).

    Inherit from lcl_report_base and redefine the abstract method start.

    CLASS lcl_report DEFINITION INHERITING FROM lcl_report_base FINAL.
      PUBLIC SECTION.
        METHODS start REDEFINITION.
    ENDCLASS.
  5. Initialize the bridge by registering your class (one line):

    set_report_class lcl_report.
  6. 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.


Handling selection-screen events

To react to selection-screen events, redefine the following methods from the superclass (lcl_report_base):

  1. on_load_of_program
    Triggered by the ABAP runtime when the executable program is loaded into the internal session.

  2. on_initialization
    Used to initialize the executable program.

  3. on_sel_screen_output
    Triggered by the selection-screen PBO (Process Before Output).

  4. on_sel_screen_user_command
    Called for user commands (function codes). Before it can be used, you must register the relevant function codes in on_initialization:

    set_sel_screen_valid_for_ucomm( 'FC01' ).
  5. on_sel_screen_exit_command
    Called when an exit command is triggered on the selection screen.

  6. on_sel_screen_validation
    Called before report execution (before START-OF-SELECTION).

  7. 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.

About

ABAP Object Oriented Reporting

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages