<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Parameter passing by value or by reference in function module in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459469#M831179</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By Refence mean the values you passed in a variable are not copied but the same will be used in the FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Feb 2008 03:34:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-15T03:34:01Z</dc:date>
    <item>
      <title>Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459467#M831177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi everybody:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im a beginner for abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below description is described in online help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In function module, the CALL FUNCTION statement can pass import, export, and changing parameters either by value or by reference. Table parameters are always transferred by reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand parameters passing by value means values carried by parameters are transferred, but I do not understand what is "by reference".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please kindly give me a explanation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 03:24:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459467#M831177</guid>
      <dc:creator>former_member200271</dc:creator>
      <dc:date>2008-02-15T03:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459468#M831178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function modules are modular units with interfaces. The interface can contain the following elements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Import parameters are parameters passed to the function module. In general, these are assigned&lt;/P&gt;&lt;P&gt;standard ABAP Dictionary types. Import parameters can also be characterized as optional.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Export parameters are passed from the function module to the calling program. Export parameters&lt;/P&gt;&lt;P&gt;are always optional and for that reason do not need to be accepted by the calling program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changing parameters are passed to the function module and can be changed by it. The result is&lt;/P&gt;&lt;P&gt;returned to the calling program after the function module has executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exceptions are used to intercept errors. If an error triggers an exception in a function module, the&lt;/P&gt;&lt;P&gt;function module stops. You can assign exceptions to numbers in the calling program, which sets the&lt;/P&gt;&lt;P&gt;system field SY-SUBRC to that value. This return code can then be handled by the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By reference Passes a pointer to the original memory location.  Very efficient &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By value Allocates a new memory location for use within the subroutine. The memory is freed when the subroutine ends.  Prevents changes to passed variable &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By value and result Similar to pass by value, but the contents of the new memory is copied back into the original memory before returning.  Allows changes and allows a rollback &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;When you pass a parameter by reference, new memory is not allocated for the value. Instead, a pointer to the original memory location is passed. All references to the parameter are references to the original memory location. Changes to the variable within the subroutine update the original memory location immediately.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1  report ztx1804.&lt;/P&gt;&lt;P&gt;2  data f1 value 'A'.&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4  perform s1 using f1.&lt;/P&gt;&lt;P&gt;5  write / f1.&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7  form s1 using p1.&lt;/P&gt;&lt;P&gt;8      p1 = 'X'.&lt;/P&gt;&lt;P&gt;9      endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code in Listing produces the following output: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope this helps, Do reward.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 03:30:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459468#M831178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-15T03:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459469#M831179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By Refence mean the values you passed in a variable are not copied but the same will be used in the FM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 03:34:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459469#M831179</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-15T03:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459470#M831180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Atish:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you give me an example? I am not quite understand, maybe because of language difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 03:39:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459470#M831180</guid>
      <dc:creator>former_member200271</dc:creator>
      <dc:date>2008-02-15T03:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459471#M831181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 report ztx1804.&lt;/P&gt;&lt;P&gt;2 data f1 value 'A'.&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4 perform s1 using f1.&lt;/P&gt;&lt;P&gt;5 write / f1.&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7 form s1 using p1.&lt;/P&gt;&lt;P&gt;8 p1 = 'X'.&lt;/P&gt;&lt;P&gt;9 endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code in Listing produces the following output: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope this helps, Do reward.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 03:41:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459471#M831181</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-15T03:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459472#M831182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Andy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Check this docs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parameters Passed by Reference&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You list these parameters after USING or CHANGING without the VALUE addition: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM &amp;lt;subr&amp;gt; USING    ... &amp;lt;pi&amp;gt; [TYPE &amp;lt;t&amp;gt;|LIKE &amp;lt;f&amp;gt;] ... &lt;/P&gt;&lt;P&gt;            CHANGING ... &amp;lt;pi&amp;gt; [TYPE &amp;lt;t&amp;gt;|LIKE &amp;lt;f&amp;gt;] ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The formal parameter occupies 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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid the value of an actual parameter being changed automatically, you must pass it by value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input Parameters That Pass Values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You list these parameters after USING with the VALUE addition: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM &amp;lt;subr&amp;gt; USING    ... VALUE(&amp;lt;pi&amp;gt;) [TYPE &amp;lt;t&amp;gt;|LIKE &amp;lt;f&amp;gt;] ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The formal parameter occupies its own memory space. When you call the subroutine, the value of the actual parameter is passed to the formal parameter. If the value of the formal parameter changes, this has no effect on the actual parameter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 03:48:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459472#M831182</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-15T03:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459473#M831183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;passing by reference means u actually pass the actual address of  ur variable(/whatever u want to pass). in the subroutine  whatever is done to the variable is actually done into its actual memory location. so whatever is the final value of the variable within the subroutine, will be the value of the variable when you are out of the subroutine also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lets put it in another way. you(program)  give  a glass of water(variable passed by reference) to your friend(subroutine) . friend mixes colour(manipulate your variable's data) in the water. now he(subroutine) returns it(final value within subroutine) to you(calling program). you(program) get coloured water(same value returned by subroutine)  because u had actually given your own container(original address of variable) of water to him.this i s pass by reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pass by value.- you give another glass of water(dummy variable) not  your own glass.  so whatever he does in that glass(dummy variable) wont affect water in your glass(original addresss).  but you can see the result when he returns it(dummy variable ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 04:23:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459473#M831183</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-15T04:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459474#M831184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;By Value&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Data : a type I value 20.&lt;/P&gt;&lt;P&gt;	Perform sub1 using a.&lt;/P&gt;&lt;P&gt;	Write a.&lt;/P&gt;&lt;P&gt;	FORM sub1 using value (p_a)&lt;/P&gt;&lt;P&gt;		P &amp;#150; a = 15&lt;/P&gt;&lt;P&gt;	ENDORM.&lt;/P&gt;&lt;P&gt;In this case during subroutine call, the formal parameter are created as copies of actual parameter.&lt;/P&gt;&lt;P&gt;The formal parameters have the memory of their own. Changes made to formal parameter have no effect on the actual parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like in this case, though value of p_a is changed to 15, it has no effect on &amp;#145;a&amp;#146; which remains as 20.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;By Reference&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Data: a type I value 20.&lt;/P&gt;&lt;P&gt;	Perform sub1 using a.&lt;/P&gt;&lt;P&gt;	Write a.&lt;/P&gt;&lt;P&gt;	FORM sub1 using value (p_a)&lt;/P&gt;&lt;P&gt;		P &amp;#150; a = 15.&lt;/P&gt;&lt;P&gt;	ENDORM.&lt;/P&gt;&lt;P&gt;By default system calls all the forms by reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, only the address of the actual parameter is transferred to the formal parameters.  The formal parameter has no memory of its own.  If you change the formal parameter, change is visible in actual parameter also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2008 04:38:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459474#M831184</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-15T04:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter passing by value or by reference in function module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459475#M831185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bhaskar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I know this is a very old post, but your examples both look identical.&lt;/P&gt;&lt;P&gt;Your explanation is fine, so I presume it's just a typo in your code sample.&lt;/P&gt;&lt;P&gt;I think your 'By Reference' example should read&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;By Reference&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data: a type I value 20.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Perform sub1 changing a.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write a.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORM sub1 changing value (p_a)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; P – a = 15.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I like to think of it as the difference between creating a copy of a file (pass by value) vs. creating a shortcut to the file (pass by reference).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;/P&gt;&lt;P&gt;Niall&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Sep 2014 17:38:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/parameter-passing-by-value-or-by-reference-in-function-module/m-p/3459475#M831185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-09-01T17:38:38Z</dc:date>
    </item>
  </channel>
</rss>

