TransSales.DELETEALL; TransSalesTransform.RESET; TransSalesTransform.SETCURRENTKEY("Store No.","POS Terminal No.","Transaction No.","Line No."); TransSalesTransform.SETRANGE("Trans. Date",CALCDATE('-1D',RunDate),RunDate); TransSalesTransform.SETRANGE("Store No.",Store."No."); IF TransSalesTransform.FINDSET THEN BEGIN REPEAT TransSales."Store No." := TransSalesTransform."Store No."; TransSales."POS Terminal No." := TransSalesTransform."POS Terminal No."; TransSales."Transaction No." := TransSalesTransform."Transaction No."; TransSales."Line No." := TransSalesTransform."Line No."; TransSales."Active Location Code" := Store."Location Code"; TransSales."Trans. Date" := TransSalesTransform."Trans. Date"; TransSales."Item No." := TransSalesTransform."Item No."; TransSales.Description := Item.Description; TransSales.Quantity := TransSalesTransform.Quantity; TransSales."Trans. Time" := TransSalesTransform."Trans. Time"; TransSales.INSERT; UNTIL TransSalesTransform.NEXT = 0; END;
Answers
Sorry. Same with the TransSalesTransform, the primary key of TransSales is:
Store No.,POS Terminal No.,Transaction No.,Line No.
However upon checking it on the sql, the TransSalesTransform has a no duplicate record.
So I'm not sure if the FINDSET looking that record twice or something?
None. Inside the function, it will delete all data in TransSalesTransform before anything else.
This is now ok. What I did is, I delete the TransSales Table and I save as the TransSalesTransform (which is existing or the source) and named as new table (the TransSales) then remove the unnecessary fields and add the "Active Location Code" which is not present on the source. The codes are still the same.
I don't know how it happen, though.
Anyway, Thank you for your feedback! it is highly appreciated.