<?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: select two diff fields and storing them in two variable in a same query ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647107#M287759</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the internal table is showing the sum grouped by material wise. I want to display each material and the SUM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Nov 2006 06:50:47 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-20T06:50:47Z</dc:date>
    <item>
      <title>select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647101#M287753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a join query and i am selecting fields from different table(one field is the material number and second is bsad-wrbtr, on which i am doing the SUM). Now i cant store material number in a variable, cause i will be getting many material numbers(against 'vbeln') and sum( bsad-wrbtr ) will be stored collectively in a variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shud i be using an internal table to store both of them ? , cause i have to display all the material numbers retrieved . If yes, the how ? what will be the query like ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current select/join query is,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  select  sum( bd~wrbtr ) into l_cramt
    from ( ( bsis as bs
              inner join bsad as bd on bs~bukrs = bd~bukrs and
                                       bs~belnr = bd~augbl and
                                       bs~bldat = bd~augdt )

              inner join vbrp as vb on vb~vbeln = bd~belnr )

    where bs~blart = 'DZ' and bs~hkont = p_hkont.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your replies, thank..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:21:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647101#M287753</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647102#M287754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u have to use internal table to store the material and sum cause u have to display in the output....try to use internal table and pass on the data to it...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:25:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647102#M287754</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647103#M287755</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;Do this way. Use collect statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define internal table which stores 2 fields&lt;/P&gt;&lt;P&gt;material number&lt;/P&gt;&lt;P&gt;wrbtr value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now define&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select   bd~matnr&lt;/P&gt;&lt;P&gt;            bd~wrbtr into &amp;lt;internal table&amp;gt;&lt;/P&gt;&lt;P&gt;    from ( ( bsis as bs&lt;/P&gt;&lt;P&gt;              inner join bsad as bd on bs&lt;SUB&gt;bukrs = bd&lt;/SUB&gt;bukrs and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;belnr = bd&lt;/SUB&gt;augbl and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;bldat = bd&lt;/SUB&gt;augdt )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;              inner join vbrp as vb on vb&lt;SUB&gt;vbeln = bd&lt;/SUB&gt;belnr )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    where bs&lt;SUB&gt;blart = 'DZ' and bs&lt;/SUB&gt;hkont = p_hkont.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  COLLECT &amp;lt;internal table&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="---------------------------------" /&gt;&lt;P&gt;This will sum up value for each same material.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*REWARD all helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:28:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647103#M287755</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647104#M287756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use &amp;lt;b&amp;gt;group by&amp;lt;/b&amp;gt; clause in the select stmt. It gives sum for the particular field&lt;/P&gt;&lt;P&gt;My current select/join query is,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select &amp;lt;b&amp;gt; material&amp;lt;/b&amp;gt; sum( bd~wrbtr ) into l_cramt&lt;/P&gt;&lt;P&gt;    from ( ( bsis as bs&lt;/P&gt;&lt;P&gt;              inner join bsad as bd on bs&lt;SUB&gt;bukrs = bd&lt;/SUB&gt;bukrs and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;belnr = bd&lt;/SUB&gt;augbl and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;bldat = bd&lt;/SUB&gt;augdt )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;              inner join vbrp as vb on vb&lt;SUB&gt;vbeln = bd&lt;/SUB&gt;belnr )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    where bs&lt;SUB&gt;blart = 'DZ' and bs&lt;/SUB&gt;hkont = p_hkont&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;group by material.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:33:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647104#M287756</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647105#M287757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ramesh, please show me what the query will be ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Palak,  is it bd&lt;SUB&gt;matnr or vb&lt;/SUB&gt;matnr ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vijay, your query is giving a dump. Says 'few fields in the INTO clause' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar  Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:39:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647105#M287757</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647106#M287758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should extract the data into internal table containing 2 fields of Matnr and wrbrt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:41:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647106#M287758</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647107#M287759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the internal table is showing the sum grouped by material wise. I want to display each material and the SUM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:50:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647107#M287759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647108#M287760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think u can extract the material and the sum within the same query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One solution might be again apply sum for the all the entries in the internal table, by this u will the materials as well as its sum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 06:56:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647108#M287760</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T06:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647109#M287761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lemme check and get back to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar Dahar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 07:19:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647109#M287761</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T07:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647110#M287762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shehryar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot select and sum the values using  a single query coz you query will return multiple materials.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should be done in two steps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) select your required data into the internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Then use SUM or Collect to get the required sum for the materials and display that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would be a better approach,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_temp.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;  wa_temp-material = itab-material.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    sum.&lt;/P&gt;&lt;P&gt;    at end of material.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;       wa_temp-wrbtr = itab-wrbtr.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      append wa_temp into itab2.&lt;/P&gt;&lt;P&gt;    endat. &lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: You do not have material number in your selection. It is required if you want to display the sum for materials.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your problem.&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;Kathirvel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 07:32:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647110#M287762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T07:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: select two diff fields and storing them in two variable in a same query ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647111#M287763</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 want to have a list of materials and sum for each of them try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of t_list,&lt;/P&gt;&lt;P&gt;            matnr like vbrp-matnr,&lt;/P&gt;&lt;P&gt;            wrbtr like bsad-wrbtr,&lt;/P&gt;&lt;P&gt;         end of t_list.&lt;/P&gt;&lt;P&gt;data: i_list type table of t_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select  vb&lt;SUB&gt;matnr sum( bd&lt;/SUB&gt;wrbtr ) into table i_list&lt;/P&gt;&lt;P&gt;    from ( ( bsis as bs&lt;/P&gt;&lt;P&gt;              inner join bsad as bd on bs&lt;SUB&gt;bukrs = bd&lt;/SUB&gt;bukrs and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;belnr = bd&lt;/SUB&gt;augbl and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;bldat = bd&lt;/SUB&gt;augdt )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;              inner join vbrp as vb on vb&lt;SUB&gt;vbeln = bd&lt;/SUB&gt;belnr )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    where bs&lt;SUB&gt;blart = 'DZ' and bs&lt;/SUB&gt;hkont = p_hkont&lt;/P&gt;&lt;P&gt;    group by vb~matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to have a sum for a given material try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select  vb&lt;SUB&gt;matnr sum( bd&lt;/SUB&gt;wrbtr ) into (v_matnr, v_wrbtr ) &lt;/P&gt;&lt;P&gt;    from ( ( bsis as bs&lt;/P&gt;&lt;P&gt;              inner join bsad as bd on bs&lt;SUB&gt;bukrs = bd&lt;/SUB&gt;bukrs and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;belnr = bd&lt;/SUB&gt;augbl and&lt;/P&gt;&lt;P&gt;                                       bs&lt;SUB&gt;bldat = bd&lt;/SUB&gt;augdt )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;              inner join vbrp as vb on vb&lt;SUB&gt;vbeln = bd&lt;/SUB&gt;belnr )&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    where bs&lt;SUB&gt;blart = 'DZ' and bs&lt;/SUB&gt;hkont = p_hkont&lt;/P&gt;&lt;P&gt;    and vb~matnr = p_matnr.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2006 07:52:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-two-diff-fields-and-storing-them-in-two-variable-in-a-same-query/m-p/1647111#M287763</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-20T07:52:46Z</dc:date>
    </item>
  </channel>
</rss>

