Lewis,
This is what I found in old notes about creating an EDI Out field:
- Go to the report Load E.D.I. Navision Field (Report No. 14002350), go to the SetUpOutFields() function and find the section of the outbound Navision document you are creating the EDI Out for. Example for the sales invoice 810 search for the E_SLSINV document, enter the code for each of the EDI Out fields. There are several predefined EDI Outs to reference. Compile the object, run the Load E.D.I. Navision Fields report. The E.D.I. Map codeunit will create in text format (note the location of the file when the report is ran) import and compile the E.D.I. Map object. Next, bring the fields into your map.
- In the codeunit to create the outbound file, example for a Sales Invoice 810 codeunit 14002360 E.D.I. Sales Invoice Send, create the EDI Outs in the LoadEDIOutFields functions (Examples below). You would assign the value of the EDI Out field value to whatever datatype is for. If the value is a decimal assign to the variable Decimal Variable. If the value is a text value, use the variable OutFldArray[i]. One more thing, if the value you are trying to calculate based on all the sales invoice lines then you will need to take extra steps. You must create a variable to hold the running total and go to function UpdateTotalLines and do your calculation. Look below for example of Total Freight Amt.
The EDI Out examples below can be used as a reference.
Codeunit 14002360 – LoadEDIOutFields function
'Net Unit Price':
IF SalesInvoiceLine.Quantity > 0 THEN
DecimalVariable := SalesInvoiceLine.Amount / SalesInvoiceLine.Quantity
ELSE
DecimalVariable := 0;
'Inv. Amt. Before Inv. Disc.':
BEGIN
InvDiscAmount := 0;
SalesInvoiceLine2.SETRANGE("Document No.",SalesInvoiceHeader."No.");
IF SalesInvoiceLine2.FIND('-') THEN
REPEAT
InvDiscAmount := InvDiscAmount + SalesInvoiceLine2."Inv. Discount Amount";
UNTIL SalesInvoiceLine2.NEXT = 0;
DecimalVariable := SalesInvoiceHeader.Amount + InvDiscAmount;
END;
'Total Freight Amt.':
DecimalVariable := InvFreightAmt;
Extra step for running totals and/or total fields
UpdateLineTotals()
IF NOT OutputOff THEN BEGIN
LineNumber := LineNumber + 1;
InvTotalUnits := InvTotalUnits + SalesInvoiceLine.Quantity;
InvTotalBaseUnits := InvTotalBaseUnits + SalesInvoiceLine.“Quantity (Base)”;
InvGrossAmt := InvGrossAmt + (SalesInvoiceLine.“Unit Price” * SalesInvoiceLine.Quantity);
END;
IF EDITotalFields.GET(
‘Total Freight Amt.’,SalesInvoiceLine.Type,SalesInvoiceLine.“No.”)
THEN
InvFreightAmt := InvFreightAmt + SalesInvoiceLine.Amount;
Setting up an EDI OUT is broken up into 2 parts:
Part 1:
Report 14002350 Load E.D.I. Navision Fields, Function SetUpOutFields()
Go to the section of the map you want to create the EDI Out for
Make a call to the function WriteEDIOutFields for example:
WriteEDIOutFields(
‘E_SLSINV’,1,'Inv. Amt. Before Inv. Disc.’,3,'Inv. Amt. Before Inv. Disc.’);
Parameters description:
1st parameter is the Navision Document
2nd Field type (whether it is an EDI Out or EDI In)
3rd EDI Out Field
4th Data type
5th Description
Then run the report so that the EDI Out field gets created, a message box will display to import and compile a file, do so from the object designer.
Part 2:
The next thing you need to do is go to the Codeunit that handles that document in this example it will be 14002360 E.D.I. Sales Invoice Send. Depending on what variables you need to get your EDI Out you may need a variable to hold the value. Put your logic in to get the value (if values from the sales invoice line needs to be added up then you will need to add your code in function UpdateLineTotals), then in function LoadEDIOutFields() add to the case statement with the EDI Out field used in part 1. If the EDI Out is a text data type then you will need to assign the value to OutFldArray[i] := else assign it to the appropriate variable:
DecimalVariable for Decimal
IntegerVariable for Integers
DateVariable for Dates