<?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: loop at itab in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388452#M188957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before doing this append another itab same structure has imard or is033 based on data mzubb magbb.. apend the itab.&lt;/P&gt;&lt;P&gt;sort the itab.based on sptag,,,and mzubb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT imard ASSIGNING &amp;lt;ls_mard&amp;gt;.&lt;/P&gt;&lt;P&gt;LOOP AT is033 ASSIGNING &amp;lt;ls_s033&amp;gt;&lt;/P&gt;&lt;P&gt;where matnr = &amp;lt;ls_mard&amp;gt;-matnr&lt;/P&gt;&lt;P&gt;and lgort = &amp;lt;ls_mard&amp;gt;-lgort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Jul 2006 12:12:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-07-09T12:12:18Z</dc:date>
    <item>
      <title>loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388450#M188955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LOOP  AT imard ASSIGNING &amp;lt;ls_mard&amp;gt;.&lt;/P&gt;&lt;P&gt;  LOOP AT is033 ASSIGNING &amp;lt;ls_s033&amp;gt;&lt;/P&gt;&lt;P&gt;          where matnr = &amp;lt;ls_mard&amp;gt;-matnr&lt;/P&gt;&lt;P&gt;          and   lgort = &amp;lt;ls_mard&amp;gt;-lgort.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;here i get 4 rows and i want to take the highest date(sptag)  mzubb&lt;/P&gt;&lt;P&gt;         magbb for each matnr&amp;lt;/b&amp;gt;and calc the menge. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         &lt;/P&gt;&lt;P&gt;          &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 11:51:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388450#M188955</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T11:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388451#M188956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab by date in ascending order, read the first record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vasavi.k&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:10:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388451#M188956</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T12:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388452#M188957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before doing this append another itab same structure has imard or is033 based on data mzubb magbb.. apend the itab.&lt;/P&gt;&lt;P&gt;sort the itab.based on sptag,,,and mzubb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT imard ASSIGNING &amp;lt;ls_mard&amp;gt;.&lt;/P&gt;&lt;P&gt;LOOP AT is033 ASSIGNING &amp;lt;ls_s033&amp;gt;&lt;/P&gt;&lt;P&gt;where matnr = &amp;lt;ls_mard&amp;gt;-matnr&lt;/P&gt;&lt;P&gt;and lgort = &amp;lt;ls_mard&amp;gt;-lgort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:12:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388452#M188957</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T12:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388453#M188958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please sort internal table IS033 with MATNR and LGORT (ASCENDING) and SPTAG, MZUBB and MAGBB (DESCENDING) prior to looping statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you use control break processing to get the highest date for SPTAG MZUBB and MAGBB when looping IS033.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AT NEW SPTAG.&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will give you an idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:14:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388453#M188958</guid>
      <dc:creator>ferry_lianto</dc:creator>
      <dc:date>2006-07-09T12:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388454#M188959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is your requirement somenthing like this.&lt;/P&gt;&lt;P&gt;Consider this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT zzarun_1.
DATA :imard TYPE STANDARD TABLE OF mard WITH HEADER LINE,
      is033 TYPE STANDARD TABLE OF s033 WITH HEADER LINE.

FIELD-SYMBOLS : &amp;lt;ls_mard&amp;gt; TYPE mard,
                &amp;lt;ls_s033&amp;gt; TYPE s033.

&amp;lt;b&amp;gt;*Declare two Internal Tables&amp;lt;/b&amp;gt;
DATA : itemp  LIKE is033 OCCURS 0,  "Holding four records
       ifinal LIKE is033 OCCURS 0.  "Holding final data

LOOP AT imard ASSIGNING &amp;lt;ls_mard&amp;gt;.
  LOOP AT is033 ASSIGNING &amp;lt;ls_s033&amp;gt; WHERE matnr = &amp;lt;ls_mard&amp;gt;-matnr
                                      AND lgort = &amp;lt;ls_mard&amp;gt;-lgort.


    APPEND &amp;lt;ls_s033&amp;gt; TO itemp.

  ENDLOOP.


*Take the row with highest date (sptag)
  SORT itemp BY sptag .
  READ TABLE itemp ASSIGNING &amp;lt;ls_s033&amp;gt; INDEX 1.
  APPEND &amp;lt;ls_s033&amp;gt; TO ifinal.

*Take the row with highest mzubb
  SORT itemp BY mzubb.
  READ TABLE itemp ASSIGNING &amp;lt;ls_s033&amp;gt; INDEX 1.
  APPEND &amp;lt;ls_s033&amp;gt; TO ifinal.

