Excess Quantity posting from Output Journal

Nav 3.6 and 5.0 exe.

Hi All,

Since the Standrad Nav does not give any warning or any other kind of message to post excess quantities from output journal than in Prod. Order.

In order to avoid to post more quantities than specified in Prod. Order i wrote codes at 2 different places,

1st at Item journal Line Table’s OnValidate of Quantity-

IF (“Entry Type” = “Entry Type”::Output) THEN BEGIN
ProdOrder.RESET;
ProdOrder.SETRANGE(ProdOrder.“No.”,“Prod. Order No.”);
ProdOrder.SETRANGE(ProdOrder.“Source No.”,“Item No.”);
IF ProdOrder.FINDSET THEN
REPEAT
IF Quantity > ProdOrder.Quantity THEN
ERROR(Text033,ProdOrder.Quantity);//Text033-You cannnot post more than %1 Quantity
UNTIL ProdOrder.NEXT = 0;
END;

2nd at Codeunit 22, PostOuput()

QtySum := 0;
ItemLedgerEntry.RESET;
ItemLedgerEntry.SETRANGE(“Prod. Order No.”,“Prod. Order No.”);
ItemLedgerEntry.SETRANGE(“Item No.”,“Item No.”);
IF ItemLedgerEntry.FINDSET THEN BEGIN
REPEAT
QtySum := QtySum + ItemLedgerEntry.Quantity;
UNTIL ItemLedgerEntry.NEXT = 0;
IF ProdOrder.GET(ProdOrder.Status::Released,“Prod. Order No.”) THEN
IF (QtySum + Quantity) > ProdOrder.Quantity THEN
ERROR(Text029,(ProdOrder.Quantity - QtySum));//Text029- You cannot Post more than %1 Quantities.
END;

Is it ok to write code like this?

Not sure what you are asking.

“Does it work”?

If it works from your thorough testing then that is your answer.