on 04-09-2009 9:29 AM
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.
Thanks
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();
Hi Costas,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey thanks for the reply
I seem to be doing something wrong, but I'm not sure what. Can anyone help?
private SAPbobsCOM.Payments oOutPay;
oOutPay.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer;
DateTime Today = DateTime.Now;
oOutPay.CardCode = "CC0001";
SAPbobsCOM.JournalEntries oJE;
oJE = ((SAPbobsCOM.JournalEntries)(globals.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)));
oJE.GetByKey(106);
oJE.Lines.SetCurrentLine(1);
oOutPay.Invoices.DocLine = oJE.Lines.Line_ID;
oOutPay.Invoices.Add();
oOutPay.Invoices.DocEntry = 106;
oOutPay.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_JournalEntry;
oOutPay.TransferAccount = globals.bankTrAccOP;
oOutPay.TransferSum = total;
oOutPay.Add();
Edited by: Costas Ioannou on Apr 9, 2009 1:48 PM
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.