<?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: Item Level Total in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763890#M1462089</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data : m_vbeln type vbeln value ' '
data : m_posnr type posnr value ' ',
data : m_menge type vbap-menge value 0.

TYPES : BEGIN OF wa1_zmmt0006 ,
vbeln TYPE zmmt0006-vbeln,
posnr TYPE zmmt0006-posnr , 
zdmenge TYPE zmmt0006-menge ,
END OF wa1_zmmt0006 .

DATA : wa2_zmmt0006 TYPE wa1_zmmt0006 ,
wa_zmmt0006 TYPE wa1_zmmt0006 ,
it2_zmmt0006 TYPE wa1_zmmt0006 ,
it_zmmt0006 TYPE wa1_zmmt0006 .

SELECT vbeln posnr menge 
FROM zmmt0006
INTO TABLE it2_zmmt0006
FOR ALL ENTRIES IN it_c_t_data
WHERE vbeln = it_c_t_data-vbeln
AND posnr = it_c_t_data-posnr
AND status = u2018 u2018 .

LOOP AT it2_zmmt0006 INTO wa2_zmmt0006 .
if m_vbeln ne wa2_zmmt0006-vbeln or m_posnr ne wa2_zmmt0006-posnr.
 write :/  m_vbeln, m_posnr, m_menge.
 move 0 to m_menge.
endif.
move wa2_zmmt0006-vbeln to m_vbeln.
move wa2_zmmt0006-posnr to m_posnr.
m_menge = m_menge + wa2_zmmt0006-zdmenge.
Endloop .
write :/  m_vbeln, m_posnr, m_menge.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vinod&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Apr 2010 04:41:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-04-15T04:41:52Z</dc:date>
    <item>
      <title>Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763884#M1462083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;want the summation at the item level with out using the AT end of controls statements inside my internal table.&lt;/P&gt;&lt;P&gt;I have writen code for the same below. Could any one give inputs to modify my code to get the summation for each item of an SO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:-&lt;/P&gt;&lt;P&gt;(VBELN)      (POSNR)                  ZDMENGE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;100                                        10                                                  100&lt;/P&gt;&lt;P&gt;100                                        10                                                   400 &lt;/P&gt;&lt;P&gt;100                                        20                                                   600&lt;/P&gt;&lt;P&gt;100                                        30                                                   50&lt;/P&gt;&lt;P&gt;100                                        30                                                  150 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200                                       10                                                   400&lt;/P&gt;&lt;P&gt;200                                       20                                                   300&lt;/P&gt;&lt;P&gt;200                                       20                                                   200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result must be as below(summation per item):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBELN      POSNR     ZDMENGE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;100        10              500                                            &lt;/P&gt;&lt;P&gt;100        20              600&lt;/P&gt;&lt;P&gt;100        30              200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200       10               400&lt;/P&gt;&lt;P&gt;200       20               500&lt;/P&gt;&lt;P&gt;My current code:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF wa1_zmmt0006 ,&lt;/P&gt;&lt;P&gt;               vbeln TYPE zmmt0006-vbeln,&lt;/P&gt;&lt;P&gt;                posnr TYPE zmmt0006-posnr , &lt;/P&gt;&lt;P&gt;                zdmenge TYPE zmmt0006-menge ,&lt;/P&gt;&lt;P&gt;               END OF wa1_zmmt0006 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : wa2_zmmt0006 TYPE wa1_zmmt0006 ,&lt;/P&gt;&lt;P&gt;             wa_zmmt0006 TYPE wa1_zmmt0006 ,&lt;/P&gt;&lt;P&gt;              it2_zmmt0006 TYPE wa1_zmmt0006 ,&lt;/P&gt;&lt;P&gt;              it_zmmt0006 TYPE wa1_zmmt0006 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln posnr menge  &lt;/P&gt;&lt;P&gt;FROM zmmt0006&lt;/P&gt;&lt;P&gt;INTO TABLE it2_zmmt0006&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN it_c_t_data&lt;/P&gt;&lt;P&gt;WHERE vbeln = it_c_t_data-vbeln&lt;/P&gt;&lt;P&gt;AND posnr = it_c_t_data-posnr&lt;/P&gt;&lt;P&gt;AND status = u2018 u2018 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it2_zmmt0006  INTO wa2_ zmmt0006 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_zmmt0006-posnr = wa2_zmmt0006-posnr .&lt;/P&gt;&lt;P&gt;wa_zmmt0006-zdmenge = wa2_zmmt0006-zdmenge .&lt;/P&gt;&lt;P&gt;wa_zmmt0006-zstatus = wa2_zmmt0006-zstatus .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Collect wa_zmmt0006 into it_zmmt0006 .&lt;/P&gt;&lt;P&gt;Endloop .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_zvitr_item_im BY vbeln ASCENDING posnr ASCENDING menge DESCENDING .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sonam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sonamrata on Apr 14, 2010 4:33 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Apr 2010 14:20:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763884#M1462083</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-14T14:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763885#M1462084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sonam,&lt;/P&gt;&lt;P&gt;  why dont you use on change of ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:w_sum type i,
