Meaning of CHANGING < Var> in subroutine call

Could any tell me the meaning of CHANGING < Var> in subroutine call.
Suppose in Perform < subroutine name > Using Var1 Changing <Var2>.

Whats the meaning and use of Changing in above sentence ?

Sunita


"using Var1" doesn't reflect any changes that we made to Var1 in the subroutine. But "changing Var2" reflects the changes we made to Var2.It is similar to the concept call by value and call by reference.
for ex.
  v1=10
  v2=20
perform subroutine using v1 changing v2.

form subroutine using a1 changing a2.
 a1 =30.
 a2=40.
endform.

then the values of v1 = 10 v2 =40.

Hope u understood...

Ravikumar Kandikonda


There will be difference between using and changing on how we mention in form statement.

Form < subroutine name> Using var1 Changing var2.
Here there is no difference as both pass by reference.

Form < subroutine name> Using var1 Changing value (var2).
Here var1 is passed by reference, whereas var2 is passed by value and result.where var2 has its own copy of memory in subroutine, but while the subroutine ends this value overwrites the original value of the var2.

Form ..... Using value(var1)...
Here  var1 is pass by value

Arvind C


Here is some brief idea about the addition USING and CHANGING in forms.

If a subroutine has a parameter interface, you must supply values to all of the formal parameters in its interface when you call it. You list the actual parameters after the USING or CHANGING addition in the PERFORM statement.

When you pass the values, the sequence of the actual parameters in the PERFORM statement is crucial. The value of the first actual parameter in the list is passed to the first formal parameter, the second to the second, and so on. The additions USING and CHANGING have exactly the same meaning. You only need to use one or the other. However, for documentary reasons, it is a good idea to divide the parameters in the same way in which they occur in the interface definition.

Actual parameters can be any data objects or field symbols of the calling program whose technical attributes are compatible with the type specified for the corresponding formal parameter. When you specify the actual parameters, note that any that you pass by reference to a formal parameter, and any that you pass by value to an output parameter, can be changed by the subroutine. You should therefore ensure that only data objects that you want to be changed appear in the corresponding position of the actual parameter list.

So there is absolutely no difference in the additions USING and CHANGING..  then you may be thinking why the hell did SAP provide both..  the answer is just for the sake of better documentation..

So whenever you write a subroutine its better to give USING only for those parameters which u wont be changing in the subroutine  and CHANGING only for those parameters which u'll be definetly changing or updateing or returning the value to the called program

This really helps the person who is looking at your code...

Cheers

Basha

See Also:
Help on Conversion From Numbers to Text Amount

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.