<?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 Subroutines in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608599#M598178</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;I want to pass an internal table by using subroutines. Now I want to have two subroutines one changing the contents of the internal table and the other without changing the internal table contents.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jul 2007 05:01:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-31T05:01:36Z</dc:date>
    <item>
      <title>Subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608599#M598178</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;I want to pass an internal table by using subroutines. Now I want to have two subroutines one changing the contents of the internal table and the other without changing the internal table contents.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 05:01:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608599#M598178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T05:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608600#M598179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ravikanth,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer this link,it will provide u sample code for all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db979035c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db979035c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 05:04:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608600#M598179</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T05:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608601#M598180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;We use TABLES parameters for passing the internal tables to subroutines and Internal tables are always passed by reference&lt;/P&gt;&lt;P&gt;see the doc&lt;/P&gt;&lt;P&gt;PERFORM - parameter_list &lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;... [TABLES   itab1 itab2 ...] &lt;/P&gt;&lt;P&gt;    [USING    a1 a2 ...] &lt;/P&gt;&lt;P&gt;    [CHANGING a1 a2 ...]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Extras: &lt;/P&gt;&lt;P&gt;1. ... TABLES itab1 itab2 ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. ... USING a1 a2 ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. ... CHANGING a1 a2 ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;These additions assign actual parameters to the formal parameters from the parameter interface for the subroutine subr. You can specify all data objects whose data type matches the typing of the corresponding formal parameter (see Check Typing) as actual parameters. Each formal parameter assumes all the properties of the actual parameter assigned to it when it is called. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition 1 &lt;/P&gt;&lt;P&gt;... TABLES itab1 itab2 ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;If you specify the addition TABLES, each table parameter t1 t2 ... for the subroutine called that is defined with the addition TABLES to the FORM statement must be assigned an internal table itab as the actual parameter. The assignment of the actual parameters to the formal parameters takes place using their positions in the lists t1 t2 ... and itab1 itab2 ... . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can only specify standard tables for itab. Transfer takes place by means of a reference. If a specified table itab has a header line, this is also transferred; otherwise, the header line in the corresponding table parameter t is blank when it is called. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note &lt;/P&gt;&lt;P&gt;Use of table parameters in the interface for subroutines is obsolete but a large number of subroutines have not yet been converted to appropriately typed USING or CHANGING parameters, so that they must still be supplied with data by the TABLES addition to the PERFORM statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Static call of the internal subroutine select_sflight transferring a table parameter. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_carr TYPE sflight-carrid, &lt;/P&gt;&lt;P&gt;            p_conn TYPE sflight-connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA sflight_tab TYPE STANDARD TABLE OF sflight. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM select_sflight TABLES sflight_tab &lt;/P&gt;&lt;P&gt;                       USING  p_carr p_conn. &lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM select_sflight TABLES flight_tab LIKE sflight_tab &lt;/P&gt;&lt;P&gt;                    USING  f_carr TYPE sflight-carrid &lt;/P&gt;&lt;P&gt;                           f_conn TYPE sflight-connid. &lt;/P&gt;&lt;P&gt;  SELECT * &lt;/P&gt;&lt;P&gt;         FROM sflight &lt;/P&gt;&lt;P&gt;         INTO TABLE flight_tab &lt;/P&gt;&lt;P&gt;         WHERE carrid = f_carr AND &lt;/P&gt;&lt;P&gt;               connid = f_conn. &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;Addition 2 &lt;/P&gt;&lt;P&gt;... USING a1 a2 ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition 3 &lt;/P&gt;&lt;P&gt;... CHANGING a1 a2 ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;If you specify the additions USING and CHANGING, an actual parameter a1 a2 ... of the appropriate type must be assigned to each of the formal parameters u1 u2 ... and c1 c2 ... defined with the same additions to the FORM statement. The actual parameters specified after USING and CHANGING form one shared list. They are assigned to the formal parameters after the position in the shared list. The type of parameter transfer is defined with the additions USING and CHANGING to the FORM statement. The addition USING must be before CHANGING. Otherwise, the assignment of the actual parameters to the additions USING and CHANGING is irrelevant to the PERFORM statement. It is also irrelevant whether only one or both of the additions is specified. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes &lt;/P&gt;&lt;P&gt;For the sake of program documentation, we advise that you specify the additions USING and CHANGING in the FORM statement according to the definition of the parameter interface. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In non-Unicode programs, you can address memory area outside an actual parameter if an actual parameter a1 a2 ... is assigned offset or length specifications. In non-Unicode programs, the length is set to the length of the current parameter if an offset is specified without a length. Both of these lead to warnings in the syntax check and to syntax errors in Unicode programs. The rules for the ASSIGN statement apply to the addressable memory area in non-Unicode programs as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;The following five PERFORM statements mean the same but only the fourth is recommended, since it is the only one that documents the interface of the subroutine called. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: a1 TYPE string, &lt;/P&gt;&lt;P&gt;      a2 TYPE string, &lt;/P&gt;&lt;P&gt;      a3 TYPE string, &lt;/P&gt;&lt;P&gt;      a4 TYPE string. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM test USING a1 a2 a3 a4. &lt;/P&gt;&lt;P&gt;PERFORM test CHANGING a1 a2 a3 a4. &lt;/P&gt;&lt;P&gt;PERFORM test USING a1 CHANGING a2 a3 a4. &lt;/P&gt;&lt;P&gt;PERFORM test USING a1 a2 CHANGING a3 a4. &lt;/P&gt;&lt;P&gt;PERFORM test USING a1 a2 a3 CHANGING a4. &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 test USING p1 TYPE string &lt;/P&gt;&lt;P&gt;                p2 TYPE string &lt;/P&gt;&lt;P&gt;          CHANGING value(p3) TYPE string &lt;/P&gt;&lt;P&gt;                   value(p4) TYPE string. &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;b&amp;gt;Reward points for useful Answers&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 05:04:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608601#M598180</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T05:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608602#M598181</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 you dont want to change the internal table then use USING and VALUE().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF you want to change then use CHANGING.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES: tab_type type table of SPFLI.

