How to run a class Method as a transaction!


Yes it is true with the new OO ABAP we can create transactions i.e. OO Transactions.
Create a program i.e. subroutine pool and create a class with a public method as shown below.

PROGRAM  z_oo_transaction_demo.

*----------------------------------------------------------------------*
*       CLASS zcl_demo_class DEFINITION
*----------------------------------------------------------------------*
* Local class Definition
*----------------------------------------------------------------------*
CLASS zcl_demo_class DEFINITION.
  
PUBLIC SECTION.
    
METHODS main_method.
ENDCLASS.                    "zcl_demo_class DEFINITION

*----------------------------------------------------------------------*
*       CLASS zcl_demo_class DEFINITION
*----------------------------------------------------------------------*
*Local class Implementation
*----------------------------------------------------------------------*
CLASS zcl_demo_class IMPLEMENTATION.
  
METHOD main_method.
    
MESSAGE 'Instance method in local class' TYPE 'I'.
  
ENDMETHOD.                    "main_method
ENDCLASS.                       
"zcl_demo_class IMPLEMENTATION


Now create a transaction in the program as shown in below image. Select method of a class ( OO transaction ).

Create OO Transaction
Give the transaction text and uncheck the OO transaction model.
Now give the details shown below in image and save this. That’s it you are done. Go and execute the transaction.
Add Class and method
 Output of the execution.
Output