Hi all,
I have created one item and assigned “Lot No’s” for that Item in Purchase order. After posting this order in ILE I have records like this
ItemNo Entry Type Qty Location Lotno Qty Remaining
1001 Purchase 10 Blue Lot001 10
1001 Purchase 10 Blue Lot002 10
1001 Purchase 10 Blue Lot003 10
Now I want rise one Sales Order for this item with Qty 25(we Have default Functionality to assign Lot nO.s but I am Just trying to do that manually) . So it should assign “Lot no” automatically. for that I am inserting Data into table called Tracking Secification like this
entryNo ItemNo Qty Location Lotno
1 1001 10 Blue Lot001
1 1001 10 Blue Lot002
1 1001 5 Blue Lot003
For this I have added one menu item in Line Menu Button called “Auto Lot No.” In Sales Order Form. In OnPush event of this control I have written code like this.
SalesLine.SETRANGE(SalesLine.“Document No.”,“No.”);
IF SalesLine.FINDFIRST THEN REPEAT
SalesQty:= SalesLine.Quantity;
Item.SETRANGE(Item.“No.”,SalesLine.“No.”);
ILE.SETRANGE(ILE.“Item No.”,SalesLine.“No.”);
ILE.SETRANGE(ILE.“Entry Type”,ILE.“Entry Type”::Purchase);
IF ILE.FINDFIRST THEN REPEAT
IF ( SalesQty <>0 ) AND (ILE.“Remaining Quantity” <= SalesQty)
AND (ILE.“Remaining Quantity” <>0 ) THEN BEGIN
TrackingSpec.“Item No.” :=ILE.“Item No.”;
TrackingSpec.“Location Code” :=ILE.“Location Code”;
TrackingSpec.“Quantity (Base)” := ILE.“Remaining Quantity”;
TrackingSpec.“Lot No.”:= ILE.“Lot No.”;
SalesQty:= SalesQty-ILE.“Remaining Quantity”;
END
ELSE IF(ILE.“Remaining Quantity” > SalesLine.Quantity ) THEN BEGIN
TrackingSpec.“Item No.” :=ILE.“Item No.”;
TrackingSpec.“Location Code” :=ILE.“Location Code”;
TrackingSpec.“Lot No.”:= ILE.“Lot No.”;
TrackingSpec.“Quantity (Base)” := ILE.“Remaining Quantity”;
SalesQty:= 0;
END;
TrackingSpec.INSERT;
TrackingSpec.MODIFY;
UNTIL ILE.NEXT=0;
UNTIL SalesLine.NEXT=0;
But I am getting an error like this when I try to click this button. Please help me.