<?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: Retrieve value in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468785#M2000799</link>
    <description>&lt;P&gt;Hi Adrian,
&lt;BR /&gt;&lt;BR /&gt;Take a look at the documentation for the openSQL &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abapgroupby_clause.htm" target="_blank"&gt;GROUP BY&lt;/A&gt; clause.&lt;BR /&gt;&lt;BR /&gt;Adjust your original database query if possible to avoid selecting unnecessary data.&lt;BR /&gt;Alternatively, if your system supports it (&amp;gt;7.40), you can &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abapselect_itab.htm" target="_blank"&gt;select from your internal table&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; SELECT
   FROM @original_itab AS material
   FIELDS material~matnr,
          MAX( material~concat ) AS max_concat_for_material
   GROUP BY material~matnr
   INTO TABLE @DATA(materials_with_max_concat).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;
Finally, another option is sorting your itab, &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abaploop_at_itab_group_by.htm" target="_blank"&gt;loop&lt;/A&gt; over it, and extract the maximum value per material number. &lt;/P&gt;</description>
    <pubDate>Tue, 20 Jul 2021 13:37:14 GMT</pubDate>
    <dc:creator>LaurensDeprost</dc:creator>
    <dc:date>2021-07-20T13:37:14Z</dc:date>
    <item>
      <title>Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468780#M2000794</link>
      <description>&lt;P&gt;Im having a little trouble building the logic.&lt;/P&gt;
  &lt;P&gt;I need to retrieve the highest concat column value per material &lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 11:43:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468780#M2000794</guid>
      <dc:creator>former_member748613</dc:creator>
      <dc:date>2021-07-20T11:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468781#M2000795</link>
      <description>&lt;P&gt;Hi Adrian,&lt;/P&gt;&lt;P&gt;How exactly are you having trouble/what have you tried to achieve the desired result?&lt;BR /&gt;Have you tried searching the Q&amp;amp;A section for similar questions?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 12:49:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468781#M2000795</guid>
      <dc:creator>LaurensDeprost</dc:creator>
      <dc:date>2021-07-20T12:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468782#M2000796</link>
      <description>&lt;P&gt;Yes, I already searched for some Q&amp;amp;A sections, I only saw on how to get the highest value on the column. But what I need is to get the highest value in concat column per material&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 12:56:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468782#M2000796</guid>
      <dc:creator>former_member748613</dc:creator>
      <dc:date>2021-07-20T12:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468783#M2000797</link>
      <description>&lt;P&gt;Hello &lt;SPAN class="mention-scrubbed"&gt;kuser0320&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Just sort the table by CONCAT column descending and read the first row - see SAP Help &lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsort_itab.htm" target="_blank"&gt;SORT itab&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Best regard&lt;/P&gt;&lt;P&gt;Dominik Tylczynski&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 13:33:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468783#M2000797</guid>
      <dc:creator>Dominik_Tylczynski</dc:creator>
      <dc:date>2021-07-20T13:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468784#M2000798</link>
      <description>&lt;P&gt;If you just need to order the data:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when selecting the data: ORDER BY&lt;/LI&gt;&lt;LI&gt;after selection: SORT BY&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If you need a new table with just the highest values:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when selecting the data: MAX( )&lt;/LI&gt;&lt;LI&gt;after selection: LOOP + INSERT (not sure if there are new syntax for these things, I'm sure they will be)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;But if you have problem with this "logic", you need to go back to the basics of programming, I fear. No offense.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 13:36:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468784#M2000798</guid>
      <dc:creator>VXLozano</dc:creator>
      <dc:date>2021-07-20T13:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468785#M2000799</link>
      <description>&lt;P&gt;Hi Adrian,
&lt;BR /&gt;&lt;BR /&gt;Take a look at the documentation for the openSQL &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abapgroupby_clause.htm" target="_blank"&gt;GROUP BY&lt;/A&gt; clause.&lt;BR /&gt;&lt;BR /&gt;Adjust your original database query if possible to avoid selecting unnecessary data.&lt;BR /&gt;Alternatively, if your system supports it (&amp;gt;7.40), you can &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abapselect_itab.htm" target="_blank"&gt;select from your internal table&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; SELECT
   FROM @original_itab AS material
   FIELDS material~matnr,
          MAX( material~concat ) AS max_concat_for_material
   GROUP BY material~matnr
   INTO TABLE @DATA(materials_with_max_concat).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;
Finally, another option is sorting your itab, &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abaploop_at_itab_group_by.htm" target="_blank"&gt;loop&lt;/A&gt; over it, and extract the maximum value per material number. &lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 13:37:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468785#M2000799</guid>
      <dc:creator>LaurensDeprost</dc:creator>
      <dc:date>2021-07-20T13:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468786#M2000800</link>
      <description>&lt;P&gt;Hello Dominik, I can't just sort concat column. Your solution will just give me the highest value in concat column. But what I need is the highest value for every matnr column &lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 13:38:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468786#M2000800</guid>
      <dc:creator>former_member748613</dc:creator>
      <dc:date>2021-07-20T13:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468787#M2000801</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;Please refer to below piece of code:&lt;/P&gt;&lt;P&gt;Output is : &lt;/P&gt;&lt;P&gt; 2562 20251 &lt;/P&gt;&lt;P&gt;2562 20221&lt;/P&gt;&lt;P&gt;2705 20211 &lt;/P&gt;&lt;P&gt;2705 20201&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types: begin of ty_mara,
        matnr type matnr,
        concat(15) type c,
      end of ty_mara.
types: ty_t_mara type standard table of ty_mara.
data: ls_mara type ty_mara.
data : lt_mara type standard table of ty_mara.
ls_mara-matnr = '000000000000002705'.
ls_mara-concat = '20201'.
append ls_mara to lt_mara.
ls_mara-matnr = '000000000000002705'.
ls_mara-concat = '20211'.
append ls_mara to lt_mara.
ls_mara-matnr = '000000000000002562'.
ls_mara-concat = '20251'.
append ls_mara to lt_mara.
ls_mara-matnr = '000000000000002562'.
ls_mara-concat = '20221'.
append ls_mara to lt_mara.
sort lt_mara by matnr  concat descending.
clear ls_mara.
loop at lt_mara assigning field-symbol(&amp;lt;lfs_mara&amp;gt;).
    write :/ &amp;lt;lfs_mara&amp;gt;-matnr .
    write : &amp;lt;lfs_mara&amp;gt;-concat.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Jul 2021 13:39:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468787#M2000801</guid>
      <dc:creator>former_member598787</dc:creator>
      <dc:date>2021-07-20T13:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468788#M2000802</link>
      <description>&lt;SPAN class="mention-scrubbed"&gt;kuser0320&lt;/SPAN&gt;&lt;P&gt;You are right. I somehow missed that part. Still the other answer give good solutions.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 13:43:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retrieve-value/m-p/12468788#M2000802</guid>
      <dc:creator>Dominik_Tylczynski</dc:creator>
      <dc:date>2021-07-20T13:43:41Z</dc:date>
    </item>
  </channel>
</rss>

