styleguides icon indicating copy to clipboard operation
styleguides copied to clipboard

RETURNING large tables is usually okay

Open webracer999 opened this issue 2 years ago • 1 comments

I'm missing the reason why "RETURNING large tables is usually okay" (Clean ABAP). The reason in my eyes is ABAPs "Sharing Between Dynamic Data Objects" (https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenmemory_consumption_3.htm). So internal tables aren't copied in memory, when they don't differ.

Returning of large tables therefore effectively end in a logical "call by reference". Which can be observed with the debugger.

webracer999 avatar Sep 05 '21 15:09 webracer999

yea, also see https://blogs.sap.com/2017/07/30/the-mysteries-of-the-returning-parameter/

larshp avatar Sep 05 '21 15:09 larshp

That's correct, the reason being the copy-on-write mechanic with respect to the table data should be mentioned.

N2oB6n-SAP avatar Nov 30 '22 09:11 N2oB6n-SAP