Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

4/13/23, 12:33 PM Instance constructors can have import parameters.

| SAPTech

Instance constructors can have import parameters.


 Values to them are passed at the time of CREATE OBJECT
statement to create object from the class containing the
constructor.

REPORT ZINSTA_CONST_OOPS.
class lcl_inst DEFINITION.
  PUBLIC SECTION.
  METHODS constructor IMPORTING today TYPE d.
ENDCLASS.
*&------------------------------------------------------------
---------*
*&       Class (Implementation)  lcl_inst
*&------------------------------------------------------------
---------*
*        Text
*-------------------------------------------------------------
---------*
CLASS lcl_inst IMPLEMENTATION.
METHOD constructor.
  write : / 'Today Is: ', today DD/MM/YYYY.
ENDMETHOD.
ENDCLASS.               "lcl_inst

START-OF-SELECTION.
DATA: obj1 TYPE REF TO lcl_inst.
CREATE OBJECT obj1 EXPORTING today = sy-datum.

Output : Today Is:  19.03.2017


Facebook Page [https://www.facebook.com/mySAPTech/]

Posted 19th March 2017 by Blogger

0 Add a comment

https://mysapnuts.blogspot.com/2017/03/instance-constructors-can-have-import.html?view=sidebar 1/2
4/13/23, 12:33 PM Instance constructors can have import parameters. | SAPTech

To leave a comment, click the button below to sign in with


Google.

SIGN IN WITH GOOGLE

https://mysapnuts.blogspot.com/2017/03/instance-constructors-can-have-import.html?view=sidebar 2/2

You might also like