SAP Virtual/Onsite Trainings

Document Categories:

What's New?


Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 

Join the Mailing List
Enter name and email address below:
Subscribe  Unsubscribe 

Working with constructors (Global Class)

By Sravanthi

1.     Constructors are special methods that cannot be called using CALL METHOD. Instead, they are called automatically by the system to set the starting state of a new object or class.

2.     Constructors are methods with a predefined name. To use them, you must declare them explicitly in the class.

3.     There are two types of constructors - Instance constructors and Static constructors.  

·         The Instance constructor of a class is the predefined instance method CONSTRUCTOR.

·         The constructor's signature can have only importing parameters or exceptions.

·         Instance Constructor is a special instance method can access the Instance Variables and Static Variables. 

·         This method is used to set the default values in a class.         

·         The Static constructor of a class is the predefined static method CLASS_CONSTRUCTOR.

·         The constructor's signature cannot have importing   parameters or exceptions.

·         The static constructor is as special static method can access the static variables.

·         These are used to set default values for the global attributes irrespective of instances.

·         Multiple Instance and Static Constructors cannot be used in one class.  

Creating the Instance Constructor and Static Constructor using SE24 (Global class)

Step1: Go to SE24 à Create Global Class ZCONSTRUCTOR_SALES


Step2: Select the Class and Click on Continue.


Step3: Continue with the default settings


Step4: Go to Methods à Create Methods.


Step5: Constructor Method can be created 2 ways.

1)     Go to Menu à Edit à Create Constructor

2)     Click on Constructor as shown below  


Step6: As soon click on Constructor à Constructor Method is automatically defaulted in the Methods.

This method is used o initial the values for the object


Step7: Create another method Select to fetch the data from the VBAK table


Step8: Select the Constructor Method à Select the Parameters and Create the Parameter


Step9: The parameter IM_VBELN is used to importing into Constructor Method. Used to initialize the value


Step10: For the Constructor, parameter type is always importing. No other Parameter type can be assigned


Step11: Go to Type Tab à Create Structure ty_vbak and Visibility (Public)


Step12: Click on Direct Type Entry


Step13: To declare the Structure (with required fields) and Table

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image