<?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>Question Re: is possible to use aggregate function in looping internal table? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136762#M4535895</link>
    <description>&lt;P&gt;The message says "&lt;STRONG&gt;Aggregate functions, host variables, or other expressions in the select list without alias names do not have a corresponding field.&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;Isn't it clear? Give a name to the aggregate functions, so that INTO CORRESPONDING finds a corresponding field for MAX, for instance if the target fields are named max_fkdat and max_erzet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;max( j~fkdat ) AS max_fkdat, max( j~erzet ) AS max_erzet&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Apr 2020 07:53:30 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2020-04-02T07:53:30Z</dc:date>
    <item>
      <title>is possible to use aggregate function in looping internal table?</title>
      <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaq-p/12136758</link>
      <description>&lt;P&gt;actually i want to get max date (j~fkdat) and max time.(j~ezret)&lt;/P&gt;
  &lt;P&gt;this my code.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT  a~vbeln, a~posnr, a~posex, a~matnr, a~arktx, a~kwmeng, a~vrkme,
        b~audat, b~auart, b~bstnk, b~waerk, b~vbtyp, b~vkorg,
        d~name1, d~stras, d~ort01, d~land1,
        e~vbeln AS vbeln_od, e~posnr AS posnr_od, e~lfimg, e~vrkme AS vrkme_od,
        f~bldat, f~lfart, f~wadat_ist, f~wadat,
        g~wbstk,
        h~fksta,
        i~vbeln AS vbeln_bil, i~posnr AS posnr_bil, i~fkimg AS fkimg_bil, i~vrkme AS vrkme_bil, i~netwr AS netwr_bil,
        j~fkart,j~fkdat ,j~erzet
        FROM vbap AS a
        JOIN vbak AS b ON a~vbeln = b~vbeln
        JOIN vbpa AS c ON b~vbeln = c~vbeln
        JOIN kna1 AS d ON b~kunnr = d~kunnr
        LEFT JOIN  lips AS e ON a~vbeln = e~vgbel AND a~posnr = e~vgpos
        JOIN likp AS f ON e~vbeln = f~vbeln
        JOIN vbuk AS g ON f~vbeln = g~vbeln
        JOIN vbup AS h ON e~vbeln = h~vbeln AND e~posnr = h~posnr
        LEFT JOIN  vbrp AS i ON e~vbeln = i~vgbel AND e~posnr = i~vgpos
        JOIN vbrk AS j ON i~vbeln = j~vbeln
        INTO CORRESPONDING FIELDS OF TABLE @it_main
        WHERE a~pstyv NE 'ZRET' AND a~pstyv NE 'ZSER' AND a~pstyv NE 'ZSEV' AND a~pstyv NE 'TAD' AND a~pstyv NE 'ZTAD'
             AND b~vkorg IN @p_vkorg
             AND c~kunnr IN @p_kunnr1
             AND c~parvw EQ 'VE'
             AND d~kunnr IN @p_kunnr2.


  LOOP AT it_main INTO wa_main GROUP BY wa_main-vbeln.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 04:58:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaq-p/12136758</guid>
      <dc:creator>former_member635273</dc:creator>
      <dc:date>2020-04-02T04:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: is possible to use aggregate function in looping internal table?</title>
      <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136759#M4535892</link>
      <description>&lt;P&gt;Dear Saddam&lt;/P&gt;&lt;P&gt;You have big columns in your it_main table, &lt;/P&gt;&lt;P&gt;You are trying to group by vbeln only &lt;/P&gt;&lt;P&gt;What is your requirement?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 05:05:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136759#M4535892</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2020-04-02T05:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: is possible to use aggregate function in looping internal table?</title>
      <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136760#M4535893</link>
      <description>I want to display data that has the latest date and time.i hv tried query like this.&lt;PRE&gt;&lt;CODE&gt;SELECT  a~vbeln, a~posnr, a~posex, a~matnr, a~arktx, a~kwmeng, a~vrkme,
        b~audat, b~auart, b~bstnk, b~waerk, b~vbtyp, b~vkorg,
        d~name1, d~stras, d~ort01, d~land1,
        e~vbeln AS vbeln_od, e~posnr AS posnr_od, e~lfimg, e~vrkme AS vrkme_od,
        f~bldat, f~lfart, f~wadat_ist, f~wadat,
        g~wbstk,
        h~fksta,
        i~vbeln AS vbeln_bil, i~posnr AS posnr_bil, i~fkimg AS fkimg_bil, i~vrkme AS vrkme_bil, i~netwr AS netwr_bil,
        j~fkart,max( j~fkdat ) ,max( j~erzet )
        FROM vbap AS a
        JOIN vbak AS b ON a~vbeln = b~vbeln
        JOIN vbpa AS c ON b~vbeln = c~vbeln
        JOIN kna1 AS d ON b~kunnr = d~kunnr
        LEFT JOIN  lips AS e ON a~vbeln = e~vgbel AND a~posnr = e~vgpos
        JOIN likp AS f ON e~vbeln = f~vbeln
        JOIN vbuk AS g ON f~vbeln = g~vbeln
        JOIN vbup AS h ON e~vbeln = h~vbeln AND e~posnr = h~posnr
        LEFT JOIN  vbrp AS i ON e~vbeln = i~vgbel AND e~posnr = i~vgpos
        JOIN vbrk AS j ON i~vbeln = j~vbeln
        INTO CORRESPONDING FIELDS OF TABLE @it_main
        WHERE a~pstyv NE 'ZRET' AND a~pstyv NE 'ZSER' AND a~pstyv NE 'ZSEV' AND a~pstyv NE 'TAD' AND a~pstyv NE 'ZTAD'
             AND b~vkorg IN @p_vkorg
             AND c~kunnr IN @p_kunnr1
             AND c~parvw EQ 'VE'
             AND d~kunnr IN @p_kunnr2
      GROUP BY  a~vbeln, a~posnr, a~posex, a~matnr, a~arktx, a~kwmeng, a~vrkme,
        b~audat, b~auart, b~bstnk, b~waerk, b~vbtyp, b~vkorg,
        d~name1, d~stras, d~ort01, d~land1,
        e~vbeln , e~posnr, e~lfimg, e~vrkme ,
        f~bldat, f~lfart, f~wadat_ist, f~wadat,
        g~wbstk,
        h~fksta,
        i~vbeln , i~posnr , i~fkimg , i~vrkme , i~netwr ,
        j~fkart.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but i get error like this.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1793795-screenshot-36.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 06:12:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136760#M4535893</guid>
      <dc:creator>former_member635273</dc:creator>
      <dc:date>2020-04-02T06:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: is possible to use aggregate function in looping internal table?</title>
      <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136761#M4535894</link>
      <description>&lt;P&gt;Hi Saddam&lt;/P&gt;&lt;P&gt;In your select statement &lt;STRONG&gt;j~fkart,max( j~fkdat ) ,max( j~erzet&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;you are using into corresponding fields of table  @it_main &lt;/P&gt;&lt;P&gt;Please verify - &lt;/P&gt;&lt;P&gt;1. what is the corresponding field/colum you defined in that it_main table to hold this ?&lt;/P&gt;&lt;P&gt;2. Use that names here in the select statement as "xxxx"&lt;/P&gt;&lt;P&gt;Example: if you use d1, d2 for that fields, then use  &lt;/P&gt;&lt;P&gt;j~fkart,max( j~fkdat ) as d1 ,max( j~erzet ) as d2&lt;/P&gt;&lt;P&gt;Update me if it works, &lt;/P&gt;&lt;P&gt;else we can go with other option&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 06:59:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136761#M4535894</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2020-04-02T06:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: is possible to use aggregate function in looping internal table?</title>
      <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136762#M4535895</link>
      <description>&lt;P&gt;The message says "&lt;STRONG&gt;Aggregate functions, host variables, or other expressions in the select list without alias names do not have a corresponding field.&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;Isn't it clear? Give a name to the aggregate functions, so that INTO CORRESPONDING finds a corresponding field for MAX, for instance if the target fields are named max_fkdat and max_erzet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;max( j~fkdat ) AS max_fkdat, max( j~erzet ) AS max_erzet&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 07:53:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136762#M4535895</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-04-02T07:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: is possible to use aggregate function in looping internal table?</title>
      <link>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136763#M4535896</link>
      <description>&lt;P&gt;ok thnks sir. it's work&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 07:59:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/is-possible-to-use-aggregate-function-in-looping-internal-table/qaa-p/12136763#M4535896</guid>
      <dc:creator>former_member635273</dc:creator>
      <dc:date>2020-04-02T07:59:26Z</dc:date>
    </item>
  </channel>
</rss>

