Stock out warning in CodeUnit 80

allendeallende Member Posts: 51
I want to control stock out level when I post an order and I wrote the following code in codeunit 80. Runtime occurs an error.Pls help :-k

Item No."does not exist

Note : SL is defined in Globals depending on Sales Line table.When I modify line of Item.GET('123456') any error occurs.

Item.GET(SL."No.");
Item.SETFILTER("Location Filter","Location Code");
//Item.SETFILTER("Variant Filter","Variant Code");
Item.CALCFIELDS(Inventory);
IF Item.Inventory <=0 THEN BEGIN
ERROR(Text045);
END;

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Have you assigned a value to your SL variable?

    Try:
    SL := SalesLine;

    or just use SalesLine."No."

    Make sure that SalesLine.Type = Item before you try to use Item.GET(SalesLine."No.").
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.