Dataport Problem- Help!!

Dave_S
Member Posts: 17
Hi,
I am fairly new to MS Dynamics NAV, i am using 5.00
I am testing a dataport i have written to import invoices from a csv formated file. The dataport is used to populate Sales Header and Sales Line tables. Everything is ok in the header part (i think :roll: ) but when it gets to the line dataitem i get the following message:-
"You Must Specify No. in Sales Line Document Type='Invoice Document',Document No. = 'IMP10010', Line No.='1'"
When i check the Sales Line table it has the line entries but the only fields filled in are the ones i am populating through code! Its like it is not reading the data for the data lines.
My Dataport is:-
This is the sample csv file layout i am using:-
CRU109,1/24/2008,12345
CWG153,1/24/2008,12346
C00010,1/24/2008,12347
DIC107,1/24/2008,12348
DOB125,1/24/2008,12349
CRU109,10,1007,83,UK 8 (EU42) Green Original,55,1
CRU109,10,1007,90,UK 9 (EU43) Green Original,55,2
CRU109,10,1007,106,UK 10 (EU44) Green Original,55,3
CWG153,10,1007,83,UK 8 (EU42) Green Original,55,1
C00010,10,1007,83,UK 8 (EU42) Green Original,55,1
DIC107,10,1007,83,UK 8 (EU42) Green Original,55,1
DOB125,10,1007,83,UK 8 (EU42) Green Original,55,1
If anyone has any idea's i would appreciate the help
Cheers
Dave
I am fairly new to MS Dynamics NAV, i am using 5.00
I am testing a dataport i have written to import invoices from a csv formated file. The dataport is used to populate Sales Header and Sales Line tables. Everything is ok in the header part (i think :roll: ) but when it gets to the line dataitem i get the following message:-
"You Must Specify No. in Sales Line Document Type='Invoice Document',Document No. = 'IMP10010', Line No.='1'"
When i check the Sales Line table it has the line entries but the only fields filled in are the ones i am populating through code! Its like it is not reading the data for the data lines.
My Dataport is:-
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. } }
This is the sample csv file layout i am using:-
CRU109,1/24/2008,12345
CWG153,1/24/2008,12346
C00010,1/24/2008,12347
DIC107,1/24/2008,12348
DOB125,1/24/2008,12349
CRU109,10,1007,83,UK 8 (EU42) Green Original,55,1
CRU109,10,1007,90,UK 9 (EU43) Green Original,55,2
CRU109,10,1007,106,UK 10 (EU44) Green Original,55,3
CWG153,10,1007,83,UK 8 (EU42) Green Original,55,1
C00010,10,1007,83,UK 8 (EU42) Green Original,55,1
DIC107,10,1007,83,UK 8 (EU42) Green Original,55,1
DOB125,10,1007,83,UK 8 (EU42) Green Original,55,1
If anyone has any idea's i would appreciate the help

Cheers
Dave
0
Comments
-
I noticed two empty lines between the data. If none of the lines are coming in, try taking one of the empty lines out. The default dataitem separator is two newline's, which is just one empty line. I have not checked your code.0
-
Hi
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.0 -
That's a brilliant tip =D> it'll tell you exactly how to format the imcoming file.0
-
The sales lines have to have at least:
-
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
0 -
read down this whole post - to find lots of basic dataport info & examples!!!
viewtopic.php?t=16024
you can always add additional fields0 -
Thanks for all the replies, im going to read advice then give this another go today.
Cheers
Dave0 -
Thanks to Harry's simple dataport i was able to get mine working by using it as a base and adding in my additional fields. I did find i had to put the date before the customer code as this was causing an error calculating the due date, but hey its working! Thanks for all your help0
-
Validating the proper fields in there proper order is the key to a good dataport.
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions