public class constructors
TRANSCRIPT
-
7/21/2019 Public Class Constructors
1/10
Working with constructors (Global Class)
By Sravanthi
1. Constructors are special methods that cannot be called using CALL METH!. "nstead# they arecalled automatically by the system to set the starting state o$ a ne% ob&ect or class.
'. Constructors are methods %ith a prede$ined name. To use them# you must declare them e(plicitlyin the class.
). There are t%o types o$ constructors * "nstance constructors and Static constructors.
The "nstance constructor o$ a class is the prede$ined instance method CONSTRUCTOR.
The constructor+s signature can have only importing parameters or e(ceptions.
"nstance Constructor is a special instance method can access the "nstance ,ariables and
Static ,ariables.
This method is used to set the de$ault values in a class.
The Static constructor o$ a class is the prede$ined static method CLASS_CONSTRUCTOR.
The constructor+s signature cannot have importing parameters or e(ceptions.
The static constructor is as special static method can access the static variables.
These are used to set de$ault values $or the global attributes irrespective o$ instances.
Multiple "nstance and Static Constructors cannot be used in one class.
Creating the Instance Constructorand Static Constructorusing SE'- /lobal class0
Step1 /o to SE'-Create /lobal Class 2C3ST45CT46SALES
Step2 Select the Class and Clic7 on Continue.
-
7/21/2019 Public Class Constructors
2/10
Step3 Continue %ith the de$ault settings
Step4 /o to MethodsCreate Methods.
Step5 Constructor Method can be created ' %ays.
10 /o to MenuEditCreate Constructor
'0 Clic7 on Constructor as sho%n belo%
Step6 As soon clic7 on ConstructorConstructor Method is automatically de$aulted in the Methods.
This method is used o initial the values $or the ob&ect
-
7/21/2019 Public Class Constructors
3/10
Step7 Create another method Select to $etch the data $rom the ,BA8 table
Step8 Select the Constructor MethodSelect the 9arameters and Create the 9arameter
Step The parameter "M6,BEL3 is used to importing into Constructor Method. 5sed to initiali:e thevalue
Step1! ;or the Constructor# parameter type is al%ays importing. 3o other 9arameter type can beassigned
-
7/21/2019 Public Class Constructors
4/10
Step11" /o to Type TabCreate Structure ty6vba7 and ,isibility 9ublic0
Step12" Clic7 on !irect Type Entry
Step13" To declare the Structure %ith re
-
7/21/2019 Public Class Constructors
5/10
Working with constructors (Global Class)
...#re$ious
Step14" t6vba7 is de$aulted in the Types tab %hich has be declared in earlier step
Step15 "n the Attributes TabCreate ,6,BEL3 type vba7*vbeln.
Step16 !ouble clic7 the Constructor and "mplement the code.
http://saptechnical.com/Tutorials/OOPS/Constructor/Index.htmhttp://saptechnical.com/Tutorials/OOPS/Constructor/Index.htm -
7/21/2019 Public Class Constructors
6/10
Step17" /o to Select MethodCreate 9arameters
Step18" /o to Select Method!ouble Clic7 the Method and "mplement the code
Step18" Activate the Class and /o to SE)=Create a 9rogram 2C3ST45CT46SALES.
"mplement the code and e(ecute the 9rogram
-
7/21/2019 Public Class Constructors
7/10
Step2!" E(ecute the 9rogram %ithout giving any sales document number.
Step21" The utput is displayed as sho%n belo% %ith the Constructor method %ith the de$ault initial
values
Step22" /ive the Sales !ocument as ->?1
-
7/21/2019 Public Class Constructors
8/10
Step23" The output is displayed $or the corresponding Sales document
Static Constructor
Step24 @ithin the Same /lobal Class Create the Static Constructor. Clic7 on Class Constructor
4
MenuEditCreate Class Constructor.
Step25 Class Constructor Method is de$aulted as sho%n belo% as soon as the Class Constructor is
Clic7ed or Selected.
-
7/21/2019 Public Class Constructors
9/10
Step26 Select the Class Constructor and Clic7 on 9arameters$ollo%ing message is displayed.
Class Constructor does not have 9arameters.
Step27 !ouble Clic7 the Class6Constructor method and %rite the @rite Statement
Step28 /o to SE)= and e(ecute the same program 2C3ST45CT46SALES. The Class
Constructor is triggered.
-
7/21/2019 Public Class Constructors
10/10