Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Trouble while retrieving last material entry per invoice

leonardo_schmidt
Product and Topic Expert
Product and Topic Expert
0 Likes
461

Hello experts,

I am having a big trouble to select invoices (FI tables J_1BNFDOC & 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.

Basically, I'm doing the following:

1. Selecting invoice items with an INNER JOIN to also get header information:

SELECT lmatnr ldocnum lmenge lnetpr lnetoth ddocdat dmodel dseries dnfnum dparid

INTO TABLE it_ult_e_aux

FROM j_1bnflin AS l

INNER JOIN j_1bnfdoc AS d

ON ldocnum = ddocnum

FOR ALL ENTRIES IN it_ult_e

WHERE l~matnr = it_ult_e-matnr

AND d~doctyp = '1'

AND d~direct = '1'

AND d~docdat > '20030101'

AND d~cancel = ' '.

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:

TYPES: BEGIN OF ty_ult_e,

matnr LIKE j_1bnflin-matnr,

docnum LIKE j_1bnflin-docnum,

menge LIKE j_1bnflin-menge,

netpr LIKE j_1bnflin-netpr,

netoth LIKE j_1bnflin-netoth,

docdat LIKE j_1bnfdoc-docdat,

model LIKE j_1bnfdoc-model,

series LIKE j_1bnfdoc-series,

nfnum LIKE j_1bnfdoc-nfnum,

parid LIKE j_1bnfdoc-parid,

END OF ty_ult_e.

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.

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...)

Any help is appreciated.

Thanks,

Leonardo

2 REPLIES 2
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
423

Hi,

This dump is related to memory allocation to internal table.

may be you can try this:

Open cursor with hold l_cursor for

select (ur select) into table itab .

do.

fetch next cursor where (ur clause) PACKAGE SIZE 50000.

if sy-subrc eq 0.

processing here,,

refresh internal table.

else.

exit.

endif.

enddo.

Read only

0 Likes
423

Thanks, I'll try using cursors and let you know if it worked.