var
ItemJnl: Record "Item Journal Line";
ItemJnlPostLine: Codeunit "Item Jnl.-Post Line";
begin
ItemJnl.Init();
ItemJnl."Posting Date" := TODAY;
ItemJnl."Journal Template Name" := 'ITEM';
ItemJnl."Journal Batch Name" := 'DEFAULT';
ItemJnl."Document No." := 'Testing';
ItemJnl."External Document No." := 'test';
ItemJnl."Item No." := '1000';
ItemJnl.Validate("Item No.");
ItemJnl."Item Charge No." := 'JB-FREIGHT';
ItemJnl.Description := 'JB-FREIGHT';
ItemJnl."Document Line No." := 20000;
ItemJnl."Unit of Measure Code" := '';
ItemJnl.Quantity := 1;
ItemJnl."Qty. per Unit of Measure" := 1;
ItemJnl."Invoiced Quantity" := 1;
ItemJnl."Invoiced Qty. (Base)" := 1;
ItemJnl.Amount := 400;
ItemJnl."Unit Cost (ACY)" := 400;
ItemJnl."Unit Cost" := 400;
ItemJnl."Applies-to Entry" := 330;
ItemJnl."Gen. Prod. Posting Group" := 'SERVICES';
ItemJnl.Insert();
Message('Inserted');
//ItemJnlPostLine.RunWithCheck(ItemJnl);
end;
The error
Error message:
The Item Ledger Entry does not exist. Identification fields and values: Entry No.='0'
AL call stack:
"Item Jnl.-Post Line"(CodeUnit 22).PostItem line 73 - Base Application by Microsoft
"Item Jnl.-Post Line"(CodeUnit 22).Code line 133 - Base Application by Microsoft
"Item Jnl.-Post Line"(CodeUnit 22).PostSplitJnlLine line 12 - Base Application by Microsoft
"Item Jnl.-Post Line"(CodeUnit 22).RunWithCheck line 16 - Base Application by Microsoft
"Item Jnl.-Post Batch"(CodeUnit 23).PostLines line 48 - Base Application by Microsoft
"Item Jnl.-Post Batch"(CodeUnit 23).Code line 56 - Base Application by Microsoft
"Item Jnl.-Post Batch"(CodeUnit 23).OnRun(Trigger) line 6 - Base Application by Microsoft
"Item Jnl.-Post"(CodeUnit 241).Code line 25 - Base Application by Microsoft
"Item Jnl.-Post"(CodeUnit 241).OnRun(Trigger) line 3 - Base Application by Microsoft
"Item Journal"(Page 40)."Post - OnAction"(Trigger) line 2 - Base Application by Microsoft