Hello,
I am trying to create a Report Only processing, that calculates the distance between two Local Post Codes ( My Company WhareHouse and Client).
I'm using a variable dotnet getdistance from google to calculate the distance. But i have some problems.
I have more than 30k lines to calculate, and not all gives back distance different from 0.
My table structure is like this:
Customer No|PostCodeOrigin|PostCodeDestination|Distance
where
Customer No|PostCodeOrigin|PostCodeDestination is a key.
the code does something like this
MyTable.RESET;
IF MyTable.FINDSET THEN REPEAT
...
Code to get the Post Codes and other data
.....
Distance:=GetDistance(PostCodeOrigin, CountryOrigin,PostCodeDestination,CountryDestination);
IF Distance= 0 THEN
Distance:=1;// so i can know what calculation failed
Mytable.Modify;
COMMIT;
SLEEP(1000);
Until Mytable.Next=0;
How can i complement the variable distance so that if it gets 0 there can be other way to get distance by other fields of Customer and Location tables.
Then how can i pass the limit of requests . I don't know what is the limit but i guess is very little.
Or is other way of getting distance between to points in NAV?
Really need help on this one :-/
0
Comments
2. COMMIT is bad, especially inside loop.
3. Your code is probably a part of some batch process and you should divide it to filling other data and distance setting processes.
Name: getDistance
DataType : DotNet
Subtype : GetDistance.GetDistance.'GetDistance, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
Length
Why commit is bad?
Better than COMMIT imho would be to put your call to GetDistance in a TryFunction, so any .NET errors would not rollback transaction
There is no generic way of getting a distance in NAV.
You mat come up with some alghoritm (store geo coordinates along post-codes?), or build your own .NET assembly, or use som alternative WEB API (Bing?), or build/get table of distances between postcodes in some external software, preload it into NAV table and keep it as a dictionary. You can also ask a user and how far is between A and B and remember the answer for future use.
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03