zmmt0006_1 like zmmt0006.
 LOOP AT it2_zmmt0006 INTO wa2_ zmmt0006 .
   on change of zmmt0006-vbeln.
      if sy-tabix ne 1.
        zmmt0006_1-zdmenge = w-sum.
        append zmmt0006_1 to it1_zmmt0006.
        clear w_sum.
      endif.
   endon.
   zmmt0006_1-vbeln =  wa2_zmmt0006-vbeln.
   zmmt0006_1-posnr =  wa2_zmmt0006-posnr.
   w_sum = w_sum + wa2_zmmt0006-zdmenge.
 endloop.
wa2_zmmt0006-zdmenge = w_sum.
append wa2_zmmt0006 to it1_zmmt0006.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because if there are any other fields rather than character type it is not desirable to use collect statement because it will also adds all other than character variables and as per performance issue append is prefered than COLLECT.&lt;/P&gt;&lt;P&gt;if you dont want to use on change of &lt;/P&gt;&lt;P&gt;replace this code,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table it2_zmmt0006index 1  INTO zmmt0006_1.
loop at it2_zmmt0006 INTO wa2_ zmmt0006 .
if  zmmt0006_1-ebeln = wa2_ zmmt0006-ebeln.
w_sum = w_sum + wa2_zmmt0006-zdmenge. 
else.
 zmmt0006_1-zdmenge = w_sum.
 append zmmt0006_1 to it1_zmmt0006.
clear w_sum.
endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think this is helpful for you.&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;Raghava Channooru.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Apr 2010 14:58:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763885#M1462084</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-14T14:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763886#M1462085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sonam,&lt;/P&gt;&lt;P&gt;Change The Following to table types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; 
it2_zmmt0006 TYPE wa1_zmmt0006 ,
it_zmmt0006 TYPE wa1_zmmt0006 .  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Apr 2010 15:05:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763886#M1462085</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-14T15:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763887#M1462086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ragav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can we do with out on change of command? could you modify with out using this.&lt;/P&gt;&lt;P&gt;I want the total of menge per item  , not per sales order. For one sales order there might be &lt;/P&gt;&lt;P&gt;multiple entries for item 10, or 20 or 30.... with menge.we have to sumup the menge for all this multiple 10 items or 20items ...,,,and display as salesorder1, tiem10  and  menge(total of menges for all 10 items of the salesorder1). salesorder 1 ,item20, menge(total of menges for all 20 items of the  salesorder1).for the next sales order2 the same way...salesorder2, tiem10  and  menge(total of menges for all 10 items of the salesorder2). salesorder 2 ,item20, menge(total of menges for all 20 items of the  salesorder2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope I am not confusing.any inputs are helpfull.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Selina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Apr 2010 20:54:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763887#M1462086</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-14T20:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763888#M1462087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also try using the SUM  and GROUP BY statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln posnr SUM ( menge  )&lt;/P&gt;&lt;P&gt;FROM zmmt0006&lt;/P&gt;&lt;P&gt;INTO TABLE it2_zmmt0006&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN it_c_t_data&lt;/P&gt;&lt;P&gt;WHERE vbeln = it_c_t_data-vbeln&lt;/P&gt;&lt;P&gt;AND posnr = it_c_t_data-posnr&lt;/P&gt;&lt;P&gt;AND status = u2018 u2018 &lt;/P&gt;&lt;P&gt;GROUP BY vbeln posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would give you totals by document and line number.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Apr 2010 21:24:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763888#M1462087</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-14T21:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763889#M1462088</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;Why you don't want to use SUM and ' AT End Of ' statements , any particular reasons ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have you used above statements to sum at line items without any major issues all my 'life', if you can explain the issue when using those , may be I can help you there...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;VB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Apr 2010 23:44:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763889#M1462088</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-14T23:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763890#M1462089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data : m_vbeln type vbeln value ' '
data : m_posnr type posnr value ' ',
data : m_menge type vbap-menge value 0.

TYPES : BEGIN OF wa1_zmmt0006 ,
vbeln TYPE zmmt0006-vbeln,
posnr TYPE zmmt0006-posnr , 
zdmenge TYPE zmmt0006-menge ,
END OF wa1_zmmt0006 .

DATA : wa2_zmmt0006 TYPE wa1_zmmt0006 ,
wa_zmmt0006 TYPE wa1_zmmt0006 ,
it2_zmmt0006 TYPE wa1_zmmt0006 ,
it_zmmt0006 TYPE wa1_zmmt0006 .

SELECT vbeln posnr menge 
FROM zmmt0006
INTO TABLE it2_zmmt0006
FOR ALL ENTRIES IN it_c_t_data
WHERE vbeln = it_c_t_data-vbeln
AND posnr = it_c_t_data-posnr
AND status = u2018 u2018 .

LOOP AT it2_zmmt0006 INTO wa2_zmmt0006 .
if m_vbeln ne wa2_zmmt0006-vbeln or m_posnr ne wa2_zmmt0006-posnr.
 write :/  m_vbeln, m_posnr, m_menge.
 move 0 to m_menge.
