cancel
Showing results for 
Search instead for 
Did you mean: 

Outgoing Payment with journal Entry

costas_ioannou2
Active Participant
0 Kudos

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();

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

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

costas_ioannou2
Active Participant
0 Kudos

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

costas_ioannou2
Active Participant
0 Kudos

Ah lol I put this : oOutPay.Invoices.Add(); in the wrong place

It needs to go after the other entries Well it works now thanks

Answers (0)