Skip to Content
author's profile photo Former Member
Former Member

Difference between "me->" and "Call Function me->" ?

Hi Experts,

I would like know if there are some differences between :

CALL METHOD me->myMethod

EXPORTING

field = value.

and

me->myMethod(

EXPORTING

field = value

).

Performance ? Best pratices ? One of both obsolete ?

Many thx!

Rachid.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 02, 2014 at 03:57 PM

    HI Rachid,

    There is one difference.

    There are four type of parameter in Class while defining the Parameter.

    1. Importing

    2.Exporting

    3.Changing

    4.Returning.

    When you are using the statement call method you can't use the return parameter.

    Return parameter means you need to hold that value in same type of the returning parameter. This can't be possible using the call method.


    CALL METHOD me->myMethod

    EXPORTING

    field = value.

    But in this statement it is possible.

    Suppose your Method has one return parameter with name R_ITem with the Int2 and you must be hold the value of the parameter.

    me->myMethod(

    EXPORTING

    field = value

    ).

    Ebelp = me->mymethod( ).

    Now the return value is automatically store in the ebelp Field.

    Regards,

    Nishant Bansal

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 02, 2014 at 03:31 PM

    Hi,

    There is no difference me->method( ) is short version of call method. actualy you can write method( ) too,

    But if you need to call your method dynamic you cant use shorted version you need to write call method. example from CALL METHOD help (F1)

    TRY. 
        CALL METHOD (class)=>(meth) 
          PARAMETER-TABLE 
            ptab 
          EXCEPTION-TABLE 
            etab. 
        CASE sy-subrc. 
          WHEN 1. 
            ... 
          ... 
        ENDCASE. 
      CATCH cx_sy_dyn_call_error INTO exc_ref. 
        exc_text = exc_ref->get_text( ). 
        MESSAGE exc_text TYPE 'I'. 
    ENDTRY.
    

    and for static method call, CALL METHOD object=>static_method is obsolete.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.