<?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: Trouble while retrieving last material entry per invoice in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529650#M1263416</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I'll try using cursors and let you know if it worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Apr 2009 18:08:44 GMT</pubDate>
    <dc:creator>leonardo_schmidt</dc:creator>
    <dc:date>2009-04-22T18:08:44Z</dc:date>
    <item>
      <title>Trouble while retrieving last material entry per invoice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529648#M1263414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a big trouble to select invoices (FI tables J_1BNFDOC &amp;amp; J_1BNFLIN) related to the most recent entry of a given material number inside another invoice (J_1BNFLIN-MATNR). My report is dumping with a memory overflow when I execute it for a full month's worth of invoices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I'm doing the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Selecting invoice items with an INNER JOIN to also get header information:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT l&lt;SUB&gt;matnr l&lt;/SUB&gt;docnum l&lt;SUB&gt;menge l&lt;/SUB&gt;netpr l&lt;SUB&gt;netoth d&lt;/SUB&gt;docdat d&lt;SUB&gt;model d&lt;/SUB&gt;series d&lt;SUB&gt;nfnum d&lt;/SUB&gt;parid&lt;/P&gt;&lt;P&gt;INTO TABLE it_ult_e_aux&lt;/P&gt;&lt;P&gt;FROM j_1bnflin AS l&lt;/P&gt;&lt;P&gt;INNER JOIN j_1bnfdoc AS d&lt;/P&gt;&lt;P&gt;ON l&lt;SUB&gt;docnum = d&lt;/SUB&gt;docnum&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN it_ult_e&lt;/P&gt;&lt;P&gt;WHERE l~matnr  = it_ult_e-matnr&lt;/P&gt;&lt;P&gt;AND d~doctyp = '1'&lt;/P&gt;&lt;P&gt;AND d~direct = '1'&lt;/P&gt;&lt;P&gt;AND d~docdat &amp;gt; '20030101'&lt;/P&gt;&lt;P&gt;AND d~cancel = ' '.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, IT_ULT_E and IT_ULT_E_AUX have both the same structure, and IT_ULT_E is already populated with all the MATNRs I want to search. The structure for both tables is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF ty_ult_e,&lt;/P&gt;&lt;P&gt;         matnr  LIKE j_1bnflin-matnr,&lt;/P&gt;&lt;P&gt;         docnum LIKE j_1bnflin-docnum,&lt;/P&gt;&lt;P&gt;         menge  LIKE j_1bnflin-menge,&lt;/P&gt;&lt;P&gt;         netpr  LIKE j_1bnflin-netpr,&lt;/P&gt;&lt;P&gt;         netoth LIKE j_1bnflin-netoth,&lt;/P&gt;&lt;P&gt;         docdat LIKE j_1bnfdoc-docdat,&lt;/P&gt;&lt;P&gt;         model  LIKE j_1bnfdoc-model,&lt;/P&gt;&lt;P&gt;         series LIKE j_1bnfdoc-series,&lt;/P&gt;&lt;P&gt;         nfnum  LIKE j_1bnfdoc-nfnum,&lt;/P&gt;&lt;P&gt;         parid  LIKE j_1bnfdoc-parid,&lt;/P&gt;&lt;P&gt;END OF ty_ult_e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. After this, the table is sorted by DOCDAT to get the most recent entries, some move logic is applied and IT_ULT_E ends up with the information I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then, the report dumps with TSV_TNEW_BLOCKS_NO_ROLL_MEMORY, right on the SELECT statement. Am I doing the best selection? Or maybe I'm missing something (maybe a standard FM...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Leonardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2009 13:55:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529648#M1263414</guid>
      <dc:creator>leonardo_schmidt</dc:creator>
      <dc:date>2009-04-22T13:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble while retrieving last material entry per invoice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529649#M1263415</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;This dump is related to memory allocation to internal table.&lt;/P&gt;&lt;P&gt;may be you can try this:&lt;/P&gt;&lt;P&gt;Open cursor with hold l_cursor for &lt;/P&gt;&lt;P&gt;select (ur select) into table itab .&lt;/P&gt;&lt;P&gt;do.&lt;/P&gt;&lt;P&gt;fetch next cursor where (ur clause) PACKAGE SIZE 50000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;processing here,,&lt;/P&gt;&lt;P&gt;refresh internal table.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2009 14:41:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529649#M1263415</guid>
      <dc:creator>Sandeep_Panghal</dc:creator>
      <dc:date>2009-04-22T14:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble while retrieving last material entry per invoice</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529650#M1263416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I'll try using cursors and let you know if it worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2009 18:08:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/trouble-while-retrieving-last-material-entry-per-invoice/m-p/5529650#M1263416</guid>
      <dc:creator>leonardo_schmidt</dc:creator>
      <dc:date>2009-04-22T18:08:44Z</dc:date>
    </item>
  </channel>
</rss>

