<?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: hi in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472394#M834659</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;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/content.htm&lt;/A&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;Local Data in the Subroutine &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data declarations in procedures create local data types and objects that are only visible &lt;/P&gt;&lt;P&gt;within that procedure. There are two kinds of data types and objects &amp;#150; dynamic and static.&lt;/P&gt;&lt;P&gt; Dynamic data objects only exist while the subroutine is running, while static objects still &lt;/P&gt;&lt;P&gt;exist after the subroutine has finished running, and retain their values until the next time &lt;/P&gt;&lt;P&gt;the subroutine is called. Field symbols can be declared locally. You can also use a special kind &lt;/P&gt;&lt;P&gt;of data object for subroutines &amp;#150; copies of global data on a local data stack. You define and address&lt;/P&gt;&lt;P&gt; them using field symbols.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic Local Data Types and Objects&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local data types and objects declared in subroutines using the TYPES and DATAstatements are deleted &lt;/P&gt;&lt;P&gt;when the subroutine ends, and recreated each time the routine is called.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every subroutine has its own local namespace. If you declare a local data type or object with the&lt;/P&gt;&lt;P&gt; same name as a global data type or object, the global type or object cannot be addressed from within &lt;/P&gt;&lt;P&gt;the subroutine. Local data types or data objects hide identically named global data types or objects.&lt;/P&gt;&lt;P&gt; This means that if you use the name of a data type or object in the subroutine, you always address a &lt;/P&gt;&lt;P&gt;locally declared object &amp;#150; if this exists &amp;#150; and otherwise a globally declared one. To prevent global data &lt;/P&gt;&lt;P&gt;types or objects from being hidden, local types and objects must have other names assigned to them. &lt;/P&gt;&lt;P&gt;For example, all local names in subroutines could begin with &amp;#145;F _&amp;#146;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_mod_tech_data_types .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES word(10) TYPE c.&lt;/P&gt;&lt;P&gt;DATA  text TYPE word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;text = '1234567890'.  WRITE / text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM datatest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE / text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM datatest.&lt;/P&gt;&lt;P&gt;  TYPES word(5) TYPE c.&lt;/P&gt;&lt;P&gt;  DATA  text TYPE word.&lt;/P&gt;&lt;P&gt;  text = 'ABCDEFGHJK'. WRITE / text.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you run the program, the following is displayed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1234567890&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABCDE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1234567890&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, a data type word and a global data object text with type word are declared globally in the main program.&lt;/P&gt;&lt;P&gt; After a value has been assigned to text and this has been displayed on the list, the internal subroutine datatest is called.&lt;/P&gt;&lt;P&gt; Inside the subroutine, a data type word and a local data object text with type word are declared locally.&lt;/P&gt;&lt;P&gt; They hide the global type and object. Only after the subroutine is finished are the global definitions are valid again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Static Local Data Objects&lt;/P&gt;&lt;P&gt;If you want to keep the value of a local data object after exiting the subroutine, you must use the STATICS statement&lt;/P&gt;&lt;P&gt; to declare it instead of the DATA statement. With STATICS you declare a data object that is globally defined,&lt;/P&gt;&lt;P&gt; but only locally visible from the subroutine in which it is defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_mod_tech_statics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM datatest1.&lt;/P&gt;&lt;P&gt;PERFORM datatest1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SKIP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM datatest2.&lt;/P&gt;&lt;P&gt;PERFORM datatest2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM datatest1.&lt;/P&gt;&lt;P&gt;  TYPES f_word(5) TYPE c.&lt;/P&gt;&lt;P&gt;  DATA  f_text TYPE f_word VALUE 'INIT'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;  f_text = '12345'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM datatest2.&lt;/P&gt;&lt;P&gt;  TYPES    f_word(5) TYPE c.&lt;/P&gt;&lt;P&gt;  STATICS  f_text TYPE f_word VALUE 'INIT'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;  f_text = 'ABCDE'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you run the program, the following is displayed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INIT  12345 INIT  12345&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INIT  ABCDE ABCDE ABCDE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, two similar subroutines datatest1 and datatest2 are defined.&lt;/P&gt;&lt;P&gt; In datatest2 , the STATICSstatement is used instead of the DATA statement to declare&lt;/P&gt;&lt;P&gt; the data object f_text. During each call of datatest1, f_text is initialized again, but it keeps&lt;/P&gt;&lt;P&gt; its value for datatest2. The VALUE addition of the STATICSstatement functions only during the first call of datatest2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local Field Symbols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All field symbols declared in a subroutine using the FIELD-SYMBOLS statement are local. For local field symbols,&lt;/P&gt;&lt;P&gt; the following rules apply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        You cannot address local field symbols outside the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        When you call the subroutine, no field is assigned to a local field symbol &amp;#150; not even if an ASSIGN was &lt;/P&gt;&lt;P&gt;          executed in the last run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        Local field symbols can have the same names as global field symbols. If they do, they hide the global field &lt;/P&gt;&lt;P&gt;           symbols within the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        You can also declare structured field symbols locally. They can have local structures and you can assign &lt;/P&gt;&lt;P&gt;         local fields to them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local Copies of Global Fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a subroutine, you can create local copies of global data on the local stack. To do this, use a local field symbol &lt;/P&gt;&lt;P&gt;and the following variant of the ASSIGN statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN LOCAL COPY OF field TO  TABLES IN_TAB STRUCTURE ITCSY&lt;/P&gt;&lt;P&gt;OUT_TAB STRUCTURE ITCSY.&lt;/P&gt;&lt;P&gt;&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;The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (&amp;#145;First page&amp;#146;, &amp;#145;Next page&amp;#146;, &amp;#145;Last page&amp;#146;) is printed as local variable symbol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definition in the SAPscript form:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO&lt;/P&gt;&lt;P&gt;/: USING &amp;amp;PAGE&amp;amp;&lt;/P&gt;&lt;P&gt;/: USING &amp;amp;NEXTPAGE&amp;amp;&lt;/P&gt;&lt;P&gt;/: CHANGING &amp;amp;BARCODE&amp;amp;&lt;/P&gt;&lt;P&gt;/: ENDPERFORM&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/ &amp;amp;BARCODE&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coding of the calling ABAP program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT QCJPERFO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY&lt;/P&gt;&lt;P&gt;OUT_PAR STRUCTURE ITCSY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: PAGNUM LIKE SY-TABIX, "page number &lt;/P&gt;&lt;P&gt;NEXTPAGE LIKE SY-TABIX. "number of next page&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE IN_PAR WITH KEY &amp;#145;PAGE&amp;#146;.&lt;/P&gt;&lt;P&gt;CHECK SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;PAGNUM = IN_PAR-VALUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE IN_PAR WITH KEY &amp;#145;NEXTPAGE&amp;#146;.&lt;/P&gt;&lt;P&gt;CHECK SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;NEXTPAGE = IN_PAR-VALUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE IN_PAR WITH KEY &amp;#145;BARCODE&amp;#146;.&lt;/P&gt;&lt;P&gt;CHECK SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;IF PAGNUM = 1.&lt;/P&gt;&lt;P&gt;OUT_PAR-VALUE = &amp;#145;|&amp;#146;. "First page &lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;OUT_PAR-VALUE = &amp;#145;||&amp;#146;. "Next page &lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NEXTPAGE = 0.&lt;/P&gt;&lt;P&gt;OUT_PAR-VALUE+2 = &amp;#145;L&amp;#146;. "Flag: last page&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY OUT_PAR INDEX SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &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; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with regards,&lt;/P&gt;&lt;P&gt;sowjanyagosala.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Mar 2008 05:29:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-05T05:29:43Z</dc:date>
    <item>
      <title>hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472387#M834652</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;/P&gt;&lt;P&gt;what is subroutine.what is the purpose of it.can i know the procedure for it?plz any one help me in this session.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:20:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472387#M834652</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472388#M834653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Swati,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;A subroutine is a block of code introduced by FORM and concluded by ENDFORM.&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;            [CHANGING... [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; ...&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;&amp;lt;subr&amp;gt; is the name of the subroutine. The optional additions USING and CHANGING define the parameter interface. Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event block in the wrong place by inserting a FORM...ENDFORM block. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You call subroutines using the statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM... [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;Subroutines can call other subroutines (nested calls) and may also call themselves (recursive calls). Once a subroutine has finished running, the calling program carries on processing after the PERFORM statement. You can use the USING and CHANGING additions to supply values to the parameter interface of the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sai&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:24:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472388#M834653</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472389#M834654</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;Subroutine is just a function which is similiar to the other programming languages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For getting help on subroutines go to Abap Editor (se38) and write form abc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.....&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;Press F1 on the FORM and ABAP help will open.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;&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;Dhruv Shah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:24:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472389#M834654</guid>
      <dc:creator>dhruv_shah3</dc:creator>
      <dc:date>2008-03-05T05:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472390#M834655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this links.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://searchsap.techtarget.com/tip/0,289483,sid21_gci1250455,00.html" target="test_blank"&gt;http://searchsap.techtarget.com/tip/0,289483,sid21_gci1250455,00.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;P&gt;sowjanya.b&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:25:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472390#M834655</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472391#M834656</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;A subroutine is a block of code introduced by FORM and concluded by ENDFORM.&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;            [CHANGING... [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; ...&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;&amp;lt;subr&amp;gt; is the name of the subroutine. The optional additions USING and CHANGING define the parameter interface. Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event block in the wrong place by inserting a FORM...ENDFORM block. &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;A href="http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/9f/db982c35c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:25:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472391#M834656</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472392#M834657</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;/P&gt;&lt;P&gt;if you are using the same code for more than one time and in more than one program then we go for subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first we have to create one program in subroutine pool and we can call that program where we need that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for this perform &amp;lt;sub_name&amp;gt; in program &amp;lt;program_name&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;swami.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:26:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472392#M834657</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472393#M834658</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;FORM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Defines a subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&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;                       [CHANGING... [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;Introduces a subroutine &amp;lt;form&amp;gt;. The USING and CHANGING additions define the subroutine&amp;#146;s parameter interface. The subroutine end with ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:28:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472393#M834658</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472394#M834659</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;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_46c/helpdata/en/9f/db976935c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/9f/db975c35c111d1829f0000e829fbfe/content.htm&lt;/A&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;Local Data in the Subroutine &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data declarations in procedures create local data types and objects that are only visible &lt;/P&gt;&lt;P&gt;within that procedure. There are two kinds of data types and objects &amp;#150; dynamic and static.&lt;/P&gt;&lt;P&gt; Dynamic data objects only exist while the subroutine is running, while static objects still &lt;/P&gt;&lt;P&gt;exist after the subroutine has finished running, and retain their values until the next time &lt;/P&gt;&lt;P&gt;the subroutine is called. Field symbols can be declared locally. You can also use a special kind &lt;/P&gt;&lt;P&gt;of data object for subroutines &amp;#150; copies of global data on a local data stack. You define and address&lt;/P&gt;&lt;P&gt; them using field symbols.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic Local Data Types and Objects&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local data types and objects declared in subroutines using the TYPES and DATAstatements are deleted &lt;/P&gt;&lt;P&gt;when the subroutine ends, and recreated each time the routine is called.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every subroutine has its own local namespace. If you declare a local data type or object with the&lt;/P&gt;&lt;P&gt; same name as a global data type or object, the global type or object cannot be addressed from within &lt;/P&gt;&lt;P&gt;the subroutine. Local data types or data objects hide identically named global data types or objects.&lt;/P&gt;&lt;P&gt; This means that if you use the name of a data type or object in the subroutine, you always address a &lt;/P&gt;&lt;P&gt;locally declared object &amp;#150; if this exists &amp;#150; and otherwise a globally declared one. To prevent global data &lt;/P&gt;&lt;P&gt;types or objects from being hidden, local types and objects must have other names assigned to them. &lt;/P&gt;&lt;P&gt;For example, all local names in subroutines could begin with &amp;#145;F _&amp;#146;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_mod_tech_data_types .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES word(10) TYPE c.&lt;/P&gt;&lt;P&gt;DATA  text TYPE word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;text = '1234567890'.  WRITE / text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM datatest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE / text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM datatest.&lt;/P&gt;&lt;P&gt;  TYPES word(5) TYPE c.&lt;/P&gt;&lt;P&gt;  DATA  text TYPE word.&lt;/P&gt;&lt;P&gt;  text = 'ABCDEFGHJK'. WRITE / text.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you run the program, the following is displayed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1234567890&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABCDE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1234567890&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, a data type word and a global data object text with type word are declared globally in the main program.&lt;/P&gt;&lt;P&gt; After a value has been assigned to text and this has been displayed on the list, the internal subroutine datatest is called.&lt;/P&gt;&lt;P&gt; Inside the subroutine, a data type word and a local data object text with type word are declared locally.&lt;/P&gt;&lt;P&gt; They hide the global type and object. Only after the subroutine is finished are the global definitions are valid again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Static Local Data Objects&lt;/P&gt;&lt;P&gt;If you want to keep the value of a local data object after exiting the subroutine, you must use the STATICS statement&lt;/P&gt;&lt;P&gt; to declare it instead of the DATA statement. With STATICS you declare a data object that is globally defined,&lt;/P&gt;&lt;P&gt; but only locally visible from the subroutine in which it is defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_mod_tech_statics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM datatest1.&lt;/P&gt;&lt;P&gt;PERFORM datatest1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SKIP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM datatest2.&lt;/P&gt;&lt;P&gt;PERFORM datatest2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM datatest1.&lt;/P&gt;&lt;P&gt;  TYPES f_word(5) TYPE c.&lt;/P&gt;&lt;P&gt;  DATA  f_text TYPE f_word VALUE 'INIT'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;  f_text = '12345'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM datatest2.&lt;/P&gt;&lt;P&gt;  TYPES    f_word(5) TYPE c.&lt;/P&gt;&lt;P&gt;  STATICS  f_text TYPE f_word VALUE 'INIT'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;  f_text = 'ABCDE'.&lt;/P&gt;&lt;P&gt;  WRITE f_text.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you run the program, the following is displayed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INIT  12345 INIT  12345&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INIT  ABCDE ABCDE ABCDE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, two similar subroutines datatest1 and datatest2 are defined.&lt;/P&gt;&lt;P&gt; In datatest2 , the STATICSstatement is used instead of the DATA statement to declare&lt;/P&gt;&lt;P&gt; the data object f_text. During each call of datatest1, f_text is initialized again, but it keeps&lt;/P&gt;&lt;P&gt; its value for datatest2. The VALUE addition of the STATICSstatement functions only during the first call of datatest2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local Field Symbols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All field symbols declared in a subroutine using the FIELD-SYMBOLS statement are local. For local field symbols,&lt;/P&gt;&lt;P&gt; the following rules apply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        You cannot address local field symbols outside the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        When you call the subroutine, no field is assigned to a local field symbol &amp;#150; not even if an ASSIGN was &lt;/P&gt;&lt;P&gt;          executed in the last run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        Local field symbols can have the same names as global field symbols. If they do, they hide the global field &lt;/P&gt;&lt;P&gt;           symbols within the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        You can also declare structured field symbols locally. They can have local structures and you can assign &lt;/P&gt;&lt;P&gt;         local fields to them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local Copies of Global Fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a subroutine, you can create local copies of global data on the local stack. To do this, use a local field symbol &lt;/P&gt;&lt;P&gt;and the following variant of the ASSIGN statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN LOCAL COPY OF field TO  TABLES IN_TAB STRUCTURE ITCSY&lt;/P&gt;&lt;P&gt;OUT_TAB STRUCTURE ITCSY.&lt;/P&gt;&lt;P&gt;&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;The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (&amp;#145;First page&amp;#146;, &amp;#145;Next page&amp;#146;, &amp;#145;Last page&amp;#146;) is printed as local variable symbol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definition in the SAPscript form:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO&lt;/P&gt;&lt;P&gt;/: USING &amp;amp;PAGE&amp;amp;&lt;/P&gt;&lt;P&gt;/: USING &amp;amp;NEXTPAGE&amp;amp;&lt;/P&gt;&lt;P&gt;/: CHANGING &amp;amp;BARCODE&amp;amp;&lt;/P&gt;&lt;P&gt;/: ENDPERFORM&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/ &amp;amp;BARCODE&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coding of the calling ABAP program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT QCJPERFO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY&lt;/P&gt;&lt;P&gt;OUT_PAR STRUCTURE ITCSY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: PAGNUM LIKE SY-TABIX, "page number &lt;/P&gt;&lt;P&gt;NEXTPAGE LIKE SY-TABIX. "number of next page&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE IN_PAR WITH KEY &amp;#145;PAGE&amp;#146;.&lt;/P&gt;&lt;P&gt;CHECK SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;PAGNUM = IN_PAR-VALUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE IN_PAR WITH KEY &amp;#145;NEXTPAGE&amp;#146;.&lt;/P&gt;&lt;P&gt;CHECK SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;NEXTPAGE = IN_PAR-VALUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE IN_PAR WITH KEY &amp;#145;BARCODE&amp;#146;.&lt;/P&gt;&lt;P&gt;CHECK SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;IF PAGNUM = 1.&lt;/P&gt;&lt;P&gt;OUT_PAR-VALUE = &amp;#145;|&amp;#146;. "First page &lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;OUT_PAR-VALUE = &amp;#145;||&amp;#146;. "Next page &lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NEXTPAGE = 0.&lt;/P&gt;&lt;P&gt;OUT_PAR-VALUE+2 = &amp;#145;L&amp;#146;. "Flag: last page&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY OUT_PAR INDEX SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &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; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with regards,&lt;/P&gt;&lt;P&gt;sowjanyagosala.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:29:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472394#M834659</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472395#M834660</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;SUBROUTINES:&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;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;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;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;&lt;/P&gt;&lt;P&gt;PASS BY REFERENCE:&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;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;&lt;/P&gt;&lt;P&gt;PASSING INTERNAL TABLE AS AN ARGUMENT:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------" /&gt;&lt;P&gt;&lt;/P&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;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:34:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472395#M834660</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472396#M834661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Subroutines are created mainly for code reusablity. I can tell this with one simple example. If u r calling some function module 10 times in your program, Then u can put this FM in a subroutine and call this subroutine where ever u want. So it will reduce the lines of code. U can pass parameters in 3 ways USING, CHANGING, TABLES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;USING-Acts as only input. (Call by value)&lt;/P&gt;&lt;P&gt;CHANGING-Acts as input/output(Call by reference)&lt;/P&gt;&lt;P&gt;TABLES-Acts as input/output(Call by reference)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check F1 help for more details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinod.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:34:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472396#M834661</guid>
      <dc:creator>vinod_vemuru2</dc:creator>
      <dc:date>2008-03-05T05:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: hi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472397#M834662</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;SUBROUTINES:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subroutines are modularization technique in a program, which is used to hold a piece of code within a block. This piece of code can be called by another statement whenever needed either within the program or from another program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM - ENDFORM statement is used to create subroutines in a program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SYNTAX:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM &amp;lt;subroutine_name&amp;gt;.&lt;/P&gt;&lt;P&gt;...attributes...&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The subroutine name can be 30 characters long.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To invoke the subroutine, use PERFORM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SYNTAX:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM &amp;lt;subroutine_name&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUBROUTINE TYPES:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------" /&gt;&lt;P&gt;1. Internal subroutine - A subroutine called from within the same program using PERFORM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. External subroutine - Subroutine called from another program using PERFORM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg. code for internal subroutine and invoking subroutine without any argument:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'THIS IS FIRST INVOKE'.&lt;/P&gt;&lt;P&gt;PERFORM SHABANA.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'THIS IS ABAP'.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'THIS IS SAP'.&lt;/P&gt;&lt;P&gt;SKIP 1.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'THIS IS SECOND INVOKE'.&lt;/P&gt;&lt;P&gt;PERFORM SHABANA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM SHABANA.&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; 'THIS IS SUBROUTINE CONCEPT'.&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;Eg. code for external subroutine:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SYNTAX:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------" /&gt;&lt;P&gt;PERFORM &amp;lt;subroutine_name&amp;gt;(&amp;lt;program_name&amp;gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program name should be specified where your subroutine code exist.&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;HR originaltext="----------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORMAL PARAMETERS are those declared in the FORM statement followed by the keyword USING. These are also called as 'sending variables'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ACTUAL PARAMETERS are those defined in the PERFORM statement followed by the keyword USING. These are also called as 'receiving variables'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg. code:&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 SHABANA USING A B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM SHABANA 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;In the above code, X and Y are local variables for subroutine, A and B are global variables.&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;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 SHABANA USING A B.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; A , B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM SHABANA USING value(X) value(Y).&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;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above code, keyword VALUE is used to send values as arguments from the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOCAL VARIABLE - If we declare variables within FORM-ENDFORM statement, these variables are called as local varibles.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GLOBAL VARIABLE - Variables declared outside the FORM-ENDFORM statement are called as global variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STATIC VARIABLE - These are local variables with global variable attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg. code for static variable:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA X TYPE I VALUE '10'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM SHABANA USING X.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM SHABANA USING X.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM SHABANA USING Y.&lt;/P&gt;&lt;P&gt;STATICS TOT TYPE I.&lt;/P&gt;&lt;P&gt;TOT = TOT + Y.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; TOT.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The keyword STATICS is used to declare a static variable in subroutine between FORM-ENDFORM statement. &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;HR originaltext="-------------------------------------" /&gt;&lt;P&gt;SYNTAX:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM &amp;lt;subroutine_name&amp;gt; TABLES &amp;lt;itab_name&amp;gt; STRUCTURE &amp;lt;dbtable_name&amp;gt;.&lt;/P&gt;&lt;P&gt;...attributes...&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To pass internal table as an argument, never use 'USING' keyword in the FORM statement. Specify internal table name followed by TABLES statement and specify for which structure, you are creating internal table followed by STRUCTURE keyword.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When invoking,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM &amp;lt;subroutine_name&amp;gt; TABLES &amp;lt;itab_name&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg. code:&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;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 KTAB STRUCTURE KNA1.&lt;/P&gt;&lt;P&gt;LOOP AT KTAB.&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; KTAB-KUNNR, KTAB-NAME1.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ADVANTAGES OF SUBROUTINE:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Readability.&lt;/P&gt;&lt;P&gt;2. Reduces code redundancy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DISADVANTAGES OF SUBROUTINE:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Subroutines cannot return a value.&lt;/P&gt;&lt;P&gt;2. Subroutines cannot be called from another client.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 05:35:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hi/m-p/3472397#M834662</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T05:35:28Z</dc:date>
    </item>
  </channel>
</rss>

