<?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 Fetch data from 50  tables with single query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-50-tables-with-single-query/m-p/8455762#M1649963</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 am having a requirement where I should fetch the records count  in a table, since there are close to 50 tables I have written below code, which is working fine with out WHERE  clause, but going to short dump if I use a where clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF NOT p_sel_opt IS INITIAL.
    LOOP AT p_sel_opt INTO wa_sel_opt .
      ASSIGN wa_sel_opt-low TO &amp;lt;fval&amp;gt;.
      ASSIGN  p_fieldname TO &amp;lt;field&amp;gt;.
      IF &amp;lt;field&amp;gt; IS ASSIGNED AND &amp;lt;fval&amp;gt; IS ASSIGNED.
        SELECT COUNT(*)  FROM (p_tabname) WHERE &amp;lt;FIELD&amp;gt;  = &amp;lt;fval&amp;gt;  .
        IF sy-subrc = 0.
          wa_fi_bukrs-bukrs = &amp;lt;fval&amp;gt;.
          wa_fi_bukrs-table =  p_tabname.
          wa_fi_bukrs-count = sy-dbcnt.
          APPEND wa_fi_bukrs TO it_fi_bukrs.
          CLEAR wa_fi_bukrs.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reason it is giving is &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;field&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; is not availble in the data base tables . what can I do to the above query for that to work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Varun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Dec 2011 17:08:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-12-13T17:08:44Z</dc:date>
    <item>
      <title>Fetch data from 50  tables with single query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-50-tables-with-single-query/m-p/8455762#M1649963</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 am having a requirement where I should fetch the records count  in a table, since there are close to 50 tables I have written below code, which is working fine with out WHERE  clause, but going to short dump if I use a where clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF NOT p_sel_opt IS INITIAL.
    LOOP AT p_sel_opt INTO wa_sel_opt .
      ASSIGN wa_sel_opt-low TO &amp;lt;fval&amp;gt;.
      ASSIGN  p_fieldname TO &amp;lt;field&amp;gt;.
      IF &amp;lt;field&amp;gt; IS ASSIGNED AND &amp;lt;fval&amp;gt; IS ASSIGNED.
        SELECT COUNT(*)  FROM (p_tabname) WHERE &amp;lt;FIELD&amp;gt;  = &amp;lt;fval&amp;gt;  .
        IF sy-subrc = 0.
          wa_fi_bukrs-bukrs = &amp;lt;fval&amp;gt;.
          wa_fi_bukrs-table =  p_tabname.
          wa_fi_bukrs-count = sy-dbcnt.
          APPEND wa_fi_bukrs TO it_fi_bukrs.
          CLEAR wa_fi_bukrs.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reason it is giving is &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;field&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; is not availble in the data base tables . what can I do to the above query for that to work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Varun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2011 17:08:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-50-tables-with-single-query/m-p/8455762#M1649963</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-13T17:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data from 50  tables with single query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-50-tables-with-single-query/m-p/8455763#M1649964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;replace &lt;STRONG&gt;&amp;lt;field&amp;gt;&lt;/STRONG&gt; with &lt;STRONG&gt;(&amp;lt;field&amp;gt;)&lt;/STRONG&gt; ok?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but, its better if you construct your where clause.. i dont know the above will work or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like &lt;/P&gt;&lt;P&gt;concatenate &amp;lt;FIELD&amp;gt;  ' = ' &amp;lt;fval&amp;gt; into s1 separated by space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and pass &lt;STRONG&gt;where (s1).&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the FM RFC_READ_TABLE. you will get a proper picture&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Soumyaprakash Mishra on Dec 13, 2011 11:02 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2011 17:31:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-50-tables-with-single-query/m-p/8455763#M1649964</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-13T17:31:48Z</dc:date>
    </item>
  </channel>
</rss>

