<?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 nested looping with select stmt in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023124#M714758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;              I need to create an abap program that takes i/p a database table(dbtable contains list of table names).The expected o/p is a DB table with tablename,co_code,total amt in local curr,amount in doc curr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the following is my logic:&lt;/P&gt;&lt;P&gt;Select * from zmatlist into table it_tablist where zmatlist~tflag like ''.  "condition to get list of table names from DB table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Loop at it_tablist into wa_tablist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Select [distinct]co_code from (wa_tablist-tabname) into table it_cocode.&lt;/P&gt;&lt;P&gt;         &lt;/P&gt;&lt;P&gt;         Loop at it_cocode into wa_cocode.&lt;/P&gt;&lt;P&gt;            select amount curtype from (wa_tablist-tabname) into table it_amount where co_code = wa_cocode-cocode.&lt;/P&gt;&lt;P&gt;              loop at it_amount into wa_amount.&lt;/P&gt;&lt;P&gt;                if curtype eq '00'.&lt;/P&gt;&lt;P&gt;                  sum = sum + wa_amount-amount.&lt;/P&gt;&lt;P&gt;                else.&lt;/P&gt;&lt;P&gt;                  total = total + wa_amount-amount.&lt;/P&gt;&lt;P&gt;               endloop.&lt;/P&gt;&lt;P&gt;              wa_result-tabname = wa_tablist-tabname.&lt;/P&gt;&lt;P&gt;              wa_result-cocode = wa_cocode-cocode.&lt;/P&gt;&lt;P&gt;              wa_result-AMTLC = sum.&lt;/P&gt;&lt;P&gt;              wa_result-AMTDC = total.&lt;/P&gt;&lt;P&gt;             Append wa_result to it_result.&lt;/P&gt;&lt;P&gt;             Clear: sum,&lt;/P&gt;&lt;P&gt;                   total.&lt;/P&gt;&lt;P&gt;             refresh: it_amount.&lt;/P&gt;&lt;P&gt;         endloop.&lt;/P&gt;&lt;P&gt;         refresh it_cocode.&lt;/P&gt;&lt;P&gt;     Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i am executing it,it is not able to recognise amount field.How to refer amount ,cocode here?&lt;/P&gt;&lt;P&gt;Am i writing it so complex?Is there any easy way to do it.Plz let me know if there is any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Oct 2007 23:27:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-28T23:27:04Z</dc:date>
    <item>
      <title>nested looping with select stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023124#M714758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;              I need to create an abap program that takes i/p a database table(dbtable contains list of table names).The expected o/p is a DB table with tablename,co_code,total amt in local curr,amount in doc curr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the following is my logic:&lt;/P&gt;&lt;P&gt;Select * from zmatlist into table it_tablist where zmatlist~tflag like ''.  "condition to get list of table names from DB table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Loop at it_tablist into wa_tablist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Select [distinct]co_code from (wa_tablist-tabname) into table it_cocode.&lt;/P&gt;&lt;P&gt;         &lt;/P&gt;&lt;P&gt;         Loop at it_cocode into wa_cocode.&lt;/P&gt;&lt;P&gt;            select amount curtype from (wa_tablist-tabname) into table it_amount where co_code = wa_cocode-cocode.&lt;/P&gt;&lt;P&gt;              loop at it_amount into wa_amount.&lt;/P&gt;&lt;P&gt;                if curtype eq '00'.&lt;/P&gt;&lt;P&gt;                  sum = sum + wa_amount-amount.&lt;/P&gt;&lt;P&gt;                else.&lt;/P&gt;&lt;P&gt;                  total = total + wa_amount-amount.&lt;/P&gt;&lt;P&gt;               endloop.&lt;/P&gt;&lt;P&gt;              wa_result-tabname = wa_tablist-tabname.&lt;/P&gt;&lt;P&gt;              wa_result-cocode = wa_cocode-cocode.&lt;/P&gt;&lt;P&gt;              wa_result-AMTLC = sum.&lt;/P&gt;&lt;P&gt;              wa_result-AMTDC = total.&lt;/P&gt;&lt;P&gt;             Append wa_result to it_result.&lt;/P&gt;&lt;P&gt;             Clear: sum,&lt;/P&gt;&lt;P&gt;                   total.&lt;/P&gt;&lt;P&gt;             refresh: it_amount.&lt;/P&gt;&lt;P&gt;         endloop.&lt;/P&gt;&lt;P&gt;         refresh it_cocode.&lt;/P&gt;&lt;P&gt;     Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i am executing it,it is not able to recognise amount field.How to refer amount ,cocode here?&lt;/P&gt;&lt;P&gt;Am i writing it so complex?Is there any easy way to do it.Plz let me know if there is any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Oct 2007 23:27:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023124#M714758</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-28T23:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: nested looping with select stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023125#M714759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Welcome to SDN &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Have you tried using field symbols for your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Oct 2007 23:33:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023125#M714759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-28T23:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: nested looping with select stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023126#M714760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Atish,&lt;/P&gt;&lt;P&gt;             No i haven't tried with field symbols.I am not familiour with them.But i am wondering how come it is not able to identify amount,co_code when i am refering to a single table in each select stmt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Oct 2007 23:44:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-looping-with-select-stmt/m-p/3023126#M714760</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-28T23:44:42Z</dc:date>
    </item>
  </channel>
</rss>

