<?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>Question Re: How to use temporary table for table function? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449956#M4662733</link>
    <description>&lt;P&gt;Not sure why temporary tables should be the "best data structure" here.&lt;/P&gt;&lt;P&gt;The problem described can be solved in several ways without temporary tables.&lt;/P&gt;&lt;P&gt;One way would be to use table variables: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;begin&lt;BR /&gt;data_sys1 = select ... from system1.tableXYZ;&lt;BR /&gt;data_sys2 = select ... from system2.tableXYZ;&lt;BR /&gt;
...&lt;BR /&gt;
  select ... &lt;BR /&gt;  from :data_sys1&lt;BR /&gt;union all&lt;BR /&gt;  select ... &lt;BR /&gt;  from :data_sys1
...&lt;BR /&gt;
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This works completely without temporary tables. &lt;/P&gt;&lt;P&gt;Of course, one can go on and stuff the data into arrays - but what for? &lt;/P&gt;&lt;P&gt;Upgrade the system to a version that is currently in support (HANA 1 is out of maintenance) and you get features like DML on table variables.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Aug 2021 00:39:21 GMT</pubDate>
    <dc:creator>lbreddemann</dc:creator>
    <dc:date>2021-08-23T00:39:21Z</dc:date>
    <item>
      <title>How to use temporary table for table function?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaq-p/12449953</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
  &lt;P&gt;I need to write and read to/from a local table in UDF / table function. I learned from this thread: &lt;A href="https://answers.sap.com/questions/124436/create-temporary-local-table-in-function-on-hana.html"&gt;https://answers.sap.com/questions/124436/create-temporary-local-table-in-function-on-hana.html&lt;/A&gt; , that this is only possible by calling a procedure from the UDF (the procedure contains the CREATE GLOBAL TEMPORARY TABLE statement). Because this procedure only works if it has not the definition clause &lt;/P&gt;
  &lt;P&gt;READS SQL DATA&lt;/P&gt;
  &lt;P&gt;I get in my UDF this error message when calling the procedure:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;Could not create catalog object: EXPLAIN PLAN and CALL statement are not allowed; &lt;BR /&gt;CALL for non read only procedure/function is not supported in the READ ONLY procedure/function: 
line 43 col 17 (at pos 1324)&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;How can I handle this situation?&lt;/P&gt;
  &lt;P&gt;Regards, Martin&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 22:53:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaq-p/12449953</guid>
      <dc:creator>martin_lehmann4</dc:creator>
      <dc:date>2021-08-19T22:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use temporary table for table function?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449954#M4662731</link>
      <description>&lt;P&gt;Can you explain why you need to write to al local (temporary?) table in a function?&lt;/P&gt;&lt;P&gt;If the purpose is to change and persist data permanently then using a procedure would likely be the better option.&lt;/P&gt;&lt;P&gt;If three purpose is to transfer intermediate results between different functions and queries, using table typed parameters and table variables could be what you’re looking for.&lt;/P&gt;&lt;P&gt;To make that decision the use case needs to be described in more detail, though.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 23:38:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449954#M4662731</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2021-08-19T23:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use temporary table for table function?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449955#M4662732</link>
      <description>&lt;P&gt;The use case is as follows:&lt;/P&gt;&lt;P&gt;- A BEx query on Composite Provider reads from Calculation View with Table function (BWoH hdb release 1.00.122.27.1568902538) the number of sentences of the same table in five different ERP systems - these systems are connected to hdb via SDA views. Parameters (IP parameter) are company code, fiscal period and system. &lt;/P&gt;&lt;P&gt;- Not all company codes are in more than one system, so the best data structure to collect the data from the different system would be a temporary table (according to internal table in ABAP) to collect - if necessary - the following information:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;BUKRS VARCHAR(4), 
CLNT NVARCHAR(3), 
FISCYEAR NVARCHAR(4), 
FISCPER3 NVARCHAR(3), 
NO_SENT_SYSTEM1 INTEGER, 
NO_SENT_SYSTEM2 INTEGER, 
NO_SENT_SYSTEM3 INTEGER, 
NO_SENT_SYSTEM4 INTEGER, 
NO_SENT_SYSTEM5 INTEGER &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Reading in SAP help I just wonder whether I could manage this task with the help of ARRAY variables and a table creation by an UNNEST function? ( -&amp;gt; &lt;A href="https://help.sap.com/viewer/de2486ee947e43e684d39702027f8a94/1.0.12/en-US/8d4be75f708c4492ab22b6b64784cd63.html"&gt;https://help.sap.com/viewer/de2486ee947e43e684d39702027f8a94/1.0.12/en-US/8d4be75f708c4492ab22b6b64784cd63.html&lt;/A&gt; )&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 19:17:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449955#M4662732</guid>
      <dc:creator>martin_lehmann4</dc:creator>
      <dc:date>2021-08-20T19:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use temporary table for table function?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449956#M4662733</link>
      <description>&lt;P&gt;Not sure why temporary tables should be the "best data structure" here.&lt;/P&gt;&lt;P&gt;The problem described can be solved in several ways without temporary tables.&lt;/P&gt;&lt;P&gt;One way would be to use table variables: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;begin&lt;BR /&gt;data_sys1 = select ... from system1.tableXYZ;&lt;BR /&gt;data_sys2 = select ... from system2.tableXYZ;&lt;BR /&gt;
...&lt;BR /&gt;
  select ... &lt;BR /&gt;  from :data_sys1&lt;BR /&gt;union all&lt;BR /&gt;  select ... &lt;BR /&gt;  from :data_sys1
...&lt;BR /&gt;
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This works completely without temporary tables. &lt;/P&gt;&lt;P&gt;Of course, one can go on and stuff the data into arrays - but what for? &lt;/P&gt;&lt;P&gt;Upgrade the system to a version that is currently in support (HANA 1 is out of maintenance) and you get features like DML on table variables.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 00:39:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449956#M4662733</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2021-08-23T00:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use temporary table for table function?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449957#M4662734</link>
      <description>&lt;P&gt;That works, thanks a lot. HANA 2.0 is already on our sandbox system and soon on production system too - then I will try it with DML on table variables...&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 21:58:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-use-temporary-table-for-table-function/qaa-p/12449957#M4662734</guid>
      <dc:creator>martin_lehmann4</dc:creator>
      <dc:date>2021-08-23T21:58:47Z</dc:date>
    </item>
  </channel>
</rss>

