Some questions on dataport import. I create a dataport and import the csv file to a table. The purpose is to import multiple customer's shipping address with the same duplicate sales order no. and so in the csv file I have 7 columns(Order No, Company, Address1, Address2, city, state, zip).
The data is imported, but it only imported one record and I have 11 records in the file. In my coding, I have something like this:
If Shipment.Order No. get(No.) then
Begin
Shipment.Name1 :=Company;
Shipment.Address :=Address1;
and the rest of the mapping fields
End;
My table which the file is imported has line no and could it be this reason which prevent the rest of the records from be imported?
Also I tried to add one column in my file and map the shipment line no with variable lineno, but it still doesn't work. Can any expert have any suggestions? Thanks a lot!!
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Many times, I just use dataport to have the OnAfterImport-triggers, the seperation properties and the file selection. Then I just use an integer element, variables to read the file and the rest in code... . Gives you much more flexibility, maintainability and readability (don't know if these are actual English words though :-k ) ... .
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Now take an order or whatever table this is that alreayd has multiple addresses and use your dataport to EXPORT data.
Then look at the file it created and see if your datafile is setup the same way.
I'm assuming this is due to quick typing in a post
If Shipment.Order No. get(No.) then
If Shipment."Order No.".GET("No.") 8)
So this table is Shipment and the Key fields are?
http://www.BiloBeauty.com
http://www.autismspeaks.org
and it keeps writing the data over the same line over and over again.
Either in your datafile add the line numbers to the dataline
10000
20000
30000
40000
etc..
or have the dataport do it.
OnPreDataItem()
"Line No." := 0;
OnAfterImportRecord()
"Line No." := "Line No." + 10000;
http://www.BiloBeauty.com
http://www.autismspeaks.org
the first way: 1. Add line no column in my file and fill in the numbers
2. add Line No to the dataport field
3. here is the coding:
IF "Multiple Ship-to".GET(OrderNo) THEN
BEGIN
"Multiple Ship-to"."Order No.":=OrderNo;
"Multiple Ship-to"."Ship-to Name" :=name;
"Multiple Ship-to"."Line No." := lineno;
"Multiple Ship-to"."Ship-to Name 2" :=contact;
"Multiple Ship-to"."Ship-to Address" :=address1;
"Multiple Ship-to"."Ship-to Address 2" :=address2;
"Multiple Ship-to"."Ship-to City" :=city;
"Multiple Ship-to"."Ship-to ZIP Code" := zip;
"Multiple Ship-to"."Ship-to State" :=state;
"Multiple Ship-to"."Ship-to Country Code" :=country;
Templine := Templine + 1;
"Multiple Ship-to".INSERT;
End;
When I run the dataport, it pops up an error: "You cannot enter 'lineno' in Integer. The cursor is in front the invalid character.".
The second way: you recommended adding some coding. This is what I do: Take the lineno numbers from my file and add the coding you recommended. Still it doesn't work.
I find the problem is if I add the line no to the dataport field, it gives this error. But if I take out Line No from Dataport Field, it imports correctly, but only one record. I really don't know what to do and I spent two days on it. Thank you for your time, Harry! Can you or some other experts have some other suggestions? Thanks!!!!
related? This looks strange to me.
What are the key fields of "Multiple Ship-To."?
I see you code but where i the incrementing of the line no?
can you manually add in multiple ship-to's or that does that error out too?
http://www.BiloBeauty.com
http://www.autismspeaks.org
This is a custom table - what is line no declared as on the table? Not integer?
"Multiple Ship-to"."Line No." := lineno; will work if you are importing the line no with the data else it would be
"Multiple Ship-to"."Line No." := "Line No." + 10000;
if you use table 222 as a guide it uses Cust No & Code as it's keys.
Each Ship-to has it's own code.
Now do you want to use the "Order No" as it's code?
If so Line No is not needed unles it's one of the keys.
also Why wouldn't you use table 222? what's different about this table?
& Can you explain this. What do you mean Same Duplicate Sales order No? if your just trying to import 7 fields into a table it should't be too difficult. As long as your key fields are SET & VALIDATED.
Is this a one tim dataport, if so you can just hard code the dup order number instead of using that GET which I can't believe it works myself
:-k
http://www.BiloBeauty.com
http://www.autismspeaks.org
-the design of the table?
-what it's keys are (if the only key for example is orderno - it will keep overwriting if you keep using the same orderno) unless you add orderno & line no as a key or orderno & some code field (for example)
-what you are trying to relate this table to?
-if you're trying to do something like table 222?
-what is a dup order no (it this a real # or just something to help you import)
-can you manually add in two lines in this new table?
-plus what ever else was asked above.
-what are you trying to GET with the GET statement?
http://www.BiloBeauty.com
http://www.autismspeaks.org
1. The key for this tableis Order No + Line No
2. It is related to Sales Header
3. The order nos in the csv file which I am going to import are real order numbers. I first got the order no from the header of the sales order form and then based on the order no, I tested typing 6 records with the same sales order no.
Normally it's very easy to import the data to the tables, but not this time. Thanks for your time!