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

subroutines

Former Member
0 Likes
740

Hi all

can any body explain me abt subroutines..call by value,call by referrence,call by value and results...

Thanks n Regards

popi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
713

Refer these links,

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm

<b>

What is the difference between external & internal subroutine?</b>

Internal subroutines in the sense ..subroutines which are defined and used in a same program...

external in the sense if you create a sub routine in one program and you're calling this subroutine in another program ..

then this is external subroutine.

Hope this helps.

Reward points if u find helpful.

Hi all

can any body explain me abt subroutines..call by value,call by referrence,call by value and results...

Thanks n Regards

popi

5 REPLIES 5
Read only

Former Member
0 Likes
714

Refer these links,

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm

<b>

What is the difference between external & internal subroutine?</b>

Internal subroutines in the sense ..subroutines which are defined and used in a same program...

external in the sense if you create a sub routine in one program and you're calling this subroutine in another program ..

then this is external subroutine.

Hope this helps.

Reward points if u find helpful.

Read only

Former Member
0 Likes
713

Hi yen,

<b>CALL BY VALUE: in this case a local copy of the parameter is created for called function and changes make in the variable are local in function they will not change the actual variable.

CALL BY REFERENCE: The address of actual variable is passed to called function and changes made in function will change the actual variable.

CALL BY VALUE AND RESULT: Local copy will be made for the variable and at the end of called function the changed value will be written back to original variable.

</b>

Read only

Former Member
0 Likes
713

Hi Popi,

Go through the following:

When we are passing parameter by reference, then a separate copy will not be created. If we are passign by value, a separate copy will be created.

1. Pass by value and pass by reference ( getting result )

a) Pass by value

PERFORM subr USING a1 a2 a3 a4 a5

Click for example: http://help.sap.com/saphelp_47x200/helpdata/en/9f/db979d35c111d1829f0000e829fbfe/frameset.htm

b) Pass by reference

PERFORM subr CHANGING a1 a2 a3 a4 a5

Click for example Example: http://help.sap.com/saphelp_47x200/helpdata/en/9f/db979035c111d1829f0000e829fbfe/frameset.htm

Ashven

Read only

Former Member
0 Likes
713

Hi Popi,

Following link is also useful. Go through it.

http://www.cs.princeton.edu/~lworthin/126/precepts/pass_val_ref.html

Ashven

Read only

Former Member
0 Likes
713

Hi,

Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module.

Call by value..Inside the subroutine if you change the value it will not have effect (means it will not change the value) in the calling place..

Call by reference...Inside the subroutine if you change the value it will change in the calling place..Means it will share the same memory..

Just have a look at this link:

Regards,

Gunasree.