Looking to do some dataport importing. My knowlege of Nav is very limited (limited to end user training). From a end user standpoint what do I need to do to setup a dataport? We get files from our vendors (prices, min order amount, etc). I want to be able use that file and update the Purchase Prices table, but be able to get a report (text file,etc) back on things that failed.
Copy-and-paste (simple data every piece of data is exactly what you would import into Navision)
You can actually do a copy and paste from Excel to a Navision table. However you need to massage the data a little in Excel so that all fields (datatype and field length) and make sure they are valid before you can do an error-free copy-and-paste.
Validating dataport (necessary when importing data w/ non-standard format)
A validating dataport will probably save you time in the long run. However simply turning on the CallFieldValidate may not be enough because the dataport will just stop upon the first error it encounters and you would have no idea where in your input data file is having a problem. Generally the design of such dataport has to consider two things:
Use global variables to hold the imported values first before assigning to a table field. You may need to manipulate the imported data before you want to map or assign to the table field. It happens a lot when vendors are giving you CSV files that have non-standard date format (e.g., 20070911). You can create a function called MapFields (in an export dataport) or SetUpFields (in an import dataport). This is the place you map the fields using :=, do any necessary truncations or re-format your data to vendor-specific requirements.
Create these global variables: ErrLogFile (File), ErrLogFileName (Text), ErrLogFileStream (Outstream) and capture your custom error messages (which should always include a line number). If the validation test fails upon the first error, do a ErrLogFileStream.WRITETEXT(“Line No.”) to capture it before doing an ErrLogFile.CLOSE
Also please clarify what you mean by “updating” your Purchase Prices tables—replacing selected fields or replacing the whole record after import?
We have developed in-house a lot of dataports using this design pattern to import Purchase Invoices from DHL, TNT, etc.