<?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 Incremental Load for multi-company tables in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Incremental-Load-for-multi-company-tables/m-p/2479313#M100582</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Our ERP includes a few different companies (managed under our enterprise), so basically each table is loaded 8 times ( as we have 8 companies) using the following script that concatenates between the companies and differs by the DBname - the company code so in the end, i have single table that includes all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Each DBName in 'Company1', 'Company2', 'Company3', 'Company4' , 'Company5', 'Company6', 'Company7', 'Company8'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;ORDERS:&lt;BR /&gt;LOAD *,&lt;BR /&gt;'$(DBName)' as Company_SalesOrder,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrderID_Company&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM $(DBName).dbo.ORDERS;&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;and for storing it continues to the following:&lt;/P&gt;
&lt;P&gt;For i = 0 to NoOfTables()-1&lt;BR /&gt;LET vTabNam = TableName($(i));&lt;BR /&gt;Store $(vTabNam) into $(vPriorityDB)$(vTabNam).qvd] (qvd);&lt;BR /&gt;Next i&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;LET vTablesNo = NoOfTables();&lt;BR /&gt;For i=1 to $(vTablesNo)&lt;BR /&gt;let vTabNam = TableName(0);&lt;BR /&gt;drop table [$(vTabNam)];&lt;BR /&gt;Next i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;now, for my question:&lt;/P&gt;
&lt;P&gt;I want to change my load to an Incremental load,&amp;nbsp; but i haven't found any documentation that suits for a multi-company table&amp;nbsp;&lt;/P&gt;
&lt;P&gt;basically i think the main issue for me, is when trying to remove deleted lines as i need to Inner join with the original table - but it will only take 1 company&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my script is as follow:&lt;/P&gt;
&lt;P&gt;Let ThisExecTime = Now( );&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;For Each DBName in 'a101209','a090212'&lt;/P&gt;
&lt;P&gt;ORDERS:&lt;BR /&gt;LOAD *,&lt;BR /&gt;'$(DBName)' as Company_SalesOrder,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrderID_Company,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrder_IncrementKey&lt;/P&gt;
&lt;P&gt;where ModificationTime&amp;gt;='$(LastExecTime) '&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT *,&lt;BR /&gt;system.dbo.tabula_dateconvert($(DBName).dbo.ORDERS.UDATE) AS ModificationTime&lt;BR /&gt;FROM $(DBName).dbo.ORDERS;&lt;BR /&gt;next&lt;/P&gt;
&lt;P&gt;Concatenate&lt;/P&gt;
&lt;P&gt;LOAD * FROM [lib://Incremental (enercon_roi.solberg)/ORDERS.qvd](qvd)&lt;BR /&gt;WHERE NOT EXISTS(Key_SalesOrder_IncrementKey);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//this will only take 1 table - according to the DBName&lt;BR /&gt;Inner Join&lt;/P&gt;
&lt;P&gt;LOAD *,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrder_IncrementKey&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT ORD FROM $(DBName).dbo.ORDERS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ScriptErrorCount = 0 then&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Let LastExecTime = ThisExecTime;&lt;/P&gt;
&lt;P&gt;End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Roi&lt;/P&gt;</description>
    <pubDate>Tue, 03 Sep 2024 09:52:42 GMT</pubDate>
    <dc:creator>roisolberg</dc:creator>
    <dc:date>2024-09-03T09:52:42Z</dc:date>
    <item>
      <title>Incremental Load for multi-company tables</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-Load-for-multi-company-tables/m-p/2479313#M100582</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Our ERP includes a few different companies (managed under our enterprise), so basically each table is loaded 8 times ( as we have 8 companies) using the following script that concatenates between the companies and differs by the DBname - the company code so in the end, i have single table that includes all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Each DBName in 'Company1', 'Company2', 'Company3', 'Company4' , 'Company5', 'Company6', 'Company7', 'Company8'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;ORDERS:&lt;BR /&gt;LOAD *,&lt;BR /&gt;'$(DBName)' as Company_SalesOrder,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrderID_Company&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM $(DBName).dbo.ORDERS;&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;and for storing it continues to the following:&lt;/P&gt;
&lt;P&gt;For i = 0 to NoOfTables()-1&lt;BR /&gt;LET vTabNam = TableName($(i));&lt;BR /&gt;Store $(vTabNam) into $(vPriorityDB)$(vTabNam).qvd] (qvd);&lt;BR /&gt;Next i&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;LET vTablesNo = NoOfTables();&lt;BR /&gt;For i=1 to $(vTablesNo)&lt;BR /&gt;let vTabNam = TableName(0);&lt;BR /&gt;drop table [$(vTabNam)];&lt;BR /&gt;Next i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;now, for my question:&lt;/P&gt;
&lt;P&gt;I want to change my load to an Incremental load,&amp;nbsp; but i haven't found any documentation that suits for a multi-company table&amp;nbsp;&lt;/P&gt;
&lt;P&gt;basically i think the main issue for me, is when trying to remove deleted lines as i need to Inner join with the original table - but it will only take 1 company&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my script is as follow:&lt;/P&gt;
&lt;P&gt;Let ThisExecTime = Now( );&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;For Each DBName in 'a101209','a090212'&lt;/P&gt;
&lt;P&gt;ORDERS:&lt;BR /&gt;LOAD *,&lt;BR /&gt;'$(DBName)' as Company_SalesOrder,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrderID_Company,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrder_IncrementKey&lt;/P&gt;
&lt;P&gt;where ModificationTime&amp;gt;='$(LastExecTime) '&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT *,&lt;BR /&gt;system.dbo.tabula_dateconvert($(DBName).dbo.ORDERS.UDATE) AS ModificationTime&lt;BR /&gt;FROM $(DBName).dbo.ORDERS;&lt;BR /&gt;next&lt;/P&gt;
&lt;P&gt;Concatenate&lt;/P&gt;
&lt;P&gt;LOAD * FROM [lib://Incremental (enercon_roi.solberg)/ORDERS.qvd](qvd)&lt;BR /&gt;WHERE NOT EXISTS(Key_SalesOrder_IncrementKey);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//this will only take 1 table - according to the DBName&lt;BR /&gt;Inner Join&lt;/P&gt;
&lt;P&gt;LOAD *,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrder_IncrementKey&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT ORD FROM $(DBName).dbo.ORDERS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ScriptErrorCount = 0 then&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Let LastExecTime = ThisExecTime;&lt;/P&gt;
&lt;P&gt;End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Roi&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 09:52:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-Load-for-multi-company-tables/m-p/2479313#M100582</guid>
      <dc:creator>roisolberg</dc:creator>
      <dc:date>2024-09-03T09:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Incremental Load for multi-company tables</title>
      <link>https://community.qlik.com/t5/App-Development/Incremental-Load-for-multi-company-tables/m-p/2505666#M103994</link>
      <description>&lt;P&gt;You can actually use the loop value with dollar sign expansion to dynamically change the variable name.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Let ThisExecTime = Now( );&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;For Each DBName in 'a101209','a090212'&lt;/P&gt;
&lt;P&gt;ORDERS:&lt;BR /&gt;LOAD *,&lt;BR /&gt;'$(DBName)' as Company_SalesOrder,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrderID_Company,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrder_IncrementKey&lt;/P&gt;
&lt;P&gt;where ModificationTime&amp;gt;='$(LastExecTime_$(DBName)) '&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT *,&lt;BR /&gt;system.dbo.tabula_dateconvert($(DBName).dbo.ORDERS.UDATE) AS ModificationTime&lt;BR /&gt;FROM $(DBName).dbo.ORDERS;&lt;BR /&gt;next&lt;/P&gt;
&lt;P&gt;Concatenate&lt;/P&gt;
&lt;P&gt;LOAD * FROM [lib://Incremental (enercon_roi.solberg)/ORDERS.qvd](qvd)&lt;BR /&gt;WHERE NOT EXISTS(Key_SalesOrder_IncrementKey);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//this will only take 1 table - according to the DBName&lt;BR /&gt;Inner Join&lt;/P&gt;
&lt;P&gt;LOAD *,&lt;BR /&gt;ORD &amp;amp; '|' &amp;amp; '$(DBName)' as Key_SalesOrder_IncrementKey&lt;BR /&gt;;&lt;BR /&gt;SQL SELECT ORD FROM $(DBName).dbo.ORDERS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ScriptErrorCount = 0 then&lt;/P&gt;
&lt;P&gt;Let LastExecTime_$(DBName) = ThisExecTime;&lt;/P&gt;
&lt;P&gt;End If&lt;BR /&gt;&lt;BR /&gt;next&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 20:15:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Incremental-Load-for-multi-company-tables/m-p/2505666#M103994</guid>
      <dc:creator>morgankejerhag</dc:creator>
      <dc:date>2025-02-12T20:15:51Z</dc:date>
    </item>
  </channel>
</rss>

