Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Posting a Purchase Receipt

(0) ShareShare
ReportReport
Posted on by 289

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;

  • Suggested answer
    Greg Kujawa Profile Picture
    Greg Kujawa 289 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.

  • Greg Kujawa Profile Picture
    Greg Kujawa 289 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
    Amit Baru Profile Picture
    Amit Baru 3,027 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

  • Suggested answer
    jerome77 Profile Picture
    jerome77 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?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans