Create Mass Receipt from PO in C#

I am trying to create the receipt in Epicor based on the PO in C#. I am able to get the Receipt Head, but when I try to get the Receipt Detail it states there is a null value but doesn’t tell me what the field name is that is null. Here is my code:
public void CreateERPReceipt(Model mydata, Session erpcon)
{
ReceiptDataSet rds = new ReceiptDataSet();
ReceiptImpl rProxy = Ice.Lib.Framework.WCFServiceSupport.CreateImpl(erpcon, ReceiptImpl.UriPath);

        string packslip = mydata.POnumber + "-Int Serv";
        string serial = string.Empty;
        
        rProxy.ValidateMRPONum(mydata.POnumber, mydata.VendorNum, out serial);
        if (string.IsNullOrEmpty(serial))
        {
            rProxy.GetNewRcvHead(rds, mydata.VendorNum, "");
            var recp = rds.Tables[0].Rows[0];
            recp["VendorNum"] = mydata.VendorNum;
            recp["PackSlip"] = packslip;
            recp["ReceiptDate"] = DateTime.Now;
            recp["ReceivePerson"] = "test";
            recp["ShipViaCode"] = "BEST";
            recp["PONum"] = mydata.POnumber;
            rProxy.Update(rds);

            rProxy.CreateMassReceipts(mydata.VendorNum, "", packslip, 0, mydata.POnumber, rds);
            rProxy.ReceiveAll(rds);
            rProxy.GetNewRcvDtl(rds, mydata.VendorNum, "", packslip);
          
            rProxy.Update(rds);
            rProxy.ReceiveAllLines(true, rds);

        }

I’d suggest enabling Tracing, and use the built-in Mass Receipt functionality once. Make sure to click the Get All and Receive All options during the Mass Receipt.

Doing this on the same PO that you’re test might give more info, like an inventoried part without a Primary Bin assigned. That’s a case where a null value in the dataset would through an exception.

Plus by tracing it, you’ll see ALL the BO’s that actually fire.

If you comment out

// rProxy.GetNewRcvDtl(rds, mydata.VendorNum, "", packslip);

Does it at least run without the Null Error?
(Just trying to determine which line of your code is the issue.)

Does GetNewRcvDtl() create multiple receipt lines? Or should it be called for each line of the PO?

I have created a few trace logs on this procedure. Alot of them are Void methods that do not fill in the dataset. The only method that I have ran across is the GetBYID Method that would fill in the dataset, but that is after the receipt is created. I was hoping someone has come across this before and had some tips.

It does run without the error if I remove the Create Mass Receipt method call. However, I set some of the fields for the receipt line and it comes back “A valid Our Qty is required” I have OurQty and ReceivedQty set. I was hoping that I could do a Mass Receipt like in the code above and skip the Receipt Detail like it does in the trace.

Any chance the PO was entered as Supplier Qty, and not Our Qty?

The PO has both Our Qty and Supplier Qty. I will try to code that in as well.