Dear all,
I am using dataport to import data into Navsion table Location from a text file .
My text file contain some errors ( text lenght exceed or illegal caracter etc ).
Does anyone know is there any way to validate the data during import? How can import data and skip the errors and write error to a text file.
Your comment is highly appriciated.
Regards,
0
Comments
This you can test in the "OnAfterImportRecord()"-trigger.
If it is not ok, you can skip the record (=CurrDataport.SKIP;).
For writing to a file, you have to open it in the "OnPreDataItem()"-trigger and close it in the "OnPostDataItem()"-trigger.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I'm beginner .... if you post some example code ?
I'm disperate .... pls help me
thanks
OnAfterImportRecord()
OnPostDataItem()
I didn't test the code, but this is less-or-more what you will need.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
here is my example of my import :import.txt
I have one table with 2 fields : code and location
<|333156|>^<|DEPOZIT BULK|> ./ldjwzz/....
<|333953|>^<|K-MAG PLOIESTI 1|>
<|333954|>^<|K-MAG TARGOVISTE 1|>
<|334033|>^<|K-MAG GIURGIU 1|>}}[e
<|334148|>^<|MARFA NEEXPEDIATA|>
<|334149|>^<|MARFA NERECEPTIONATA|>
<|334204|>^<|K-MAG GALATI 1|>
<|334205|>^<|K-MAG GALATI 2|>----87362,,mdjd
how to set up a dataport to skip this records and output error filed to a text file ?
First make a dataport with 1 field (a text (=txtTheInputText) of 1024) [at least if your textfile doesn't contain lines longer than 1024 characters].
This will read the file line by line.
You can check it if you put a MESSAGE('%1',txtTheInputText); in the OnAfterImportRecord()-trigger.
So you don't need to do a read from a file. This is handled by the dataport. Look at the standard-import dataports. In general there is no code for importing. The DataItem you can use, is the "Integer"-table with properties "AutoSave","AutoUpdate","AutoReplace" = No.
Once this works fine, you can start putting your code to test the input and to write errors to the textfile:
In the OnPreDataItem()-trigger you open the textfile for writing.
In the OnAfterImportRecord()-trigger you text the textline and write errors to the textfile.
In the OnPostDataItem()-trigger you close your textfile.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!