<?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 Code block reusability in LOAD script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1882783#M1216926</link>
    <description>&lt;P&gt;I have a LOAD script like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concatenate(Sales)&lt;/P&gt;
&lt;P&gt;SELECT&lt;/P&gt;
&lt;P&gt;aa,&lt;/P&gt;
&lt;P&gt;bb&lt;/P&gt;
&lt;P&gt;FROM $(vMyPath)file1.xlsx (ooxml, embedded labels, table is INPUT)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concatenate(Sales)&lt;/P&gt;
&lt;P&gt;SELECT&lt;/P&gt;
&lt;P&gt;aa,&lt;/P&gt;
&lt;P&gt;bb&lt;/P&gt;
&lt;P&gt;FROM $(vMyPath)file2.xlsx (ooxml, embedded labels, table is INPUT)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e. 2 blocks of code where only the names of the excel source files differ. &lt;STRONG&gt;(How) Can I reuse the main part of the code to shorten the script and do something like:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sub MySub(MyExcelFile)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Concatenate(Sales)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; SELECT&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; aa,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; bb&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; FROM $(vMyPath)MyExcelFile (ooxml, embedded labels, table is INPUT)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;end sub&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call MySub(file1.xlsx)&lt;/P&gt;
&lt;P&gt;call MySub(file2.xlsx)&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 12:46:22 GMT</pubDate>
    <dc:creator>RobinB1</dc:creator>
    <dc:date>2022-01-19T12:46:22Z</dc:date>
    <item>
      <title>Code block reusability in LOAD script</title>
      <link>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1882783#M1216926</link>
      <description>&lt;P&gt;I have a LOAD script like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concatenate(Sales)&lt;/P&gt;
&lt;P&gt;SELECT&lt;/P&gt;
&lt;P&gt;aa,&lt;/P&gt;
&lt;P&gt;bb&lt;/P&gt;
&lt;P&gt;FROM $(vMyPath)file1.xlsx (ooxml, embedded labels, table is INPUT)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concatenate(Sales)&lt;/P&gt;
&lt;P&gt;SELECT&lt;/P&gt;
&lt;P&gt;aa,&lt;/P&gt;
&lt;P&gt;bb&lt;/P&gt;
&lt;P&gt;FROM $(vMyPath)file2.xlsx (ooxml, embedded labels, table is INPUT)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e. 2 blocks of code where only the names of the excel source files differ. &lt;STRONG&gt;(How) Can I reuse the main part of the code to shorten the script and do something like:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sub MySub(MyExcelFile)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Concatenate(Sales)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; SELECT&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; aa,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; bb&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; FROM $(vMyPath)MyExcelFile (ooxml, embedded labels, table is INPUT)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;end sub&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call MySub(file1.xlsx)&lt;/P&gt;
&lt;P&gt;call MySub(file2.xlsx)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 12:46:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1882783#M1216926</guid>
      <dc:creator>RobinB1</dc:creator>
      <dc:date>2022-01-19T12:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Code block reusability in LOAD script</title>
      <link>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1883000#M1216927</link>
      <description>&lt;P&gt;In general you could outsource such things into sub-routines. Depending on the number of parameter you specify and/or how expensive check- and/or error-logics are included you could build logics which could be used very often and in many scenarios. But the more you includes the more complex becomes it. Therefore be careful with such approaches to not to get the opposite from making things easier.&lt;/P&gt;
&lt;P&gt;In regard to your example you might be able to use wildcards within the filename, like:&lt;/P&gt;
&lt;P&gt;load * from path\*.xlsx (ooxml, …);&lt;/P&gt;
&lt;P&gt;or using it within a filelist-loop, like:&lt;/P&gt;
&lt;P&gt;for each file in filelist('path\*.xlsx')&lt;BR /&gt;&amp;nbsp;&amp;nbsp; load * from [$(file)] (ooxml, …);&lt;BR /&gt;next&lt;/P&gt;
&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 18:32:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1883000#M1216927</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2022-01-19T18:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Code block reusability in LOAD script</title>
      <link>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1884425#M1217004</link>
      <description>&lt;P&gt;I solved this one myself. The correct syntax is (everything else as is):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;FROM $(vMyPath)$(MyExcelFile) (ooxml, embedded labels, table is INPUT)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;call MySub('file1.xlsx')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;call MySub('file2.xlsx')&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 11:45:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Code-block-reusability-in-LOAD-script/m-p/1884425#M1217004</guid>
      <dc:creator>RobinB1</dc:creator>
      <dc:date>2022-01-24T11:45:41Z</dc:date>
    </item>
  </channel>
</rss>

