2013 Jan 26 9:26 AM
Dear Experts,
How to pass value to interface in objects- interface IF_UJA_APPSET_DATA
I am not much familier with OOPS.
Kindly help me to sort out the issue
Interface Name = IF_UJA_APPSET_DATA
data: abcd type REF TO IF_UJA_APPSET_DATA.
CALL METHOD ABCDE->GET_PARAM_VALUE
EXPORTING
I_TYPE = 'SYSTEM'
I_PARAM_NAME = 'RTRCT_CC_COST_DEST'
RECEIVING
R_VALUE = l_appl_param.
.
when i pass like dis i am getting the below error
An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause
Dereferencing the NULL reference
Regards,
Srinivasan.V
2013 Jan 26 7:59 PM
Hi Ajay,
Did you implement the interface in any class before calling the method??
Interfaces contain definitions of the methods(no code - like a template) which can be implemented by multiple classes.
Create a class implementing the interface and then call the method of that class using object.
P.S : After declaring the reference variable using DATA, use CREATE OBJECT obj after that
Eg. data: abcd type REF TO IF_UJA_APPSET_DATA.
create object abcd.
2013 Feb 01 10:43 AM
Hello,
Interface contains only definitions. To use an interface you have to declare its use in a class first and implement its methods in that class.
e.g : your interface if_uja_appset_data.
declare a class or use it in a existing class.
if in a local class then,
CLASS lcl_abc DEFINITION.
INTERFACES : if_uja_appset_data "declare usage of interface
ENDCLASS.
CLASS lcl_abc IMPLEMENTATION.
METHOD if_uja_appset_data~get_param_value.
" your implementation.
.....
.....
ENDMETHOD.
ENDCLASS.
if global class,
then go to interfaces tab in class builder and add an entry for the interface to be used.
after that go to methods tab, you will find methods of interface listed there. Double click on each method to implement it.
Now in main program,
DATA lo_abcd TYPE REF TO lcl_abc "or your global class
CREATE OBJECT lo_abc.
lo_abc->if_uja_appset_data~get_param_value(
EXPORTING
I_TYPE = 'SYSTEM'
I_PARAM_NAME = 'RTRCT_CC_COST_DEST'
RECEIVING
R_VALUE = l_appl_param.
).
Thats how we use an interface. Try and clear your basics of using interfaces and classes to clear your doubts. This was a basic problem.