Application Development 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: 

What is purpose of Changing keyword in a Subroutine ?

Former Member
0 Kudos

Hi Experts .

Please Help me What is the use of Changing Parameter in a Subroutine .

For Ex :

data : a type i ,

b type i ,

c type i .

a = 4 .

b = 8 .

perform abc using a b changing c .

write 😕 a . " it gives 4

write 😕 b . " it gives 8

write 😕 c . " it gives 12

perForm abc using c changing d .

a = a + 1 .

b = b + 1 .

c = c + 1 .

skip 2 .

write 😕 a . " it gives 5

write 😕 b . " it gives 6

write 😕 c . " it gives 13

form abc using a b changing c .

c = a + b .

endform .

Form abc using c changing d .

d = c + 1 .

endform .

The same thing i will get by Using c also , Then what is specific purpose of

Changing in subroutine ?

Please Help me out Boss ...

Regards : rajneesh

1 ACCEPTED SOLUTION

Former Member

Hi,

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..

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 updating or returning the value to the called program

<b>Check this link.</b> for more details

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db984635c111d1829f0000e829fbfe/content.htm

Regards,

Maha

1 REPLY 1

Former Member

Hi,

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..

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 updating or returning the value to the called program

<b>Check this link.</b> for more details

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db984635c111d1829f0000e829fbfe/content.htm

Regards,

Maha