On-prem BC 365 v19.5 environment here. I ran across this post, which had me looking at the possible root cause of my issue (Posting - Codeunits 90 and 91). I am looking to post a receipt-only for a specific PO’s line item using AL. The error that kicks back is an HTTP 400 error - There is nothing to post. Calling the Codeunit 90 - Purch.-Post method, passing in the Purchase Header.
Looking deeper at the Windows Application Log, it appears to be choking on determining the Purchase Header’s Posting Type (i.e. - Receive, Invoice, Ship). My AL code goes back to the Purchase Header, I’m flagging for Receive only, saving the modification, then proceeding to define my Receipt Header and Line. I can look at the Purchase Header in SQL and see just the Receive flag is set to true. I’ll include a code snippet below.
Any suggestions as to what I’m missing?
if PurchHdr.FindFirst() then begin PurchLine.SetRange("Document No.", PoNum); PurchLine.SetRange("Line No.", LineNo); if PurchLine.FindFirst() then begin PurchHdr.Status := PurchHdrStatus::Released; PurchHdr.Invoice := false; PurchHdr.Ship := false; PurchHdr.Receive := true; PurchHdr.Modify(true); Commit(); RcptHdr.Init(); RcptHdrNo := NoSeriesMgt.GetNextNo('P-RCPT', WorkDate(), true); RcptHdr.Validate("No.", RcptHdrNo); RcptHdr.Validate("Order No.", PurchHdr."No."); ...
Looking at the underlying Codeunit 90 source, I see it’s apparently hitting this snag. Which I still don’t understand since I’m defining Ship = true in the Purchase Header.
local procedure CheckHeaderPostingType(var PurchHeader: Record "Purchase Header")
var
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeCheckHeaderPostingType(PurchHeader, IsHandled);
if IsHandled then
exit;
if not (PurchHeader.Receive or PurchHeader.Invoice or PurchHeader.Ship) then
Error(NothingToPostErr);
end;