04-13-2009 5:52 AM
Hi,
I have a requirement to programmatically create and activate an ABAP class that implements a 'pre-defined' interface.
Do you have any ideas how this can be done?
Thanks,
Shreevathsa S
04-13-2009 10:09 AM
Hi,
Try if GENRATE SUBROUTINE POOL keyword can be of your help.
See the below example,
DATA itab TYPE TABLE OF string.
DATA prog TYPE string.
DATA class TYPE string.
APPEND `program.` TO itab.
APPEND `class main definition.` TO itab.
APPEND ` public section.` TO itab.
APPEND ` class-methods meth.` TO itab.
APPEND `endclass.` TO itab.
APPEND `class main implementation.` TO itab.
APPEND ` method meth.` TO itab.
APPEND ` message 'Test' type 'I'.` TO itab.
APPEND ` endmethod.` TO itab.
APPEND `endclass.` TO itab.
GENERATE SUBROUTINE POOL itab NAME prog.
CONCATENATE `\PROGRAM=` prog `\CLASS=MAIN` INTO class.
CALL METHOD (class)=>meth.
Regards,
Sesh