Duplicate error

tullio
tullio Member Posts: 39
I'm importing from text file in a dataport Purchase invoice header
In the aftergetrecord i wrote:


PurInv.INIT;
PurInv."Document Type" := T38."Document Type"::Invoice;
PurInv.INSERT(TRUE);
PurInv.SetHideValidationDialog(TRUE);
PurInv.VALIDATE("Buy-from Vendor No.",NoVen);
PurInv.VALIDATE("Pay-to Vendor No.",PayVen);
PurInv.MODIFY;

After read first record it execute code but second time show an error: "The Purchase Header Already exists"

Why this? I suspect series number not increment after first record.. :-k

Comments

  • MBerger
    MBerger Member Posts: 413
    What happens is that the first time your "No." field is empty which will make the Insert(true) statement assign one. But because INIT doesn't initialize primary key fields ( see the help file ), the second time "No." will still be filled, resulting in the code trying to insert the same document. Just empty the "no." field after your INIT, and it should work
  • tullio
    tullio Member Posts: 39
    Sure! It works.

    Thanks