Options

Check for Duplicated Item No

vios15vios15 Member Posts: 43
edited 2010-07-19 in Navision Attain
Dear Expert,

I have created a dataport that allow import of data from csv into a temporary table, it's working fine, but I would the system to check after import for duplication of ordered item No. As the duplication of item could create problem in the later stage. I would like to solve it at the temporary table first.

Does anyone has a solution?

Thanks

Answers

  • Options
    krikikriki Member, Moderator Posts: 9,090
    Something like:
    recTemporaryTable.RESET;
    recTemporaryTable.SETCURRENTKEY("Item No.");
    IF recTemporaryTable.FINDSET THEN
      REPEAT
        recTemporaryTable2.RESET;
        recTemporaryTable2.RESET;
        recTemporaryTable2.SETCURRENTKEY("Item No.","Customer No.");
        recTemporaryTable2.SETRANGE("Item No.",recTemporaryTable."Item No.");
        recTemporaryTable2.SETRANGE("Customer No.",recTemporaryTable."Customer No.");
        IF recTemporaryTable2.COUNT > 1 THEN BEGIN
          MESSAGE('Item %1 is ordered more than once',recTemporaryTable."Item No.");
    
        END;
      UNTIL recTemporaryTable.NEXT = 0;
    

    What does it do?
    It loops all records in the table and checks how many records exist of the combination "Item No."+"Customer No.".
    If each customer can order each item only once, the COUNT should be 1. If it is more than 1, it means the customer ordered the item more than once.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    vios15vios15 Member Posts: 43
    Hi kriki,

    Thanks for the reply.

    I will test it out and revert.

    Thanks
  • Options
    vios15vios15 Member Posts: 43
    Hi kriki,

    I have tried your solution and it is working.

    Thanks for the help.
Sign In or Register to comment.