Delete double BinCode from BinContent

rossale
rossale Member Posts: 26
Hi!!
I've to delete some BinCode(s) from BinContent Table, only for those Item No. repeated twice in the same Location.

Have some one some ideas? How can I do?

Example:

Location | Bin Code | Item No.
1 | AAA.AAA | 0.65789A
1 | BBB.BBB| 0.65789A

1 | CCC.CCC | 1.5698A
1 | DDD.DDD | 54564Q
1 | BBB.BBB | 1.2345
1 | EEE.EEE | A.12345
1 | BBB.BBB | A.12345



I've to delete the Item No. 0.65789A with the Bin Code
BBB.BBB and the Item No. A.12345 with the Bin Code
BBB.BBB

Thanks :D

Alex

Answers

  • kine
    kine Member Posts: 12,562
    ??? Why???
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rossale
    rossale Member Posts: 26
    Hi Ing. Sacek !!

    I've to delete the duplicated Items 'cause I don't need two different Bin Code for the same Item.

    Originally the Item was in a fixed Bin Code (BBB.BBB), when we added the new Bin Code we have forgotten to delete the fixed one. So now I've to delete the wrong Bin Code. :(

    Thanks

    Alex
  • kine
    kine Member Posts: 12,562
    How do you know which Bin code is the correct one for the particular item?

    e.g. when I have item X on bin A and B and item Y on bin A and B, for item X is correct A or B? How can the system know that? :?:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rossale
    rossale Member Posts: 26
    The correct one is the Bin Code not fixed...

    e.g.
    1 | AAA.AAA | 0.65789A <---- CORRECT
    1 | BBB.BBB| 0.65789A <---- TO DELETE

    The Bin Code named "BBB.BBB" is a "fixed code" that we use for those articles that we don't want to manage in warehouse but only for anagrafics purpouse. So we have many Items associated to the "BBB.BBB" Bin Code, when we want to store in warehouse an article we create a new Bin Code and we delete it from the "fixed position" (if exist).

    Now, since we didn't delete the "fixed" before create the new one, we have some articles coded twice. These articles have to delete.

    Also a report could help me, but I don't know how to filter all the Items coded twice.

    Thanks

    Alex
  • kine
    kine Member Posts: 12,562
    you need something like:
      Go through all FIXED bin records in Bin Content
      for each 
         if exists record with same location and item but other BIN then
           delete the fixed bin record
    

    it means
      BinContent.SETRANGE("Bin Code",'BBB.BBB');
      if BinContent.FINDSET then
      repeat
        BinContent2.RESET;
        BinContent2.SETRANGE(Location,BinContent.Location);
        BinContent2.SETRANGE("Item No.",BinContent."Item No.");
        BinContent2.SETFILTER("Bin Code",'<>%1','BBB.BBB');
        if not BinContent2.IsEmpty then begin  //other bin found
          BinContent2 := BinContent;
          BinContent2.DELETE;   // delete the fixed bin through another var than used for iteration
        end;
      until BinContent.NEXT=0;
    

    Code is not tested, is written from scratch. Do not forget to add usage of correct Keys etc...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rossale
    rossale Member Posts: 26
    Thanks Ing. Sacek !!

    I'm going to try in report first ....

    But I'm sure that is the right SOLUTION !! :D

    Thanks

    Alex

    p.s. I try then I mark as SOLVED the Topic...........
  • rossale
    rossale Member Posts: 26
    Hi Ing. Sacek,

    I try... but actually it doesn't works... Could you help me?

    Is there a simply way to sort the "Item No."? In this way I could find the duplicated....

    Thanks a lot for your help.

    Alex
  • rossale
    rossale Member Posts: 26
    SOLVED.

    I made in another way manually by using filtering.

    Thanks

    Alex