<?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: how to use count inside the loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159788#M1195211</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;PRE&gt;&lt;CODE&gt;
sort it_final by lifnr matnr.
loop at it_final.
  at new matnr.
    l_flg = 'X'.
  endat.
  if l_flg ne 'X'.
    delete it_final.
*or...
    clear it_final-matnr.
    modify it_final.
  else.
    clear l_flg.
  endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Edgar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Feb 2009 10:16:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-26T10:16:41Z</dc:date>
    <item>
      <title>how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159782#M1195205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lifnr-matnr-menge-idnrk-excess&lt;/P&gt;&lt;P&gt;r11-subfert-100-subscrap-25&lt;/P&gt;&lt;P&gt;r11-subfert-100-scrap-20&lt;/P&gt;&lt;P&gt;r11-neera1-125-scrap2-15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(please dont tell delete adjacent duplicates).In my case that is not needed.Because I need this in final stage.output i have shown is partial one.&lt;/P&gt;&lt;P&gt;i need to clear second row 100.because matnr is same.instead of 100 i need to insert zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am declaring variable in my IT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example v_matnr type mseg-matnr.&lt;/P&gt;&lt;P&gt;count type i value 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_final.&lt;/P&gt;&lt;P&gt;  if sy-index = 1.&lt;/P&gt;&lt;P&gt;    v_matnr = it_final-matnr.&lt;/P&gt;&lt;P&gt;   move it_final-menge to it_final-menge.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;i am getting logic.i couldnt able to do.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 09:54:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159782#M1195205</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T09:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159783#M1195206</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;1. &lt;/P&gt;&lt;P&gt;data: count type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_final.&lt;/P&gt;&lt;P&gt;add 1 to count.&lt;/P&gt;&lt;P&gt;if sy-index = 1.&lt;/P&gt;&lt;P&gt;v_matnr = it_final-matnr.&lt;/P&gt;&lt;P&gt;move it_final-menge to it_final-menge.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if count eq 100.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;clear count.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or 2. Define an new field in your internal table from type i and worte it if you fill the internal table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 09:57:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159783#M1195206</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T09:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159784#M1195207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can move data to another internal table  like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it_final2[] = it_final[]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and delete dupilicates from it_final. and finally you can use it_final2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 09:57:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159784#M1195207</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T09:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159785#M1195208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take two variables for lifnr and matnr. Inside the loop pass the first record Lifnr and matnr to those variables. for the second record in the loop check the itab values with the variable values for both lfinr and matnr, if both are same then make the menge zero.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 09:58:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159785#M1195208</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T09:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159786#M1195209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;please give me sample code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:04:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159786#M1195209</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159787#M1195210</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;in your internal table have an extra field called &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mark type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab by lifnr matnr.&lt;/P&gt;&lt;P&gt;field-symbols : &amp;lt;fS_itab&amp;gt; like itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab assigning &amp;lt;fs_tab&amp;gt;.&lt;/P&gt;&lt;P&gt; at new matnr.&lt;/P&gt;&lt;P&gt;   &amp;lt;fs_tab&amp;gt;-mark = 'X'. &lt;/P&gt;&lt;P&gt; endat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the the records where mark is 'X' will tell u the unique material number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now &lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;if itab-mark ne 'X'.&lt;/P&gt;&lt;P&gt; you can make the material number as zeros or what ever you want you cando .&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please come back to us for more queries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkatesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:10:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159787#M1195210</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159788#M1195211</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;PRE&gt;&lt;CODE&gt;
sort it_final by lifnr matnr.
loop at it_final.
  at new matnr.
    l_flg = 'X'.
  endat.
  if l_flg ne 'X'.
    delete it_final.
*or...
    clear it_final-matnr.
    modify it_final.
  else.
    clear l_flg.
  endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Edgar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:16:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159788#M1195211</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159789#M1195212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Bathrinath,&lt;/P&gt;&lt;P&gt;                        do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_final1[] = t_final[].&lt;/P&gt;&lt;P&gt;data: count type i,&lt;/P&gt;&lt;P&gt;       count1 type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count = 1.&lt;/P&gt;&lt;P&gt;loop at t_final into w_final.&lt;/P&gt;&lt;P&gt;count1 = count + sy-tabix. &lt;/P&gt;&lt;P&gt;read table t_final1 into w_final1 index count1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if w_final-lifnr = w_final1-lifnr and&lt;/P&gt;&lt;P&gt; w_final-matnr = w_final1-matnr and&lt;/P&gt;&lt;P&gt;w_final-menge = w_final1-menge.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;w_final-menge = 0.&lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;modify t_final from w_final.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear: count1,w_final,w_final1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope your problem will be solved.&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:17:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159789#M1195212</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159790#M1195213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you my dear friend.&lt;/P&gt;&lt;P&gt;I am so kind of you.&lt;/P&gt;&lt;P&gt;its working well.&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:20:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159790#M1195213</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159791#M1195214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for all who have given replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:21:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159791#M1195214</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159792#M1195215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     Try below logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : it_final TYPE TABLE OF ty_final,
                wa_final TYPE ty_final,
                wa_final1 TYPE ty_final,
                w_indx TYPE i,
                w_tybix TYPE i.

    w_indx = 1.
    LOOP AT it_final INTO wa_final.
    w_indx = w_indx + 1.
    w_tabix = sy-tabix.
    IF wa_final-matnr = wa_final1-matnr.
    wa_final-menge = '0'.
    MODIFY it_final INDEX w_tabix FROM wa_final TRANSPORTING menge.
    ENDIF.
    CLEAR wa_final1.
    READ TABLE it_final INDEX w_indx INTO wa_final1.        " Reads next record of the table.
    ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bala Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:21:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159792#M1195215</guid>
      <dc:creator>former_member585060</dc:creator>
      <dc:date>2009-02-26T10:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159793#M1195216</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;Please close the thread if you got the proper results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkatesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 10:23:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159793#M1195216</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T10:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to use count inside the loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159794#M1195217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thread closed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2009 12:13:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-count-inside-the-loop/m-p/5159794#M1195217</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-26T12:13:05Z</dc:date>
    </item>
  </channel>
</rss>

