<?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 Re: FOR..NEXT LOOP is skipping record on incremental load in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1829012#M1214255</link>
    <description>&lt;P&gt;I have also tried to implement incremental load with for loop but not getting the correct data. It is skipping some records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody help on this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Aug 2021 10:39:13 GMT</pubDate>
    <dc:creator>Adorable09</dc:creator>
    <dc:date>2021-08-17T10:39:13Z</dc:date>
    <item>
      <title>FOR..NEXT LOOP is skipping record on incremental load</title>
      <link>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1684359#M593634</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I have run into a bizarre issue during an incremental load scenario.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I have a Sales Order List table and a Sales Order Lines table which is loaded and stored into a QVD daily.&lt;/LI&gt;&lt;LI&gt;The data set is becoming too big to perform the full loads daily and so I am now changing the code to perform an incremental load to reduce the load time.&lt;/LI&gt;&lt;LI&gt;I am encountering an issue during the FOR...NEXT loop when reloading the Sales order lines, some of the lines are skipped during the load and I am unable to identify the error in the code.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Overview of test data load&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Total Sales Orders in list: 593&lt;/LI&gt;&lt;LI&gt;TotalSales Orders modified since last reload: 9 &lt;EM&gt;(currently using today()-7 just so I get sufficient test data loaded.)&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;When i run throught the FOR...NEXT loop certain records are being skipped despite the fact that I have verified the record exists. only 5 of the sales orders load.&lt;/EM&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;EM&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="counts.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29992i714D3D80718C8E1E/image-size/large?v=v2&amp;amp;px=999" role="button" title="counts.png" alt="counts.png" /&gt;&lt;/span&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;STEP 1: Load Sales Orders from QVD&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;//LOAD Sales Order List from the QVD&lt;/P&gt;&lt;P&gt;tSalesList:&lt;BR /&gt;LOAD&lt;BR /&gt;SLSalesOrderID AS tSLSalesOrderID,&lt;BR /&gt;SLSalesOrderNo AS tSLSalesOrderNo,&lt;BR /&gt;SLSalesOrderStatus AS tSLSalesOrderStatus,&lt;BR /&gt;SLSalesOrderDate AS tSLSalesOrderDate,&lt;BR /&gt;SLSalesOrderTimeStamp AS tSLSalesOrderTimeStamp,&lt;BR /&gt;SLSalesInvoiceDate AS tSLSalesInvoiceDate,&lt;BR /&gt;SLSalesInvoiceTimestamp AS tSLSalesInvoiceTimestamp,&lt;BR /&gt;SLCustomerID AS tSLCustomerID,&lt;BR /&gt;SLSalesInvoiceNo AS tSLSalesInvoiceNo,&lt;BR /&gt;SLWooCommerceID AS tSLWooCommerceID,&lt;BR /&gt;SLSalesInvoiceAmount AS tSLSalesInvoiceAmount,&lt;BR /&gt;SLSalesOrderPaidAmount AS tSLSalesOrderPaidAmount,&lt;BR /&gt;SLSalesInvoiceDueDate AS tSLSalesInvoiceDueDate,&lt;BR /&gt;SLSalesOrderShipByDate AS tSLSalesOrderShipByDate,&lt;BR /&gt;SLSalesOrderCurrency AS tSLSalesOrderCurrency,&lt;BR /&gt;SLCustomerCurrency AS tSLCustomerCurrency,&lt;BR /&gt;SLSalesCreditNoteNo AS tSLSalesCreditNoteNo,&lt;BR /&gt;SLSalesOrderLastUpdated AS tSLSalesOrderLastUpdated,&lt;BR /&gt;SLSalesQuoteStatus AS tSLSalesQuoteStatus,&lt;BR /&gt;SLStatusSaleOrder AS tSLStatusSaleOrder,&lt;BR /&gt;SLStatusSalePicking AS tSLStatusSalePicking,&lt;BR /&gt;SLStatusSalePayment AS tSLStatusSalePayment,&lt;BR /&gt;SLSaleTrackingNo AS tSLSaleTrackingNo,&lt;BR /&gt;SLStatusSalePacking AS tSLStatusSalePacking,&lt;BR /&gt;SLStatusSaleShipping AS tSLStatusSaleShipping,&lt;BR /&gt;SLStatusSaleInvoice AS tSLStatusSaleInvoice,&lt;BR /&gt;SLStatusSaleCreditNote AS tSLStatusSaleCreditNote,&lt;BR /&gt;SLSaleFulFillStatus AS tSLSaleFulFillStatus,&lt;BR /&gt;SLSalesOrderType AS tSLSalesOrderType,&lt;BR /&gt;SLSalesOrderChannel AS tSLSalesOrderChannel,&lt;BR /&gt;SLSalesOrderExternalID AS tSLSalesOrderExternalID,&lt;BR /&gt;SLSalesOrderFulfilled AS tSLSalesOrderFulfilled&lt;/P&gt;&lt;P&gt;FROM [C:\Users\Molecule Liquids\Dropbox\Xhype Liquid Co\Business Intelligence\Data Warehouse\QVDs\dl_salesorderlist.qvd]&lt;BR /&gt;(qvd);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;STEP 2: Load IDs of Sales Orders modified based on the criteria&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;//Load Sales Orders updated in the last 7 days&lt;BR /&gt;NewSalesList:&lt;BR /&gt;LOAD&lt;BR /&gt;&lt;BR /&gt;tSLSalesOrderID AS SLSalesOrderID&lt;/P&gt;&lt;P&gt;RESIDENT tSalesList&lt;BR /&gt;WHERE DATE(tSLSalesOrderLastUpdated,'YYYY-MM-DD') &amp;gt;= DATE(TODAY(),'YYYY-MM-DD')-7;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3:&lt;/P&gt;&lt;P&gt;Loop Through the list of Sales Orders and load the Sales Order Lines - This is where the failure occurs&lt;/P&gt;&lt;P&gt;//Load updated Sales Order Lines&lt;BR /&gt;LET vLoop= 0;&lt;BR /&gt;LET vRecord = 0;&lt;BR /&gt;LET vSOID= 0;&lt;BR /&gt;LET vTotalRows = NOOFROWS('NewSalesList'); &lt;FONT color="#FF0000"&gt;&lt;EM&gt;Result is 9 IDs which is correct&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;FOR vLoop= 0 TO vTotalRows-1;&lt;/P&gt;&lt;P&gt;LET vSOID = PEEK('SLSalesOrderID',vLoop,'NewSalesList');&lt;/P&gt;&lt;P&gt;LET vURL='&lt;A href="https://inventory.dearsystems.com/ExternalApi/v2/sale/order?SaleID='&amp;amp;'$(vSOID)'&amp;amp;'&amp;amp;CombineAdditionalCharges=true" target="_blank"&gt;https://inventory.dearsystems.com/ExternalApi/v2/sale/order?SaleID='&amp;amp;'$(vSOID)'&amp;amp;'&amp;amp;CombineAdditionalCharges=true&lt;/A&gt;';&lt;/P&gt;&lt;P&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"SaleID",&lt;BR /&gt;"SaleOrderNumber",&lt;BR /&gt;"Memo",&lt;BR /&gt;"Status",&lt;BR /&gt;"TotalBeforeTax",&lt;BR /&gt;"Tax" AS "Tax_u0",&lt;BR /&gt;"Total" AS "Total_u0",&lt;BR /&gt;"__KEY_root",&lt;BR /&gt;(SELECT&lt;BR /&gt;"ProductID",&lt;BR /&gt;"SKU",&lt;BR /&gt;"Name",&lt;BR /&gt;"Quantity",&lt;BR /&gt;"Price",&lt;BR /&gt;"Discount",&lt;BR /&gt;"Tax",&lt;BR /&gt;"AverageCost",&lt;BR /&gt;"TaxRule",&lt;BR /&gt;"Comment",&lt;BR /&gt;"DropShip",&lt;BR /&gt;"BackorderQuantity",&lt;BR /&gt;"Total",&lt;BR /&gt;"Sku",&lt;BR /&gt;"__FK_Lines"&lt;BR /&gt;FROM "Lines" FK "__FK_Lines")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root"&lt;BR /&gt;WITH CONNECTION(Url "$(vURL)");&lt;/P&gt;&lt;P&gt;LET vLoop = vLoop + 1;&lt;/P&gt;&lt;P&gt;SLEEP(1000);&amp;nbsp;&lt;FONT color="#FF0000"&gt;Calls Limited in API service to 60 callsper minute which in itself is a nuisance &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NEXT vLoop;&lt;/P&gt;&lt;P&gt;NewSalesOrderLines:&lt;BR /&gt;LOAD&lt;BR /&gt;[ProductID],&lt;BR /&gt;[SKU],&lt;BR /&gt;[Name],&lt;BR /&gt;[Quantity],&lt;BR /&gt;[Price],&lt;BR /&gt;[Discount],&lt;BR /&gt;[Tax],&lt;BR /&gt;[AverageCost],&lt;BR /&gt;[TaxRule],&lt;BR /&gt;[Comment],&lt;BR /&gt;[DropShip],&lt;BR /&gt;[BackorderQuantity],&lt;BR /&gt;[Total],&lt;BR /&gt;// [Sku],&lt;BR /&gt;[__FK_Lines] AS [__KEY_root]&lt;BR /&gt;RESIDENT RestConnectorMasterTable&lt;BR /&gt;WHERE NOT IsNull([__FK_Lines]);&lt;/P&gt;&lt;P&gt;LEFT JOIN (NewSalesOrderLines)&lt;BR /&gt;LOAD&lt;BR /&gt;[SaleID],&lt;BR /&gt;[SaleOrderNumber],&lt;BR /&gt;[SaleOrderNumber] AS SalesOrderNo,&lt;BR /&gt;[Memo],&lt;BR /&gt;[Status],&lt;BR /&gt;[TotalBeforeTax],&lt;BR /&gt;[Tax_u0],&lt;BR /&gt;[Total_u0],&lt;BR /&gt;[__KEY_root]&lt;BR /&gt;&lt;BR /&gt;RESIDENT RestConnectorMasterTable&lt;BR /&gt;WHERE NOT IsNull([__KEY_root]);&lt;/P&gt;&lt;P&gt;DROP TABLE RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;//DROP TABLE SalesOrderLines;&lt;/P&gt;&lt;P&gt;I have verified, using the debugger that it loops through and call the service 9 times but it seems like the Sales Order Id does not load. I obtain the Sales Order ID using PEEK() with record number =&amp;nbsp;vLoop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="loops.png" style="width: 352px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29994i417B1F7ADB705FAD/image-size/large?v=v2&amp;amp;px=999" role="button" title="loops.png" alt="loops.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;yet&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="directcall.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29996i05B1000399664AFB/image-size/large?v=v2&amp;amp;px=999" role="button" title="directcall.png" alt="directcall.png" /&gt;&lt;/span&gt; if I call the API direct the missing sales orders do exist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone assist in helping me trouble shoot this issue please.&lt;/P&gt;&lt;P&gt;Zander&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:57:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1684359#M593634</guid>
      <dc:creator>zanderxhype</dc:creator>
      <dc:date>2024-11-16T18:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: FOR..NEXT LOOP is skipping record on incremental load</title>
      <link>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1829012#M1214255</link>
      <description>&lt;P&gt;I have also tried to implement incremental load with for loop but not getting the correct data. It is skipping some records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody help on this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 10:39:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1829012#M1214255</guid>
      <dc:creator>Adorable09</dc:creator>
      <dc:date>2021-08-17T10:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: FOR..NEXT LOOP is skipping record on incremental load</title>
      <link>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1829026#M1214256</link>
      <description>&lt;P&gt;You don't have to increment vLoop in your script (&lt;SPAN&gt;LET vLoop = vLoop + 1;).&amp;nbsp; "Next vLoop" increments it.&amp;nbsp; Remove the line "LET vLoop = vLoop + 1;".&amp;nbsp; Yes it's running right number of times, but&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I bet if you run a trace you'd see .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;vSOID &amp;amp;&amp;nbsp;vURL run 2x for the same&amp;nbsp;&lt;SPAN&gt;SLSalesOrderID and missing the other half&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 11:13:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FOR-NEXT-LOOP-is-skipping-record-on-incremental-load/m-p/1829026#M1214256</guid>
      <dc:creator>stevejoyce</dc:creator>
      <dc:date>2021-08-17T11:13:03Z</dc:date>
    </item>
  </channel>
</rss>