endif.
move wa2_zmmt0006-vbeln to m_vbeln.
move wa2_zmmt0006-posnr to m_posnr.
m_menge = m_menge + wa2_zmmt0006-zdmenge.
Endloop .
write :/  m_vbeln, m_posnr, m_menge.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vinod&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Apr 2010 04:41:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763890#M1462089</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-15T04:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763891#M1462090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi New comer ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried as per ur idea...I got the error as ...The addition "FOR ALL ENTRIES" excludes all aggregate functions with the exception of "COUNT( * )" as the single element of the SELECT clause. any information regarding this to fix?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln posnr SUM ( menge )&lt;/P&gt;&lt;P&gt;FROM zmmt0006&lt;/P&gt;&lt;P&gt;INTO TABLE it2_zmmt0006&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN it_c_t_data&lt;/P&gt;&lt;P&gt;WHERE vbeln = it_c_t_data-vbeln&lt;/P&gt;&lt;P&gt;AND posnr = it_c_t_data-posnr&lt;/P&gt;&lt;P&gt;AND status = u2018 u2018 &lt;/P&gt;&lt;P&gt;GROUP BY vbeln posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am also trying others logic replied here.&lt;/P&gt;&lt;P&gt;Thank you all for your quick replies.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Selina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Apr 2010 07:10:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763891#M1462090</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-15T07:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Item Level Total</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763892#M1462091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sonam,&lt;/P&gt;&lt;P&gt;Here you can try this aswell.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES: zmmt0006 .&lt;/P&gt;&lt;P&gt;DATA : it_c_t_data TYPE TABLE OF mc11va0itm .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF wa1_zmmt0006 ,&lt;/P&gt;&lt;P&gt;vbeln TYPE zmmt0006-vbeln,&lt;/P&gt;&lt;P&gt;posnr TYPE zmmt0006-posnr , &lt;/P&gt;&lt;P&gt;zdmenge TYPE zmmt0006-menge ,&lt;/P&gt;&lt;P&gt;END OF wa1_zmmt0006 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;wa_ zmmt0006&amp;gt; TYPE wa1_zmmt0006 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : it_zmmt0006 TYPE wa1_zmmt0006 ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : l_vbeln2 TYPE zmmt0006-vbeln ,&lt;/P&gt;&lt;P&gt;             l_posnr2 TYPE zmmt0006-posnr ,&lt;/P&gt;&lt;P&gt;            l_zdmenge TYPE zmmt0006-menge VALUE 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it_c_t_data[] = c_t_data[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT it_c_t_data[] IS INITIAL.&lt;/P&gt;&lt;P&gt;SORT it_c_t_data BY vbeln posnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln posnr menge &lt;/P&gt;&lt;P&gt;FROM zmmt0006&lt;/P&gt;&lt;P&gt;INTO TABLE it_zmmt0006&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN it_c_t_data&lt;/P&gt;&lt;P&gt;WHERE vbeln = it_c_t_data-vbeln&lt;/P&gt;&lt;P&gt;AND posnr = it_c_t_data-posnr&lt;/P&gt;&lt;P&gt;AND status = u2018 u2018 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;SORT it_zmmt0006 BY vbeln posnr.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_zmmt0006 ASSIGNING &amp;lt;wa_zmmt0006&amp;gt;.&lt;/P&gt;&lt;P&gt;IF l_vbeln2 NE &amp;lt;wa_zmmt0006&amp;gt;-vbeln OR l_posnr2 NE&lt;/P&gt;&lt;P&gt;&amp;lt;wa_zmmt0006&amp;gt;-posnr.&lt;/P&gt;&lt;P&gt;l_zdmenge = 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;l_vbeln2 = &amp;lt;wa_zmmt0006&amp;gt;-vbeln.&lt;/P&gt;&lt;P&gt;l_posnr2 = &amp;lt;wa_zmmt0006&amp;gt;-posnr.&lt;/P&gt;&lt;P&gt;l_zdmenge = l_zdmenge + &amp;lt;wa_zmmt0006&amp;gt;-zdmenge .&lt;/P&gt;&lt;P&gt;&amp;lt;wa_zmmt0006&amp;gt;-vbeln = l_vbeln2.&lt;/P&gt;&lt;P&gt;&amp;lt;wa_zmmt0006&amp;gt;-posnr = l_posnr2.&lt;/P&gt;&lt;P&gt;&amp;lt;wa_zmmt0006&amp;gt;-zdmenge = l_zdmenge.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_zmmt0006 BY vbeln ASCENDING posnr ASCENDING zdmenge&lt;/P&gt;&lt;P&gt;DESCENDING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM it_zmmt0006 COMPARING vbeln posnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_zmmt0006 ASSIGNING &amp;lt;wa_zmmt0006&amp;gt;.&lt;/P&gt;&lt;P&gt; WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;  &amp;lt;wa_zmmt0006&amp;gt;-vbeln  , &amp;lt;wa_zmmt0006&amp;gt;-posnr , &amp;lt;wa_zmmt0006&amp;gt;-zdmenge.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Selina&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Apr 2010 19:17:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/item-level-total/m-p/6763892#M1462091</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-04-19T19:17:19Z</dc:date>
    </item>
  </channel>
</rss>

