OBJECT Dataport 50050 Import Sales Invoice { OBJECT-PROPERTIES { Date=10/17/08; Time=[ 9:17:30 AM]; Modified=Yes; Version List=; } PROPERTIES { TransactionType=UpdateNoLocks; OnInitDataport=BEGIN // Setup array to use for document numbers, these are stored in an // array then they are added to the lines in order. FOR nCnt:=1 TO ARRAYLEN(aDocNos) DO BEGIN aDocNos[nCnt]:= ''; aDocUsed[nCnt]:= FALSE; END; nHeadCnt := 0; //Used for storing header document numbers nLineCnt := 0; //Used for setting the lines with the correct document no. END; } DATAITEMS { { PROPERTIES { DataItemTable=Table36; DataItemTableView=SORTING(No.); OnBeforeImportRecord=BEGIN INIT; END; OnAfterImportRecord=BEGIN nHeadCnt := nHeadCnt + 1 ; // Header Count WITH "Sales Header" DO BEGIN VALIDATE("Document Type","Document Type"::Invoice); VALIDATE("No.",NoSeriesMgt.GetNextNo('S-IMPINV',0D,FALSE)); aDocNos[nHeadCnt] := "No."; // Take copy of the document number used on this header. VALIDATE("Order Date"); VALIDATE("Posting Date",TODAY); VALIDATE("Document Date","Order Date"); VALIDATE("Sell-to Customer No."); VALIDATE("Bill-to Customer No.","Sell-to Customer No."); Custmr.GET("Sell-to Customer No."); VALIDATE("Sell-to Customer Name",Custmr.Name); VALIDATE("Sell-to Address",Custmr.Address); VALIDATE("Sell-to Address 2",Custmr."Address 2"); VALIDATE("Sell-to City",Custmr.City); VALIDATE("Sell-to Post Code",Custmr."Post Code"); VALIDATE("Customer Posting Group",Custmr."Customer Posting Group"); VALIDATE("Gen. Bus. Posting Group",Custmr."Gen. Bus. Posting Group"); VALIDATE("VAT Bus. Posting Group",Custmr."VAT Bus. Posting Group"); VALIDATE("Bill-to Name",Custmr.Name); VALIDATE("Bill-to Address",Custmr.Address); VALIDATE("Bill-to Address 2",Custmr."Address 2"); VALIDATE("Bill-to City",Custmr.City); VALIDATE("Bill-to Post Code",Custmr."Post Code"); VALIDATE("No. Series",'S-IMPINV'); END; nLineCnt := 0; END; OnPostDataItem=BEGIN NoSeriesMgt.SaveNoSeries(); //Update the Number series. END; } FIELDS { { ; ;"Sell-to Customer No." } { ; ;"Order Date" } { ; ;"External Document No." } } } { PROPERTIES { DataItemTable=Table37; DataItemTableView=SORTING(Document No.,Line No.); OnBeforeImportRecord=BEGIN INIT; END; OnAfterImportRecord=BEGIN WITH "Sales Line" DO BEGIN IF STRLEN("Sell-to Customer No.")<>0 THEN BEGIN VALIDATE("Document Type","Document Type"::Invoice); // Set the document number. If this is first line of the document. IF "Line No." = 1 THEN BEGIN nLineCnt := nLineCnt + 1; VALIDATE("Document No.",aDocNos[nLineCnt]); END ELSE VALIDATE("Document No.",aDocNos[nLineCnt]); VALIDATE("Sell-to Customer No."); VALIDATE(Type,Type::Item); //Line type VALIDATE("No."); VALIDATE("Location Code",'BLUE'); //Validate the warehouse code END; END; END; } FIELDS { { ; ;"Sell-to Customer No." } { ; ;Quantity } { ; ;"No." } { ; ;"Variant Code" ;Enabled=No } { ; ;Description } { ; ;"Unit Price" } { ; ;"Line No." } } } } REQUESTFORM { PROPERTIES { Width=9020; Height=3410; } CONTROLS { } } CODE { VAR aDocNos@1000000000 : ARRAY [1000000] OF Code[10]; aDocUsed@1000000001 : ARRAY [1000000] OF Boolean; nCnt@1000000002 : Integer; nHeadCnt@1000000003 : Integer; nLineCnt@1000000004 : Integer; NoSeriesMgt@1000000005 : Codeunit 396; Custmr@1000000006 : Record 18; BEGIN END. } }
Comments
RIS Plus, LLC
Another tip is to export using the dataport to see if it creates the file in the same layout as you are trying to inport.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
RIS Plus, LLC
The Document Type (ie "Order") The Document No (Matching the HEADER) The TYPE (ie "ITEM") The Line No. (must be different for each line item) The Item No. The Quantity
http://www.BiloBeauty.com
http://www.autismspeaks.org
viewtopic.php?t=16024
you can always add additional fields
http://www.BiloBeauty.com
http://www.autismspeaks.org
Cheers
Dave
That's why I'm for the use of importing all the data into variables and then matching them to there proper Nav fields and validating in the order "I" want.
http://www.BiloBeauty.com
http://www.autismspeaks.org