Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to pass value to interface in objects- interface IF_UJA_APPSET_DATA

Former Member
0 Likes
1,694

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

2 REPLIES 2
Read only

former_member491621
Contributor
0 Likes
856

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.

Read only

Former Member
0 Likes
856

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.