<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>subroutine &#8211; SAP EWM Help</title>
	<atom:link href="https://www.sapewmhelp.com/question-tag/subroutine/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sapewmhelp.com</link>
	<description>SAP EWM questions answered by experts — ABAP, S/4HANA, warehouse management</description>
	<lastBuildDate>Fri, 01 Aug 2025 13:43:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>
	<item>
		<title>Subroutines in SAP</title>
		<link>https://www.sapewmhelp.com/question/subroutines-in-sap/</link>
					<comments>https://www.sapewmhelp.com/question/subroutines-in-sap/#respond</comments>
		
		<dc:creator><![CDATA[DPM125]]></dc:creator>
		<pubDate>Fri, 01 Aug 2025 13:43:35 +0000</pubDate>
				<guid isPermaLink="false">https://www.sapewmhelp.com/?question=subroutines-in-sap</guid>

					<description><![CDATA[A subroutine is a block of reusable code defined using FORM and called using PERFORM. It is a procedural method of modularization mainly used in classical ABAP programming.  When to use: In classic procedural ABAP programs. For logic reuse in the same or other programs via INCLUDE. *&#38;---------------------------------------------------------------------* *&#38; Report  ZREP_LCLCLASS *&#38; *&#38;---------------------------------------------------------------------* *&#38; *&#38; *&#38;---------------------------------------------------------------------* REPORT zrep_lclclass. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>A <strong>subroutine</strong> is a block of reusable code defined using FORM and called using PERFORM. It is a <strong>procedural</strong> method of modularization mainly used in classical ABAP programming.</p>
<h3><strong> When to use:</strong></h3>
<ul>
<li>In classic procedural ABAP programs.</li>
<li>For logic reuse in the same or other programs via INCLUDE.</li>
</ul>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code><!--StartFragment --><span><span>*&amp;---------------------------------------------------------------------*</span>
<span>*&amp; Report  ZREP_LCLCLASS</span>
<span>*&amp;</span>
<span>*&amp;---------------------------------------------------------------------*</span>
<span>*&amp;</span>
<span>*&amp;</span>
<span>*&amp;---------------------------------------------------------------------*</span>

<span>REPORT </span>zrep_lclclass<span>.</span>

<span>DATA</span><span>: </span>lv_a <span>TYPE </span><span>i </span><span>VALUE </span><span>5</span><span>,</span>
      lv_b <span>TYPE </span><span>i </span><span>VALUE </span><span>10</span><span>,</span>
      lv_result <span>TYPE </span><span>i </span><span>VALUE </span><span>0</span><span>.</span>

<span>WRITE</span><span>: </span>/ 'Before subroutine <span>call</span><span>:</span>'<span>,</span>
       / 'lv_a ='<span>, </span>lv_a<span>,</span>
       / 'lv_b ='<span>, </span>lv_b<span>,</span>
       / 'lv_result ='<span>, </span>lv_result<span>.</span>

<span>* Call the subroutine</span>
<span>PERFORM </span>calculate_sum <span>USING    </span>lv_a     <span>" passed by value (copy)</span>
                              lv_b     <span>" passed by value (copy)</span>
                       <span>CHANGING </span>lv_result<span>.  </span><span>" passed by reference (direct)</span>

<span>WRITE</span><span>: </span>/ 'After subroutine <span>call</span><span>:</span>'<span>,</span>
       / 'lv_a ='<span>, </span>lv_a<span>,</span>
       / 'lv_b ='<span>, </span>lv_b<span>,</span>
       / 'lv_result ='<span>, </span>lv_result<span>.</span>

<span>*------------------------------------------------------------------*</span>
<span>* Subroutine Definition</span>
<span>*------------------------------------------------------------------*</span>
<span>FORM </span>calculate_sum <span>USING    </span>p_a <span>TYPE </span><span>i</span>
                            p_b <span>TYPE </span><span>i</span>
                   <span>CHANGING </span>p_sum <span>TYPE </span><span>i</span><span>.</span>

  p_a <span>= </span>p_a + <span>1</span><span>.  </span><span>" Modifies copy (no effect on lv_a)</span>
  p_b <span>= </span>p_b + <span>1</span><span>.  </span><span>" Modifies copy (no effect on lv_b)</span>

  p_sum <span>= </span>p_a + p_b<span>.  </span><span>" Modifies original lv_result (by reference)</span>

<span>ENDFORM</span><span>.</span></span> 
</code></pre>
<p>Output:<br />
<img decoding="async" class="content-img" src="https://www.sapewmhelp.com/wp-content/uploads/2025/08/subroutines.png" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sapewmhelp.com/question/subroutines-in-sap/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
