Reputation: 31
I'm trying to post to SAP B1 from my add-on application payments with multiple invoices. I'm using C# in developing my add-on app.
Upon posting, SAP creates one payment for every invoice or payment detail but suppose to be the invoices of those payments belongs to one payment in my add-on app.
Here's my code.
Payments _pay = (Payments)company.GetBusinessObject(BoObjectTypes.oIncomingPayments);
Recordset _oRecordSet = (Recordset)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
_oRecordSet.DoQuery("select NextNumber from NNM1 where Series = 98");
int docnum = int.Parse(_oRecordSet.Fields.Item(0).Value.ToString());
int errCode = 0;
_pay.DocNum = docnum;
_pay.DocDate = pay.DocDate;
_pay.TaxDate = pay.TaxDate;
_pay.DueDate = pay.DocDueDate;
_pay.CashSum = pay.CashSum;
_pay.CashAccount = pay.CashAcct;
_pay.Invoices.SumApplied = pay.TotalPaid;
_pay.Invoices.AppliedFC = pay.TotalPaid;
_pay.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice;
foreach (var i in pay.Details)
{
InvoiceHeader inv = new InvoiceHeader();
inv = context.InvoiceHeaders.FirstOrDefault(x => x.Id == i.TransactionDocumentNo);
_pay.Invoices.DocEntry = Convert.ToInt32(inv.DocumentNumber);
errCode = _pay.Add();
if (errCode != 0)
{
string _errMsg = "";
company.GetLastError(out errCode, out _errMsg);
}
}
Upvotes: 3
Views: 4971
Reputation: 319
The only way is to pay on account and do the internal reconciliation https://answers.sap.com/questions/568503/internal-reconciliation-posting-using-sdk.html
https://launchpad.support.sap.com/#/notes/2586911 (you need a S-ID for this link)
Upvotes: 0