A constructor can have Import parameter and that parameter will get the value at the time of creating the object. Here we have a program where we have declared a constructor with Import parameter. Then we have implement the method constructor. After that we create the object and export a value to the import parameter.
REPORT zsr_test.
PARAMETERS p_text TYPE char20.
*----------------------------------------------------------------------*
* CLASS cl_construct DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_construct DEFINITION.
PUBLIC SECTION.
METHODS constructor IMPORTING i_text TYPE char20.
ENDCLASS. "cl_construct DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_construct IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_construct IMPLEMENTATION.
METHOD constructor.
WRITE: /3 i_text,
/3 'Date: ', sy-datum DD/MM/YYYY.
ENDMETHOD. "constructor
ENDCLASS. "cl_construct IMPLEMENTATION
START-OF-SELECTION.
DATA obj TYPE REF TO cl_construct.
CREATE OBJECT obj EXPORTING i_text = p_text.
Below is the output:
PARAMETERS p_text TYPE char20.
*----------------------------------------------------------------------*
* CLASS cl_construct DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_construct DEFINITION.
PUBLIC SECTION.
METHODS constructor IMPORTING i_text TYPE char20.
ENDCLASS. "cl_construct DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_construct IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_construct IMPLEMENTATION.
METHOD constructor.
WRITE: /3 i_text,
/3 'Date: ', sy-datum DD/MM/YYYY.
ENDMETHOD. "constructor
ENDCLASS. "cl_construct IMPLEMENTATION
START-OF-SELECTION.
DATA obj TYPE REF TO cl_construct.
CREATE OBJECT obj EXPORTING i_text = p_text.
Below is the output:
2 comments:
SAP Success Factors Real Time Hands on Training in Chennai...
Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286
Both Classroom/Online Training is Available!!!!!!
thank you for sharing nyce information really very nice ..i am intrested ur sap course for more info sap hr abap online classes
Post a Comment