web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Posting a Purchase Receipt

(0) ShareShare
ReportReport
Posted on by 565

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;

I have the same question (0)
  • Suggested answer
    jerome77 Profile Picture
    on at
    RE: Posting a Purchase Receipt

    Hi

    What is your location setup if you are using one? Do you have receipt step before to post the PO as received?

  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at
    RE: Posting a Purchase Receipt

    Hi,

    Pls create one function and in that function call one variable PurchaseHeader and cal 90 codeunit to post the Purchase receipt.

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Greg Kujawa Profile Picture
    565 on at
    RE: Posting a Purchase Receipt

    Thanks for your replies! I separated out the Purch.-Post function to a separate procedure in my Codeunit. And I capture the Boolean result value to pass back to the caller. It comes back with False and the receipt still doesn't post.

    To recap, I am not utilizing Warehouse Receipts in my location codes. And I can manually post purchase receipts just fine against the same PO's in the web UI. In my code I am first creating the Purchase Header, and then creating the Purchase Line. I can see these rows added to the respective SQL tables. And the PO header is correctly flagged. I have reviewed the three Booleans (Ship, Invoice, Receive) and see they are correctly set. Wondering if I'm missing a step. Assuming that the PO line values for Qty. to Invoice and Qty. to Receive don't have to be manually set and that the Purchase Lines being created automatically calculates them, correct?

  • Suggested answer
    Greg Kujawa Profile Picture
    565 on at
    RE: Posting a Purchase Receipt

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans