ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  ABAP Objects - Overview →  Examples for ABAP Objects → 

ABAP Objects, OO Transaction

This example demonstrates the linking of a transaction code with the method of a local class.

Source Code

*&---------------------------------------------------------------------*
*& Subroutine pool  DEMO_OO_TRANSACTION                                *
*&                                                                     *
*&---------------------------------------------------------------------*

PROGRAM  demo_oo_transaction.

*

CLASS demo_class DEFINITION.
  PUBLIC SECTION.
    METHODS instance_method.
ENDCLASS.

*

CLASS demo_class IMPLEMENTATION.
  METHOD instance_method.
    cl_demo_output=>display( 'Instance method in local class' ).
  ENDMETHOD.
ENDCLASS.

Description

The program DEMO_OO_TRANSACTION is a subroutine pool that does not contain any subroutines. Instead, the program contains the definition of the local class demo_class, with which the transaction code DEMO_OO_METHOD is linked. When the transaction is called, the program is loaded, one instance of the class is created, and the method is called.