Posting Purchase Receipt

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;

Someone on another forum suggested that I separate out the Purch.-Post call to a separate procedure. I did and captured the Boolean result. It came back as false, although I can verify looking in the web UI via Page Inspector that the correct Ship/Receive/Invoice flags are set in the Purchase Header. Wondering if I need to manually assign the Qty. to Invoice and Qty. to Receive values in the Purchase Lines, or if my Receipt Lines automatically force those to be calculated?

That was it. I needed to modify the Purchase Line’s Qty. to Receive value in order to accomplish the posting. All good now.