I want to import three fixed length Ascii files into three tables Vendor, Customer and Item. Can I have one dataport with a custom request form to achieve this?
I want to import three fixed length Ascii files into three tables Vendor, Customer and Item. Can I have one dataport with a custom request form to achieve this?
Is it possible?
Why not?
Dataport can export/import more than one table. Need just add to options form case and export/import in compliance with it.
So can I have three different tables in data item and select at the same time three different fixed length ascii files and each one import a specific table?
Basically it is one file format per dataport. You can create a dataport that imports/exports into/from multiple tables, but those records would have to be in one file.
Or you can set in the Field Designer only One variable with length. After this the variable get the actual line and then you can do anything with this.
...you declare 3 record type of variable for the tables and in the OnAfterImportRecord trigger you can use the data and drop between the tables. (COPYSTR...) :-s
This is very clever Asallai but don't forget that I want to import three different files simultaneously. Or to have a flag, an option box, that it will skip the other tables. For example, I have three tables in my data item (customer, item, vendor) I have a custom request form with an option box and I choose to import my file into Vendor table. I do the following checks:
Vendor - OnPreDataItem()
IF NOT (DataItem = DataItem::Vendor) THEN CurrDataport.SKIP;
Vendor - OnBeforeImportRecord()
IF NOT (DataItem = DataItem::Vendor) THEN CurrDataport.SKIP;
Vendor - OnAfterImportRecord()
IF DataItem = DataItem::Vendor THEN BEGIN
// some custom code here...
END;
But it always try to import my file to customer table and it crashes because length do not match. If I remove customer and item table it works. So how can I bypass the first two tables and import my file only to the third?
Conclusion is to have one dataport with many data items (many tables) and with a custom request form to import or export data only from the chosen table.
I want to import three different files simultaneously
Like I said before, it's one file format per dataport. If you have three different files, you have to have three different dataports or program your own file read codeunit.
I think you're going to have to compromise on something to get this to work. One question I would have is how much time & energy do you want to spend to make the masterfile import process really elaborate. If it's only run once or twice by a few accounting people is it not better to spend developer/analyst resources on other tasks on the project/implementation?
As I see it there are 3 solutions:
1) combine all of your data into 1 big file with 2 line breaks between each dataset (this is the standard DataItemSeperator dataport property). This would allow you to run the import with a pretty straight forward dataport that has 3 data items.
2) build 3 different dataports that take a different file type. Then have a custom built form or process that gets the filenames from user or somewhere else and then calls the appropriate dataports.
3) just build 3 different dataports run them manually for each seperate file (not what you want - but it's quick to build and simple).
I'm sure there are other solutions out there that would work but how much time and energy is smart to spend on building these types of dataports - in my experience these are run once or a few times at Go Live and that's it.
Comments
Why not?
Dataport can export/import more than one table. Need just add to options form case and export/import in compliance with it.
Each data item can have its own format, but you can mix lines in dataitems.
You can import data to a temporary table and modify/Insert data to correct tables.
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
The answer in that case is no. If you combine them into one file then you can easily import into multiple tables at once, but not as separate files.
My Blog - nav.education
RIS Plus, LLC
Ex.
Did not test it but if there is an error with commiting. You can add it
...you declare 3 record type of variable for the tables and in the OnAfterImportRecord trigger you can use the data and drop between the tables. (COPYSTR...) :-s
But it always try to import my file to customer table and it crashes because length do not match. If I remove customer and item table it works. So how can I bypass the first two tables and import my file only to the third?
Conclusion is to have one dataport with many data items (many tables) and with a custom request form to import or export data only from the chosen table.
You can just write empty line to file instead of other data of the table
RIS Plus, LLC
As I see it there are 3 solutions:
1) combine all of your data into 1 big file with 2 line breaks between each dataset (this is the standard DataItemSeperator dataport property). This would allow you to run the import with a pretty straight forward dataport that has 3 data items.
2) build 3 different dataports that take a different file type. Then have a custom built form or process that gets the filenames from user or somewhere else and then calls the appropriate dataports.
3) just build 3 different dataports run them manually for each seperate file (not what you want - but it's quick to build and simple).
I'm sure there are other solutions out there that would work but how much time and energy is smart to spend on building these types of dataports - in my experience these are run once or a few times at Go Live and that's it.
Epimatic Corp.
http://www.epimatic.com
Just for completeness' sake, solution 4: program a codeunit to read the data one line at a time, and decide per line what to do.
RIS Plus, LLC