Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function Module or Class to generate a global class

Former Member
0 Likes
1,214

Hi all,

Does anyone know a function module or a class with which I can generate a global class implementing a predefined global interface and fill the methods of the generated class dynamically with coding?

Thanks in advance.

Sükrü

5 REPLIES 5
Read only

Former Member
0 Likes
896

HI,

Global internal table can be declared which can accessed by other classes based on the access specifier (public,private,protected)

Step-1 Create table type(ZTABLETYPE) in SE11 which refres to the table (ZTABLE)

Step-2 in SE24, in attribute column keep itab and in assiciated type keep ZTABLETYPE

That's a way of global declaration for internal table in Global Class(SE24).

REGARDS

WARUN

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
896

There is not a function module or class for this. I'm not sure how this will help you in your requirement anyway, because if it is to run in a productive system, which should not be open for changes, your program would not be allowed to create the global class anyway. Unfortunatly, I think your best way to proceed would be to use a generated subroutine, yes not as elegant, but I think this is the way to go.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
896

Hi Rich,

I want to generate classes in a development system. And I do not want to generate classes on the fly during program run. I want to write a report which reads some certain meta data from the database, and based on this generates a class with a specific method(which is a method of a global interface) and then I want to put coding into this method dynamically. And as SE24 definitely uses some APIs to generate classes, it must be possible, I guess.

Regards,

Sükrü

Read only

Former Member
0 Likes
896

I found the class for generating a class :

SEO_CLASS_CREATE_COMPLETE

Read only

analytics
Product and Topic Expert
Product and Topic Expert
0 Likes
896

CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE'

EXPORTING

corrnr = korrnum

devclass = devclass

version = seoc_version_active

overwrite = overwrite

IMPORTING

korrnr = korrnum

CHANGING

class = gs_class

inheritance = gs_inheritance

redefinitions = gt_redefinitions

implementings = gt_implementings

impl_details = gt_impl_details

attributes = gt_attributes

methods = gt_methods

events = gt_events

types = gt_types

type_source = gt_type_source

PARAMETERS = gt_parameters

exceps = gt_exceps

aliases = gt_aliases

typepusages = gt_typepusages

clsdeferrds = gt_clsdeferrds

intdeferrds = gt_intdeferrds

friendships = gt_friendships

EXCEPTIONS

OTHERS = 7.

IF sy-subrc <> 0.

MESSAGE 'Error generating class' TYPE 'E'.

ENDIF.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Generating local class definitions'.

CALL FUNCTION 'SEO_CLASS_GENERATE_LOCALS'

EXPORTING

clskey = clskey

force = seox_true

corrnr = korrnum

implementation = gt_locals_src

locals_def = gt_locals_def

locals_imp = gt_locals_imp

locals_mac = gt_locals_mac

EXCEPTIONS

OTHERS = 5.