Académique Documents
Professionnel Documents
Culture Documents
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.
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.
Creating the Instance Constructor and Static Constructor using SE24 (Global class)
Step1: Go to SE24 Create Global Class ZCONSTRUCTOR_SALES
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
Step18: Go to Select Method Double Click the Method and Implement the code
Step20: Execute the Program without giving any sales document number.
Step21: The Output is displayed as shown below with the Constructor method with the default initial
values
Static Constructor
Step24: Within the Same Global Class Create the Static Constructor. Click on Class Constructor
OR
Menu Edit Create Class Constructor.
Step25: Class Constructor Method is defaulted as shown below as soon as the Class Constructor is
Clicked or Selected.
Step26: Select the Class Constructor and Click on Parameters following message is displayed.
Class Constructor does not have Parameters.
Step27: Double Click the Class_Constructor method and write the Write Statement
Step28: Go to SE38 and execute the same program ZCONSTRUCTOR_SALES. The Class
Constructor is triggered.