DATA: itab type tab_type.

PERFORM no_change using itab. "no change

PERFORM change changing itab. "with change

form no_change using value(p_tab) type tab_type.
* cannot change here
endform.

form change changing p_itab type tab_type.
* can change here
endform.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 05:05:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608602#M598181</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2007-07-31T05:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608603#M598182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

1)perform sub_routine using itab. "changing the contents of the internal table

form sub_routine using p_itab.
code.. to change p_itab. Changes will be reflected to itab also
endform

2) perform sub_routine changing itab."without changing the internal table contents

form sub_routine changing p_itab.
code.. to change p_itab. Changes wont be reflected to itab 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;lt;b&amp;gt;reward if useful&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;endform&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 05:05:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608603#M598182</guid>
      <dc:creator>Vijay</dc:creator>
      <dc:date>2007-07-31T05:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Subroutines</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608604#M598183</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;Check the following example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM FORM_TEST.&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;COL1 TYPE I,&lt;/P&gt;&lt;P&gt;COL2 TYPE I,&lt;/P&gt;&lt;P&gt;END OF LINE.&lt;/P&gt;&lt;P&gt;DATA: ITAB TYPE STANDARD TABLE OF LINE WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;JTAB TYPE STANDARD TABLE OF LINE.&lt;/P&gt;&lt;P&gt;PERFORM FILL TABLES ITAB.&lt;/P&gt;&lt;P&gt;MOVE ITAB[] TO JTAB.&lt;/P&gt;&lt;P&gt;PERFORM OUT TABLES JTAB.&lt;/P&gt;&lt;P&gt;FORM FILL TABLES F_ITAB LIKE ITAB[].&lt;/P&gt;&lt;P&gt;DO 3 TIMES.&lt;/P&gt;&lt;P&gt;F_ITAB-COL1 = SY-INDEX.&lt;/P&gt;&lt;P&gt;F_ITAB-COL2 = SY-INDEX ** 2.&lt;/P&gt;&lt;P&gt;APPEND F_ITAB.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;FORM OUT TABLES F_ITAB LIKE JTAB.&lt;/P&gt;&lt;P&gt;LOOP AT F_ITAB.&lt;/P&gt;&lt;P&gt;WRITE: / F_ITAB-COL1, F_ITAB-COL2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;The produces the following output:&lt;/P&gt;&lt;P&gt;1      1&lt;/P&gt;&lt;P&gt;2      4&lt;/P&gt;&lt;P&gt;3      9&lt;/P&gt;&lt;P&gt;In this example, an internal table ITAB is declared with a header line and an&lt;/P&gt;&lt;P&gt;internal table JTAB is declared without a header line. The actual parameter ITAB&lt;/P&gt;&lt;P&gt;is passed to the formal parameter F_ITAB of the subroutine FILL in the TABLES&lt;/P&gt;&lt;P&gt;addition. The header line is passed with it. After the body of the table has been&lt;/P&gt;&lt;P&gt;copied from ITAB to JTAB, the actual parameter is passed to the formal&lt;/P&gt;&lt;P&gt;parameter F_ITAB of the subroutine OUT using the TABLES addition. The&lt;/P&gt;&lt;P&gt;header line F_ITAB, which is not passed, is generated automatically in the&lt;/P&gt;&lt;P&gt;subroutine.&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>Tue, 31 Jul 2007 05:28:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutines/m-p/2608604#M598183</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T05:28:32Z</dc:date>
    </item>
  </channel>
</rss>

