‎2008 Jul 11 8:41 AM
what is the diffrence between changing and using in function module.
‎2008 Jul 11 8:44 AM
Hi naresh,
Changing & using are generally used in passing parameters by reference
You list these parameters after USING or CHANGING without the VALUEaddition:
FORM subr USING p1 [{TYPE type}|{LIKE field}]
p2 [{TYPE type}|{LIKE field}]
...
CHANGING p1 [{TYPE type}|{LIKE field}]
p2 [{TYPE type}|{LIKE field}]
...The formal parameter has no memory of its own. During a subroutine call, only the address of the actual parameter is transferred to the formal parameter. The subroutine works with the field from the calling program. If the value of the formal parameter changes, the contents of the actual parameter in the calling program also change.
For calling by reference, USING and CHANGING are equivalent. For documentation purposes, you should use USING for input parameters which are not changed in the subroutine, and CHANGING for output parameters which are changed in the subroutine.
To avoid the value of an actual parameter being changed automatically, you must pass it by value.
Check this link for more info;-
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db984635c111d1829f0000e829fbfe/content.htm
Regards,
Bhumika
‎2008 Jul 11 8:44 AM
Hi naresh,
Changing & using are generally used in passing parameters by reference
You list these parameters after USING or CHANGING without the VALUEaddition:
FORM subr USING p1 [{TYPE type}|{LIKE field}]
p2 [{TYPE type}|{LIKE field}]
...
CHANGING p1 [{TYPE type}|{LIKE field}]
p2 [{TYPE type}|{LIKE field}]
...The formal parameter has no memory of its own. During a subroutine call, only the address of the actual parameter is transferred to the formal parameter. The subroutine works with the field from the calling program. If the value of the formal parameter changes, the contents of the actual parameter in the calling program also change.
For calling by reference, USING and CHANGING are equivalent. For documentation purposes, you should use USING for input parameters which are not changed in the subroutine, and CHANGING for output parameters which are changed in the subroutine.
To avoid the value of an actual parameter being changed automatically, you must pass it by value.
Check this link for more info;-
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db984635c111d1829f0000e829fbfe/content.htm
Regards,
Bhumika
‎2008 Jul 11 8:46 AM
Hi Narendra,
The Changing parameters in the Function Module must be supplied with data when you call the function module, unless they are flagged as optional. They can be changed in the function module.
The changed values are then returned to the calling program.
And Using is used in the Subroutines and not in the Function Modules.
In Function Modules You have Export and Import parameters.
Regards,
Swapna.
‎2008 Jul 11 8:48 AM
hi Please check this thread.may be use ful to u
http://help.sap.com/saphelp_46c/helpdata/EN/d1/801ece454211d189710000e8322d00/frameset.htm
The additions using and changing both pass by reference-they are identical in function. The reason they both exist is that-used properly-they can document whether the subroutine will change a parameter or not.
Code changing with parameters, the subroutine changes. You should code using with parameters that are not changed by the subroutine. the following program illustrates this point.
1 report zexam.
2 data: f1 value 'A',
3 f2 value 'B'.
4
5 write: / f1, f2.
6 perform s1 using f1
7 changing f2.
8 write: / f1, f2.
9
10 form s1 using p1
11 changing p2.
12 p1 = p2 = 'X'.
13 endform.
-
The code in Listing produces the following output:
A B
X X
f1 and f2 are both passed by reference to s1. Therefore, p1 and p2 are pointers to f1 and f2. Changes to p1 and p2 are immediately reflected in f1 and f2. This example only illustrates that it is possible to change any parameter that is passed by reference. You should code your parameters so that using and changing properly document your usage of those parameters.
reward points if useful,
Thanks,
usha
Edited by: Usha Rani Rachamalla on Jul 11, 2008 9:57 AM
‎2008 Jul 11 8:50 AM
HI,
Using & Changing will acts same as Pass by Value (with value addition) and Pass by Reference.