title: Identify last group in a LOOP AT ... GROUP BY?
body: <p>I'm looking for the equivalent of the AT LAST statement within the LOOP AT ... GROUP BY statement.</p>
  <p>I'm looping using group by, and for performance reasons, I execute a call method every few groups, when a certain amount of records has been accumulated into an internal table. But I would like to add an extra condition to run this call at the end of the loop, if I'm in the last group.</p>
  <p>Below I wrote a piece of executable code simulating my problem, I would like to process my last material before exiting the loop.</p>
  <pre><code>constants: processing_size_threshold type i value 10.
  types: begin of ty_material,
           material_num type c length 3,
         end of ty_material.
  data:  materials type standard table of ty_material,
         materials_bom type standard table of ty_material.
  
  materials = value #( for i = 1 then i + 1 while i &lt;= 3
                       ( material_num = conv #( i ) ) ).
  
  
  loop at materials reference into data(material_grp) group by material_grp-&gt;material_num.
  
      loop at group material_grp reference into data(material).
        materials_bom = value #( base materials_bom (
                                 lines of value #( for j = 1 then j + 1 while j &lt;= 5
                                                 ( material_num = |{ material-&gt;material_num }{ j }| ) ) ) ).
      endloop.
  
     &quot;The 2nd condition of this IF is what I'm not able to figure out, I need material 3 BOM to be processed here
      if lines( materials_bom ) &gt;= processing_size_threshold. &quot;or group_num = last_group.
        &quot;me-&gt;process_boms(materials_bom).
        clear materials_bom.
      endif.
  endloop.
  </code></pre>