*Take the row with highest magbb
  SORT itemp BY magbb.
  READ TABLE itemp ASSIGNING &amp;lt;ls_s033&amp;gt; INDEX 1.
  APPEND &amp;lt;ls_s033&amp;gt; TO ifinal.

  "In internal table IFINAL you have the required data
  "Do your processing(Calculation)  here.


&amp;lt;b&amp;gt;*After processing dont forget to refresh the Internal tables&amp;lt;/b&amp;gt;

  CLEAR   : itemp, ifinal.
  REFRESH : itemp, ifinal.

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;Arun Sambargi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:24:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388454#M188959</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T12:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388455#M188960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can also try in this way, ( might possible )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sort is033 by sptag.
LOOP AT imard ASSIGNING &amp;lt;ls_mard&amp;gt;.
read table is033 with key marnt = matnr = &amp;lt;ls_mard&amp;gt;-matnr
and lgort = &amp;lt;ls_mard&amp;gt;-lgort.
if sy-subrc = 0.
you will get the first record which should be highest date.
endif.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regds&lt;/P&gt;&lt;P&gt;Manohar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:26:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388455#M188960</guid>
      <dc:creator>Manohar2u</dc:creator>
      <dc:date>2006-07-09T12:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388456#M188961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;arun nice answer thsnks.&lt;/P&gt;&lt;P&gt;i need to update is033-zlbkum every line that i have in is033.&lt;/P&gt;&lt;P&gt;the calc is&lt;/P&gt;&lt;P&gt;zlbkum = end_qty - magbb.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:33:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388456#M188961</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T12:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388457#M188962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

REPORT zzarun_1.
DATA :imard TYPE STANDARD TABLE OF mard WITH HEADER LINE,
      is033 TYPE STANDARD TABLE OF s033 WITH HEADER LINE.

FIELD-SYMBOLS : &amp;lt;ls_mard&amp;gt; TYPE mard,
                &amp;lt;ls_s033&amp;gt; TYPE s033.

*Declare two Internal Tables
DATA : itemp  LIKE is033 OCCURS 0,  "Holding four records
       ifinal LIKE is033 OCCURS 0.  "Holding final data

LOOP AT imard ASSIGNING &amp;lt;ls_mard&amp;gt;.
  LOOP AT is033 ASSIGNING &amp;lt;ls_s033&amp;gt; WHERE matnr = &amp;lt;ls_mard&amp;gt;-matnr
                                      AND lgort = &amp;lt;ls_mard&amp;gt;-lgort.

*Substract here befor appending

    &amp;lt;b&amp;gt;&amp;lt;ls_s033&amp;gt;-zlbkum =  &amp;lt;ls_s033&amp;gt;-end_qty - &amp;lt;ls_s033&amp;gt;-magbb.&amp;lt;/b&amp;gt;

    APPEND &amp;lt;ls_s033&amp;gt; TO itemp.

  ENDLOOP.


*Take the row with highest date (sptag)
  SORT itemp BY sptag .
  READ TABLE itemp ASSIGNING &amp;lt;ls_s033&amp;gt; INDEX 1.
  APPEND &amp;lt;ls_s033&amp;gt; TO ifinal.

*Take the row with highest mzubb
  SORT itemp BY mzubb.
  READ TABLE itemp ASSIGNING &amp;lt;ls_s033&amp;gt; INDEX 1.
  APPEND &amp;lt;ls_s033&amp;gt; TO ifinal.

*Take the row with highest magbb
  SORT itemp BY magbb.
  READ TABLE itemp ASSIGNING &amp;lt;ls_s033&amp;gt; INDEX 1.
  APPEND &amp;lt;ls_s033&amp;gt; TO ifinal.

  "In internal table IFINAL you have the required data
  "Do your processing(Calculation)  here.


*After processing dont forget to refresh the Internal tables

  CLEAR   : itemp, ifinal.
  REFRESH : itemp, ifinal.

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;Arun S.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 12:57:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388457#M188962</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T12:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: loop at itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388458#M188963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know the &amp;lt;b&amp;gt;loop at where&amp;lt;/b&amp;gt; statement has been improved quite a bit but for runtime considerations I would still suggest that you use a sorted table and use &amp;lt;b&amp;gt;read table with key&amp;lt;/b&amp;gt; -- instead of the inner loop at itab where&lt;/P&gt;&lt;P&gt;(see one of the previous posts).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This might have very little impact if the table has just a few rows but can be quite different if each table has around 300,000 rows...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enjoy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jul 2006 13:16:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-itab/m-p/1388458#M188963</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-09T13:16:09Z</dc:date>
    </item>
  </channel>
</rss>

