Skip to Content
avatar image
Former Member

Different ways of calling Methods

Dear SAPians,

What is the Difference between calling a method in the following ways.

1) call method obj->m1.

2) obj->m1( ).

3) obj2 = obj->m1( ).

Thanks in Advance

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 02, 2015 at 12:51 PM

    Hi,

    There is no big difference between call method obj->m1,obj->m1( ).

    But obj2 = obj->m1( ) is wrong if OBJ2 is a reference variable.

    If OBJ2 is normal variable, it holds the returning value . i,e you'r M1() method should have returning parameter.

    Thanks

    KH

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 05, 2015 at 04:35 AM

    Hi Kumar,

    There is no difference in terms of performance by calling methods in different way but look and feel representation may differ.

    Please find my explanation

    1) call method obj->m1 : Here you to explicitly mention EXPORTING/IMPORTING/RECEIVING/CHANGING option

    call method ojb->m1

    RECEIVING

    obj = obj2.

    2) obj->m1( ). " using this, method call assumes return/exporting parameter can be implicitly received

    obj2 = obj-m1( my_data )

    Note: here obj2 is of type object and the method M1 should return the object of same type & my_data is an exporting parameter to the method M1

    Regards,

    Rama

    Add comment
    10|10000 characters needed characters exceeded