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

CALL METHOD

Former Member
0 Likes
788

hi i am using a method change_price of class cl_isu_price.can u tell me what is the syntax or procedure for calling it i.e. is it just CALL METHOD change_price?

Pla reply.

thanks in advance,

anand.

2 REPLIES 2
Read only

Former Member
0 Likes
468

Hi

Hope it will help you.

Pls reward if help.

Calling Methods

To call a method, use the following statement:

CALL METHOD <meth> EXPORTING... <ii> =.<f i>...

IMPORTING... <ei> =.<g i>...

CHANGING ... <ci> =.<f i>...

RECEIVING r = h

EXCEPTIONS... <ei> = rc i...

The way in which you address the method <method> depends on the method itself and from where you are calling it. Within the implementation part of a class, you can call the methods of the same class directly using their name <meth>.

CALL METHOD <meth>...

Outside the class, the visibility of the method depends on whether you can call it at all. Visible instance methods can be called from outside the class using

CALL METHOD <ref>-><meth>...

where <ref> is a reference variable whose value points to an instance of the class. Visible instance methods can be called from outside the class using

CALL METHOD <class>=><meth>...

where <class> is the name of the relevant class.

When you call a method, you must pass all non-optional input parameters using the EXPORTING or CHANGING addition in the CALL METHOD statement. You can (but do not have to) import the output parameters into your program using the IMPORTING or RECEIVING addition. Equally, you can (but do not have to) handle any exceptions triggered by the exceptions using the EXCEPTIONS addition. However, this is recommended.

You pass and receive values to and from methods in the same way as with function modules, that is, with the syntax:

... <Formal parameter> = <Actual parameter>

after the corresponding addition. The interface parameters (formal parameters) are always on the left-hand side of the equals sign. The actual parameters are always on the right. The equals sign is not an assignment operator in this context; it merely serves to assign program variables to the interface parameters of the method.

If the interface of a method consists only of a single IMPORTING parameter, you can use the following shortened form of the method call:

CALL METHOD <method>( f).

The actual parameter <f> is passed to the input parameters of the method.

If the interface of a method consists only of IMPORTING parameters, you can use the following shortened form of the method call:

CALL METHOD <method>(....<ii> =.<f i>...).

Each actual parameter <f i > is passed to the corresponding formal parameter <i i >.

Read only

0 Likes
468

HI,

can we call the method in a similar way by using pattern tab in ABAP editor?