<?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 problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811926#M916910</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   Don't write LOOP inside LOOP.Instead loop at one internal table and read the second with key fields.Also,sort the internal table with key field in ascending order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 May 2008 15:10:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-23T15:10:19Z</dc:date>
    <item>
      <title>loop problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811925#M916909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I written on report stock History by commidity, with tables ltap, lips,likp and lfm1 . in the selection screen i given material is sample1.for sample1 i have the 74 records . in the output iam getting only 47 records , iam not getting the problem , iam sending the code please see that and suggest me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at gt_ltap into gs_ltap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;gs_output-matnr = gs_ltap-matnr.&lt;/P&gt;&lt;P&gt;gs_output-maktx = gs_ltap-maktx.&lt;/P&gt;&lt;P&gt;gs_output-nista = gs_ltap-nista.&lt;/P&gt;&lt;P&gt;gs_output-tanum = gs_ltap-tanum.&lt;/P&gt;&lt;P&gt;gs_output-qdatu = gs_ltap-qdatu.&lt;/P&gt;&lt;P&gt;gs_output-vbeln = gs_ltap-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at gt_lips into gs_lips where vbeln = gs_ltap-vbeln and&lt;/P&gt;&lt;P&gt;posnr = gs_ltap-posnr.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;gs_output-vkgrp = gs_lips-vkgrp.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;sort gt_likp by vbeln ascending.&lt;/P&gt;&lt;P&gt;read table gt_likp into gs_likp with key vbeln = gs_lips-vbeln Binary search.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;gs_output-kunnr = gs_likp-kunnr.&lt;/P&gt;&lt;P&gt;gs_output-lifnr = gs_likp-lifnr.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;sort gt_lfm1 by lifnr ascending.&lt;/P&gt;&lt;P&gt;read table gt_lfm1 into gs_lfm1 with key lifnr = gs_likp-lifnr Binary search.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;gs_output-ekgrp = gs_lfm1-ekgrp.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;append gs_output to gt_output.&lt;/P&gt;&lt;P&gt;clear gs_output.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for above loop in gt_ltap iam having 74 records , for gt_output iam having 47 only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;N.Narasimha rao.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on May 23, 2008 6:52 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 15:06:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811925#M916909</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T15:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: loop problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811926#M916910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   Don't write LOOP inside LOOP.Instead loop at one internal table and read the second with key fields.Also,sort the internal table with key field in ascending order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 15:10:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811926#M916910</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T15:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: loop problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811927#M916911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The most logic thing I can deduct is that gt_ltap has 74 records but only 47 in gt_lips have the same vbeln and posnr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 15:14:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811927#M916911</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T15:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: loop problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811928#M916912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The append statement is in the loop gt_lips.  So it will append only common records ( ie gs_ltap-vbeln = gs_lips-vbeln) to the output table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u pick it out it will append all the records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suggestions:   U r sorting tables in a loop. So the performance of the program will be down since u r sorting the internal tables in each loop pass, that measn  there are 74 records and the tables will be sorted 74 times.  Which is not required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before going into the loop only u sort all the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And there is no need to check for sy-subrc next to the loop statement.  When there is a record then only processor will go inside the loop.  U can remove that also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Venkat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on May 23, 2008 6:52 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 15:23:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811928#M916912</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T15:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: loop problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811929#M916913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at gt_ltap into gs_ltap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gs_output-matnr = gs_ltap-matnr.&lt;/P&gt;&lt;P&gt;gs_output-maktx = gs_ltap-maktx.&lt;/P&gt;&lt;P&gt;gs_output-nista = gs_ltap-nista.&lt;/P&gt;&lt;P&gt;gs_output-tanum = gs_ltap-tanum.&lt;/P&gt;&lt;P&gt;gs_output-qdatu = gs_ltap-qdatu.&lt;/P&gt;&lt;P&gt;gs_output-vbeln = gs_ltap-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at gt_lips into gs_lips where vbeln = gs_ltap-vbeln and&lt;/P&gt;&lt;P&gt;posnr = gs_ltap-posnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gs_output-vkgrp = gs_lips-vkgrp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort gt_likp by vbeln ascending.&lt;/P&gt;&lt;P&gt;read table gt_likp into gs_likp with key vbeln = gs_lips-vbeln Binary search.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;gs_output-kunnr = gs_likp-kunnr.&lt;/P&gt;&lt;P&gt;gs_output-lifnr = gs_likp-lifnr.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;sort gt_lfm1 by lifnr ascending.&lt;/P&gt;&lt;P&gt;read table gt_lfm1 into gs_lfm1 with key lifnr = gs_likp-lifnr Binary search.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;gs_output-ekgrp = gs_lfm1-ekgrp.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;append gs_output to gt_output.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;clear gs_output.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;append gs_output to gt_output.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you chk it now....&lt;/P&gt;&lt;P&gt;if not...tell me the requirement...wil do.&lt;/P&gt;&lt;P&gt;you are writing in a very comlex way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Sandeep Reddy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 15:30:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-problem/m-p/3811929#M916913</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T15:30:30Z</dc:date>
    </item>
  </channel>
</rss>

