10-29-2007 5:04 PM
Hi experts,
I have the doubt about class constructor.
I write the code in Class constructor like,
DATA : ZCURRSTR TYPE IHTTPNVP,
ZCURRTTYPE TYPE TIHTTPNVP.
ZCURRSTR-NAME = 'INDIA'.
ZCURRSTR-VALUE = 'RS'.
APPEND ZCURRSTR TO ZCURRTTYPE.
Now I want to call this Table ZCURRTTYPE in One of the method of Same class.
Any one help me on this issue.
Thanks in Advance,
Points Assured for all suggestions.
10-29-2007 5:09 PM
10-29-2007 5:16 PM
Hi,
Class-Constructor or A Static Constructor is the first method to be called, when we do any kind of operation on the class.
It would trigger only once in a program execution... while create the class object or when we access the class variables with out creating the object.
So The first method to be trigegred is the Constructor class.
Here is the sample code..
REPORT ysk_sdn_temp.
DATA : zcurrstr TYPE ihttpnvp,
zcurrttype TYPE tihttpnvp.
*----------------------------------------------------------------------*
* CLASS c1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS c1 DEFINITION .
PUBLIC SECTION.
CLASS-DATA : num TYPE i VALUE 5.
CLASS-METHODS:class_constructor.
METHODS: normal_method.
ENDCLASS. "c1 DEFINITION
*----------------------------------------------------------------------*
* CLASS c1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS c1 IMPLEMENTATION.
METHOD class_constructor.
WRITE:/5 'I am class constructor'.
zcurrstr-name = 'INDIA'.
zcurrstr-value = 'RS'.
APPEND zcurrstr TO zcurrttype.
ENDMETHOD. "CLASS_CONSTRUCTOR
METHOD normal_method.
WRITE:/ zcurrstr-name,
zcurrstr-value.
ENDMETHOD. "NORMAL_METHOD
ENDCLASS. "c1 IMPLEMENTATION
DATA: obj1 TYPE REF TO c1.
START-OF-SELECTION.
WRITE:/5 c1=>num.
CREATE OBJECT obj1.
obj1->normal_method( ).
Thanks,
Sreekanth
<i>Do not forget to reward if it helps you ;)</i>