<?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: subroutines in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649507#M879004</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;You can create a subroutine &amp;amp; call it as follows:&lt;/P&gt;&lt;P&gt;PERFORM f_validation.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  f_validation&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM F_VALIDATION .&lt;/P&gt;&lt;P&gt;  IF SY-UCOMM = 'ONLI' OR SY-UCOMM = 'SJOB'.&lt;/P&gt;&lt;P&gt;    IF ZCOMP IS NOT INITIAL AND S_COMP IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;      MESSAGE E001(ZBHI) WITH TEXT-006.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " f_validation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First you can write the perform statement &amp;amp; when you double click on this statement, it will automatically create FORM.&lt;/P&gt;&lt;P&gt;Then you can put your code in this FORM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sipra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Apr 2008 07:58:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-03T07:58:39Z</dc:date>
    <item>
      <title>subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649502#M878999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how to calling subroutines (internal and external)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:25:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649502#M878999</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649503#M879000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt; by the following stmt we call subroutine:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM &amp;lt;subroutine&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:26:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649503#M879000</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649504#M879001</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;if it is internal&lt;/P&gt;&lt;P&gt;perform &amp;lt;name&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;external&lt;/P&gt;&lt;P&gt;perform &amp;lt;name&amp;gt; (program) if found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds,&lt;/P&gt;&lt;P&gt;bharat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:27:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649504#M879001</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649505#M879002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Internal subroutines in the sense ..subroutines which are defined and used in a same program&amp;#133;external in the sense if you create a sub routine in one program and you&amp;#146;re calling this subroutine in another program ..then this is external subroutine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The name itself implies the internal subroutines defined by form /perform.. can be called within the same prog in which they were declared&amp;#133;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;external subroutines can be called outside the program&amp;#133;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUBROUTINES:&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;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM - ENDFORM statement is used to create subroutines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM statement is used to invoke the subroutine created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subroutines are used to call a piece of code frequently within the program or externally from other program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOCAL SUBROUTINES:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The subroutine is called locally from the same program using PERFORM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg. code of local subroutine without any value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM STALIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM STALIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 5 TIMES.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'WELCOME TO ABAP'.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg. code of external subroutine without any value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create an executable program and write the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZSUBROUTINES2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM STALIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM STALIN.&lt;/P&gt;&lt;P&gt;DO 5 TIMES.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'WELCOME TO ABAP'.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Save -&amp;gt; Activate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create another executable program and write the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZSUBROUTINES1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM STALIN(ZSUBROUTINES2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Save -&amp;gt; Activate -&amp;gt; Execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have to specify name of the program where subroutine is created within the bracket whenever we try to invoke the subroutine externally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PASS BY REFERENCE:&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;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : A(10) VALUE 'INDIA', B TYPE I VALUE '20'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM STALIN USING A B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM STALIN USING X Y.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; X , Y.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PASS BY VALUE:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : A(10) VALUE 'INDIA', B TYPE I VALUE '20'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM STALIN USING A B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM STALIN USING X Y.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X = 'AMERICA'.&lt;/P&gt;&lt;P&gt;Y = '100'.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; X , Y.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PASSING INTERNAL TABLE AS AN ARGUMENT:&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;HR originaltext="-------------------------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM KNA1 INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM DISPLAY TABLES ITAB .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM DISPLAY TABLES ITAB STRUCTURE KNA1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; ITAB-KUNNR, ITAB-NAME1, ITAB-LAND1, ITAB-ORT01.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:28:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649505#M879002</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649506#M879003</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;To call a subroutine defined in the same program, you need only specify its name in the&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM statement:&lt;/P&gt;&lt;P&gt;PERFORM &amp;lt;subr&amp;gt; [USING ... &amp;lt;pi&amp;gt;... ]&lt;/P&gt;&lt;P&gt;[CHANGING... &amp;lt;pi&amp;gt;... ].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The internal subroutine can access all of the global data of the calling program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can specify the name of a subroutine and, in the case of external calls, the name of the program in which it occurs, dynamically as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM (&amp;lt;fsubr&amp;gt;)[IN PROGRAM (&amp;lt;fprog&amp;gt;)][USING ... &amp;lt;pi&amp;gt;... ]&lt;/P&gt;&lt;P&gt;[CHANGING... &amp;lt;pi&amp;gt;... ]&lt;/P&gt;&lt;P&gt;[IF FOUND].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The names of the subroutine and the external program are the contents of the fields &amp;lt;fsubr&amp;gt; and &amp;lt;fprog&amp;gt; respectively. By using the option IF FOUND, you can prevent a runtime error from being triggered if &amp;lt;fprog&amp;gt; does not contain a subroutine with the name &amp;lt;fsubr&amp;gt;. If you omit the parentheses, this variant of the PERFORM statement behaves like the static variant.&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>Thu, 03 Apr 2008 07:33:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649506#M879003</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649507#M879004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;You can create a subroutine &amp;amp; call it as follows:&lt;/P&gt;&lt;P&gt;PERFORM f_validation.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  f_validation&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM F_VALIDATION .&lt;/P&gt;&lt;P&gt;  IF SY-UCOMM = 'ONLI' OR SY-UCOMM = 'SJOB'.&lt;/P&gt;&lt;P&gt;    IF ZCOMP IS NOT INITIAL AND S_COMP IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;      MESSAGE E001(ZBHI) WITH TEXT-006.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " f_validation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First you can write the perform statement &amp;amp; when you double click on this statement, it will automatically create FORM.&lt;/P&gt;&lt;P&gt;Then you can put your code in this FORM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sipra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:58:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/3649507#M879004</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:58:39Z</dc:date>
    </item>
  </channel>
</rss>

