Dataports : how to import all the file even...

philippegirodphilippegirod Member Posts: 191
edited 2004-03-23 in Navision Attain
if there are a lot of errors in the data.

2 steps :

1/ Create a table to store all the mistakes :
For instance 50000 "Import file errors"

2/ In the dataport, in each fields wich can contain an error do the next :

For instance, if i want to import in the "Sales Header" the "Sell-to customer Name" :
OnBeforeEvaluateField
IF NOT EVALUATE("Sell-to Customer Name",Text) THEN BEGIN
   Errors.FIND('+');
   NumError := Errors."Line No.";
   Errors.INIT; //Begin to insert in the "error" table, Errors is a record var
    Errors."Line No."          := NumError + 10000;
    Errors.Description         := STRSUBSTNO('Import error on field %1, [Field Name]',FIELDNAME("Sell-to customer Name"); //Text wich explain what kind of error
    Errors."Data Type"         := 'Text';  //Field type
    Errors."Incorrect element" := Text;  //The text which couldn't be imported
    Errors.Date                := TODAY; //When the error occured
    Errors.Time                := TIME;  //When the error occured
    //Just to know what was the field length :
    Errors."Field Lenght"      := 30;   
    //If i have al lot of tables to import, to know in wich import the error was :
    Errors."Table Name"        := "Sales Header".TABLENAME; 
    //Same idea : in which record the error was :
    Errors."Record No."        := "No."; 
   Errors.INSERT;
//To continue the import and not have a navision error message :
   CurrDataport.SKIP; 
END;

Like that, you will skip the current field, allow the import of the correct data, and store the error in the error table.
My candle burns by both ends, it will not last the night,
But oh my foes and oh my friends, it gives a lovely light

Comments

  • eromeineromein Member Posts: 589
    que?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
Sign In or Register to comment.