Deleting the Items which does not have any Transactions

haseeb1812haseeb1812 Member Posts: 8
Hi,
I am new to Navision / LS Retail we have classic client 2009 sp2.
I need a help ,in deleting items (almost 50,000) which does not have any transaction entry in Item Legder entry table
I tried it with two ways,

1.I Created a Code unit,

On Run Code:
item.reset;
if item.findset then repeat
itemledgentry.reset;
itemledgentry.setrange("Item No.",Item."No.");
if not itemledgentry.findfirst then
item.delete(true);
until item.next = 0;

Running this code unit is not skipping the records in Item ledger entry.

2.Created a report with data item ITEM Table

required filters : Date created,Inventory=0,Purcase qty =0,Sales qty =0,Division=value.
On aftergetrecord()
Item.Delete(True);

is also not skipping the Item Ledger Entry records.

Kindly help me...

Thank you.

Comments

  • SavatageSavatage Member Posts: 7,142
    What we did was add a new field to the item table called "Ledger Entry Exists"
    Type Boolean.
    FieldClass = Flowfield
    Calcformula = Exist("Item Ledger Entry" WHERE (Item No.=FIELD(No.)))

    Then we can filter on the items that do not have this field checked.
    Select & delete - letting the item table (onDelete) take care of the rest.
  • haseeb1812haseeb1812 Member Posts: 8
    Thank you Harry.

    I will try to do as suggested.

    But will it create Preaction as I need to maintain same data at stores as well.
  • haseeb1812haseeb1812 Member Posts: 8
    Thank You Harry

    I tried your suggestion ,It is working fine but taking almost 5 minutes to delete one single Item.
    I have 50,000 Items to delete it will take long time.

    So kindly suggest accordingly.



    Best Regards
    Abdul Haseeb
Sign In or Register to comment.