Dear All,
This code below is for creating an Item Journal from a customized requisition. But cannot work.
It refuses to recognize the Journal template and the batch and if I comment both Journal template and the batch, it refuses to recognise the posting date and lock the document.
what could be the issue.
procedure CreateItemJournal()
var
ItmJnl: Record "Item Journal Line";
PRQHeader: Record "Purchase Requisition Header";
PRLine: Record "Purchase Requisition Lines";
NextLineNo :Integer;
//counter:Integer;
//counter := counter + 10000;
begin
if PRQHeader.Find then
ItmJnl.INIT();
ItmJnl.VALIDATE("Journal Template Name",'GENERAL');
ItmJnl.VALIDATE("Journal Batch Name",'Default');
IF ItmJnl.FINDLAST THEN
NextLineNo := ItmJnl."Line No." + 10000
ELSE
NextLineNo := 10000;
//NextLineNo := NextLineNo + 10000;
//ItmJnl.validate("Line No.",NextLineNo);
ItmJnl.VALIDATE("Posting Date",PRQHeader."PRQ Date");
ItmJnl.VALIDATE("Entry Type",ItmJnl."Entry Type"::"Negative Adjmt.");
ItmJnl.VALIDATE("Document No.",'Issue'+PRLine."PRQ No.");
ItmJnl.VALIDATE("Item No.",PRLine."No.");
ItmJnl.VALIDATE(Description,PRLine.Description);
ItmJnl.VALIDATE("Variant Code",'');
ItmJnl.VALIDATE("Location Code",'HQ');
ItmJnl.VALIDATE(Quantity,PRLine.Quantity);
ItmJnl.VALIDATE("Quantity (Base)",PRLine.Quantity);
ItmJnl.VALIDATE("Unit of Measure Code",PRLine."Unit of Measure Code");
ItmJnl.VALIDATE("Unit Amount",PRLine."Unit Cost");
ItmJnl.VALIDATE(Amount,PRLine.Quantity*PRLine."Unit Cost");
ItmJnl.VALIDATE("Unit Cost",PRLine."Unit Cost");
ItmJnl.VALIDATE("Applies-to Entry",0);
ItmJnl.Insert();
end;
}