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

OO Object: Constructor and Static Attribute?

Former Member
0 Likes
773

I've defined an internal table to my Class as a static attribute. I would like it to be filled once during runtime and it should stay populated because it is a static attribute....right?

Please confirm: I need to create a method "Constructor". Within this method, it should load the internal table. This will occur when I say "Create Object" in my code automatically?

Am I correct?

Thank-You.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
599

Hello,

You need to create the CLASS_CONSTRUCTOR method to populate the static internal table. This method run in the first time you use the create object or when you call a static method. And this method run only once per class.

The CONSTRUCTOR method is called every time you create a new instance to the class using the command CREATE OBJECT.

So, the CLASS_CONSTRUCTOR run only once, instead the times that the class is instancied and the CONSTRUCTOR run one time per instance.

Regards,

2 REPLIES 2
Read only

Former Member
0 Likes
600

Hello,

You need to create the CLASS_CONSTRUCTOR method to populate the static internal table. This method run in the first time you use the create object or when you call a static method. And this method run only once per class.

The CONSTRUCTOR method is called every time you create a new instance to the class using the command CREATE OBJECT.

So, the CLASS_CONSTRUCTOR run only once, instead the times that the class is instancied and the CONSTRUCTOR run one time per instance.

Regards,

Read only

Former Member
0 Likes
599

Justa adding a bit more information about CLASS_CONSTRUCTOR :

They are executed once per program

They are first executed when : -Create an instance of the class or

-Acessing a static attribute of the class

-Calling a static methid of the class

-Register and event for this class