Outgoing Payment with journal Entry
Hi guys I need your help
I need to be able to do an outgoing payment based on a journal entry. This is my code but I get this error:
"Base document card & target document card do not match"
The journal is based on an incoming payment that was over paid and has a remaining balance.
oOutPay.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer; oOutPay.CardCode = "CC0001"; //oOutPay.Invoices.Add(); oOutPay.Invoices.DocEntry = 106; oOutPay.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_JournalEntry; oOutPay.TransferAccount = globals.bankTrAccOP; oOutPay.TransferSum = 80; int lRetCode; lRetCode = oOutPay.Add();
Edy Simon replied
In order to based the payment on Journal Entry,
You have to set the docline of the Payment to Journal Entry Line which has the same cardcode as your payment card code like this
oPay.Invoices.DocLine = oJE.Lines.Line_ID
What I do is I iterate through the Journal Entry to look for the line like this :
If .Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_JournalEntry _ Or .Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_PaymentAdvice Then Dim oJE As SAPbobsCOM.JournalEntries oJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries) oJE.GetByKey(.Invoices.DocEntry) For iLines As Integer = 0 To oJE.Lines.Count - 1 oJE.Lines.SetCurrentLine(iLines) If oJE.Lines.ShortName = .CardCode Then 'If the line card equal payment card code, then assign the docline id oPay.Invoices.DocLine = oJE.Lines.Line_ID System.Runtime.InteropServices.Marshal.ReleaseComObject(oJE) oJE = Nothing Exit For End If Next End If