Sales Shipment Header
Rikarddo
Member Posts: 80
Hi,
I created a table with all possible combinations, based on historic sales, of origin and destination of Post Codes and it's distance in Kms . My point here is to fill up a field in Sales Shipment Line with distance based on the other table.
For example a Shipment of Customer X From A to B in a total of Z Kms.
I created a ProcessingOnly Report to insert in Sales Shipment Line the kms.
My table has this fields :
Code, Customer, PostCode Origin, Post Code Destination, Distance
Where Customer, PostCode Origin, Post Code Destination is a key.
Here is what i tried to do:
But i Can't get the code from my table with sales shipment header.
What am i doing wrong?
I created a table with all possible combinations, based on historic sales, of origin and destination of Post Codes and it's distance in Kms . My point here is to fill up a field in Sales Shipment Line with distance based on the other table.
For example a Shipment of Customer X From A to B in a total of Z Kms.
I created a ProcessingOnly Report to insert in Sales Shipment Line the kms.
My table has this fields :
Code, Customer, PostCode Origin, Post Code Destination, Distance
Where Customer, PostCode Origin, Post Code Destination is a key.
Here is what i tried to do:
Sales Shipment Header - OnAfterGetRecord()
Location.RESET;
Location.SETRANGE(Code,"Sales Shipment Header"."Location Code");
IF Location.FIND('-') THEN
loc:=Location."Post Code";
DistanciaEntrega.RESET;
DistanciaEntrega.SETRANGE(DistanciaEntrega."No.", "Sales Shipment Header"."Sell-to Customer No.");
DistanciaEntrega.SETRANGE("Cod. Origem",loc);
DistanciaEntrega.SETRANGE("Cod. Entrega","Sales Shipment Header"."Ship-to Post Code");
IF DistanciaEntrega.FIND('-') THEN
SalesShipmentLine.RESET;
SalesShipmentLine.SETRANGE("Document No.","Sales Shipment Header"."No.");
SalesShipmentLine.SETRANGE("Sell-to Customer No.","Sales Shipment Header"."Sell-to Customer No.");
SalesShipmentLine.SETRANGE(Type,SalesShipmentLine.Type::Item);
SalesShipmentLine.SETFILTER("No.",'<>%1','');
SalesShipmentLine.SETRANGE("Item Container",FALSE);
IF SalesShipmentLine.FINDSET THEN REPEAT
SalesShipmentLine.Distance:=DistanciaEntrega.Distance;
SalesShipmentLine.MODIFY;
UNTIL SalesShipmentLine.NEXT=0;
But i Can't get the code from my table with sales shipment header.
What am i doing wrong?
0
Comments
-
Sales Shipment Line is related to Sales Shipment Header on Document No. = No. You do not need to add the filter on the Sell-to Customer No.
But, to the point of the issue, have you tried stepping through the code with the debugger? That would be my next move.
One more suggestion. If you are going to edit a record, it is better to use
FINDSET(TRUE, FALSE) so that it is locked. What you are doing works, but is not optimal.2 -
the first parameter of findset tells whether you are going to update the filtered table or not. If true than than second parameter tells whether you're going to update a field which is one of your filters of that table.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions