Advice on NAV 2017 Code efficiency
This code is taking hours to run but my earlier itterations of it were only taking minutes to run. No change in record count - loking for advice from more seasons developers as to what can i do to improove its runtime - my only thought is to create a temp table and store the records tehre before itterating
CustomerPriceGroup.RESET;
CustomerPriceGroup.SETFILTER("Source Price List",'<>%1','');
IF CustomerPriceGroup.FINDSET THEN BEGIN
REPEAT
DestSalesPrices.RESET;
DestSalesPrices.SETCURRENTKEY("Sales Type","Sales Code","Item No.","Starting Date","Currency Code","Variant Code","Unit of Measure Code","Minimum Quantity");
DestSalesPrices.SETRANGE("Sales Type", DestSalesPrices."Sales Type"::"Customer Price Group");
DestSalesPrices.SETFILTER("Sales Code",CustomerPriceGroup.Code); //empty the destination ready to receive more
DestSalesPrices.DELETEALL(TRUE);
SrcSalesPrices.RESET;
SrcSalesPrices.SETCURRENTKEY("Sales Type","Sales Code","Item No.","Starting Date","Currency Code","Variant Code","Unit of Measure Code","Minimum Quantity");
SrcSalesPrices.SETRANGE("Sales Type",SrcSalesPrices."Sales Type"::"Customer Price Group");
SrcSalesPrices.SETFILTER("Sales Code",CustomerPriceGroup."Source Price List"); //filter source to popualte dest
SrcSalesPrices.SETFILTER("Starting Date",'<=%1', TODAY());
SrcSalesPrices.SETRANGE("Currency Code",CustomerPriceGroup."Src. Price List Currency");
//SrcSalesPrices.SETFILTER("Unit of Measure Code", '<>%1','');
IF CustomerPriceGroup."Src. Ending Date" = 0D THEN
// Only get records where Ending Date is blank
SrcSalesPrices.SETRANGE("Ending Date", 0D)
ELSE
SrcSalesPrices.SETRANGE("Ending Date", CustomerPriceGroup."Src. Ending Date");
IF SrcSalesPrices.FINDSET THEN BEGIN
REPEAT
DestSalesPrices.RESET;
DestSalesPrices.INIT;
DestSalesPrices."Sales Type" := DestSalesPrices."Sales Type"::"Customer Price Group";
DestSalesPrices."Sales Code" := CustomerPriceGroup.Code;
DestSalesPrices."Item No." := SrcSalesPrices."Item No.";
DestSalesPrices."Starting Date" := SrcSalesPrices."Starting Date";
DestSalesPrices."Currency Code" := SrcSalesPrices."Currency Code";
DestSalesPrices."Variant Code" := SrcSalesPrices."Variant Code";
DestSalesPrices."Unit of Measure Code" := SrcSalesPrices."Unit of Measure Code";
DestSalesPrices."Minimum Quantity" := SrcSalesPrices."Minimum Quantity";
DestSalesPrices."Price Includes VAT" := SrcSalesPrices."Price Includes VAT";
DestSalesPrices.Active := SrcSalesPrices.Active;
DestSalesPrices."Date to Submit" := SrcSalesPrices."Date to Submit";
DestSalesPrices."Ending Date" := SrcSalesPrices."Ending Date";
DestSalesPrices."Unit Price" := SrcSalesPrices."Unit Price" * (1 / CustomerPriceGroup."Src. Price List Modifier (/by)");
DestSalesPrices."Unit Price Including VAT" := SrcSalesPrices."Unit Price Including VAT" * (1 / CustomerPriceGroup."Src. Price List Modifier (/by)");
DestSalesPrices.INSERT;
UNTIL SrcSalesPrices.NEXT = 0;
END;
UNTIL CustomerPriceGroup.NEXT = 0;
END;
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 323 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions