<?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: subroutine in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617652#M1087939</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;case.&lt;/P&gt;&lt;P&gt;  when 1.                                                             " retrieve data from table 1.&lt;/P&gt;&lt;P&gt;       perform get_data using common_fields '1'.&lt;/P&gt;&lt;P&gt;  when 2.                                                             " retrieve data from table 2.&lt;/P&gt;&lt;P&gt;       perform get_data using common_fields '2'.&lt;/P&gt;&lt;P&gt;  when 3 .                                                            " retrieve data from table 3.&lt;/P&gt;&lt;P&gt;       perform get_data using common_fields '3'.&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_data using fields tablenumber.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if tablenumber = '1'.&lt;/P&gt;&lt;P&gt;     assign table 1.&lt;/P&gt;&lt;P&gt;  if tablenumber = '2'.&lt;/P&gt;&lt;P&gt;     assign table 2.&lt;/P&gt;&lt;P&gt;  if tablenumber = '3'.&lt;/P&gt;&lt;P&gt;      assign table 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;lt;&amp;lt; get data from table &amp;gt;&amp;gt;&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, 09 Oct 2008 11:17:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-09T11:17:39Z</dc:date>
    <item>
      <title>subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617648#M1087935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guruz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is my question&lt;/P&gt;&lt;P&gt;i gotto pull data from 3 tables  based on the case statement but im passing same values to retrieve the data .now how can i use 1 perform statement so it can pull the data from table based on case.&lt;/P&gt;&lt;P&gt;( at the moment im using 3 performz)&lt;/P&gt;&lt;P&gt;plz advise..&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;Edited by: BrightSide on Oct 9, 2008 11:56 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 10:30:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617648#M1087935</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T10:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617649#M1087936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;perform fetch using XXXXXX XXXXX XXXXXX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where 'XXXXXX'are your fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 11:02:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617649#M1087936</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T11:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617650#M1087937</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;Pass all parameters to a suborutine and inside subroutine do a case statement or condtional if and depending of the condtion result do your processing on desired table.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM case_form using var1 type var2 type c var3 type c 
                          tables tab1 tab2 tab3.
   if var1 eq 'X'.
      "processing of tab1
   elseif var2 eq 'X'.
      "processing of tab2
   elseif va3 eq 'X'.
      "processing of tab3
   endif.
ENDFORM.


"Then just call your subroitune only once.
PERFORM case_form using...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that what you meant?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 11:08:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617650#M1087937</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2008-10-09T11:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617651#M1087938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bright,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Can you please explain in brief about your requirement.&lt;/P&gt;&lt;P&gt;   Whether you want to fetch the data from one table depending upon the case statement condition or from three tables in each &lt;/P&gt;&lt;P&gt;case statement condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) If you want to fecth the data from 3 tables in every case statement then, its is easy create the the subroutine.&lt;/P&gt;&lt;P&gt;just call the subroutine with respective parameters ans define the logic to fetch the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) If you want to fecth the data from selective table depending on the condition of the case statement, then &lt;/P&gt;&lt;P&gt;pass the parametet of the subroutine as the table name.&lt;/P&gt;&lt;P&gt;and use the dynamic table name in the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This might solve the problem. If not please let us know your &lt;/P&gt;&lt;P&gt; requirement in brief.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dinakar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 11:08:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617651#M1087938</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T11:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617652#M1087939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;case.&lt;/P&gt;&lt;P&gt;  when 1.                                                             " retrieve data from table 1.&lt;/P&gt;&lt;P&gt;       perform get_data using common_fields '1'.&lt;/P&gt;&lt;P&gt;  when 2.                                                             " retrieve data from table 2.&lt;/P&gt;&lt;P&gt;       perform get_data using common_fields '2'.&lt;/P&gt;&lt;P&gt;  when 3 .                                                            " retrieve data from table 3.&lt;/P&gt;&lt;P&gt;       perform get_data using common_fields '3'.&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_data using fields tablenumber.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if tablenumber = '1'.&lt;/P&gt;&lt;P&gt;     assign table 1.&lt;/P&gt;&lt;P&gt;  if tablenumber = '2'.&lt;/P&gt;&lt;P&gt;     assign table 2.&lt;/P&gt;&lt;P&gt;  if tablenumber = '3'.&lt;/P&gt;&lt;P&gt;      assign table 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;lt;&amp;lt; get data from table &amp;gt;&amp;gt;&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, 09 Oct 2008 11:17:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617652#M1087939</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T11:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617653#M1087940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;thanks for ur replies,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I want to fecth the data from selective table depending on the condition of the case statement, then &lt;/P&gt;&lt;P&gt;pass the parametet of the subroutine as the table name.&lt;/P&gt;&lt;P&gt;and use the dynamic table name in the select statement.&lt;/P&gt;&lt;P&gt;plz advise..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: BrightSide on Oct 9, 2008 12:28 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 11:28:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617653#M1087940</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T11:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617654#M1087941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where you want the case statement to be, inside or outside soubroutine?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To pass table_name dynamically to routine use:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM sub USING table_name type c.
    select * from (table) into ...
ENDFORM.

"then call it like this
PERFORM sub USING 'TABLE1'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 11:41:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617654#M1087941</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2008-10-09T11:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617655#M1087942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IF XXXXXX = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tablename = 'ekko'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peform fetch tables gt_output&lt;/P&gt;&lt;P&gt;             using  tablename fieldname fieldname1 fieldname2 fieldname3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elseif YYYYYY = 'Y'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tablename = 'ekpo'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peform fetch tables gt_output&lt;/P&gt;&lt;P&gt;             using  tablename fieldname fieldname1 fieldname2 fieldname3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tablename = 'XXXXX'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peform fetch tables gt_output&lt;/P&gt;&lt;P&gt;             using  tablename fieldname fieldname1 fieldname2 fieldname3.&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;Form .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select ebeln ........ from tablename&lt;/P&gt;&lt;P&gt;into gt_output&lt;/P&gt;&lt;P&gt;= &amp;gt;into corresponding gt_output ( If selected fields are different for three tables)&lt;/P&gt;&lt;P&gt;where XXXXX = fieldname and&lt;/P&gt;&lt;P&gt;      XXXXX = fieldname1 and&lt;/P&gt;&lt;P&gt;      XXXXX = fieldname2.&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, 09 Oct 2008 11:42:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617655#M1087942</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T11:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617656#M1087943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;data:
  it_kna1 type table of kna1,
  wa_kna1 type kna1,
  it_vbak type table of vbak,
  wa_vbak type vbak.

  perform fill_tab using 'KNA1'
                         'IT_KNA1[]'.

  perform fill_tab using 'VBAK'
                         'IT_VBAK[]'.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  FILL_TAB
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_0026   text
*      --&amp;gt;P_0027   text
*----------------------------------------------------------------------*
form FILL_TAB  using    value(p_dbtab)
                        value(p_itab).

  field-symbols: &amp;lt;fs_itab&amp;gt;  type any table.

   assign (p_itab)  to &amp;lt;fs_itab&amp;gt;.
   if sy-subrc eq 0,

     select * from (p_dbtab)
       into table &amp;lt;fs_itab&amp;gt;.
*    where ....

   endif.

endform.                    " FILL_TAB&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the WHERE clause: guess you'll be able to find out yourself how to do that&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2008 11:59:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/subroutine/m-p/4617656#M1087943</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-09T11:59:33Z</dc:date>
    </item>
  </channel>
</rss>

