Quantcast
Viewing all articles
Browse latest Browse all 10032

Sales Shipment Header

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:
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?

Viewing all articles
Browse latest Browse all 10032

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>