cancel
Showing results for 
Search instead for 
Did you mean: 

Incoming Payments in DI

Former Member
0 Kudos

Dear Experts,

The following is the scenario,

say i have 2 invoices of the same customer one for 2000 and another for -2000, Now i'm making an incomming paymnet for both of these things.... in SAP UI when i select these 2 invoices i cannot add a payment with 0 amount, so i just add 0.1 as the payment and add the payment doc.

Now when i do the same in DI its not accepting. The following is the code..

Dim oPymt As SAPbobsCOM.Payments
        Dim totalPayment As Double

        totalPayment = TextBox5.Text
        oPymt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)



        oPymt.DocDate = "07/19/10"
        oPymt.CardCode = "CK0001"
        oPymt.CashSum = TextBox5.Text '15000 'TextBox2.Text '1000.0
        If TextBox5.Text <= 1 Then
            oPymt.CashAccount = "428104" '"580026"
        Else
            oPymt.CashAccount = "428104"
        End If


        oPymt.Invoices.DocEntry = "536" 'TextBox1.Text
        'MsgBox(oPymt.Invoices.PaidSu)
        'oPymt.Invoices.SumApplied = 0.25 '500 + AllocateAmount(totalPayment, TextBox1.Text, "IN") 'TextBox2.Text
        'totalPayment = totalPayment - AllocateAmount(totalPayment, TextBox1.Text, "IN")
        oPymt.Invoices.Add()

        oPymt.Invoices.DocEntry = "537" 'TextBox1.Text
        'MsgBox(oPymt.Invoices.PaidSu)
        'oPymt.Invoices.SumApplied = 0.25 '500 + AllocateAmount(totalPayment, TextBox1.Text, "IN") 'TextBox2.Text
        'totalPayment = totalPayment - AllocateAmount(totalPayment, TextBox1.Text, "IN")
        oPymt.Invoices.Add()

 oErrorInv = oPymt.Add()

But when i am adding the payment i am getting the following error. Enter Valid Code [JDT1.ContraAct]

Where am I going wrong.?

Thanks in advance.

Vasu Natari.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Vasu,

You missing the Account in the payment.

DI API does not has a functionality in payments to reconsile to amounts with 0 balance. The GUI itself knows it.

You can try the scenario you have described, and there is a special settings in SAP b1 to handle the 0.1 difference as a BP Overpayment difference

Problems with your code:

1. You did not provided the invoice type when you entered the docentrys ( there should be defined invoice, credit memo, down payment, etc).

oPymt.Invoices.InvoiceType = 13

2. You should provide 0.1 as cashsum in the header, to the text1, and also G/L Account for the cash The ERROR MESSAGE SAYS: THIS IS MISSING

oPymt.CashSum = 0.1
oPymt.CashAccount = 'GL ACCOUNT FOR CASH

3. You should set up the small differences at:

- g/l account determination: pruchase tab, Overpayment A/R Account / Underpayment A/R Account. Do it for sales also.

- if version > 2007 SP 01 Currency set up, and enter the value 0.1 to IIncoming Amt. Diff. Allowed / Outgoing Amt. Diff. Allowed, and your version is less the 2007 SP1 then open document settings, by documents tab -> select incoming payment then enter the value for all currencies. Do the same for outgoing payments.

I did like described above, and working

Regards

János

Former Member
0 Kudos

J,

I have followed ur inputs, but the same error. The following is the exact code that I am using.

Dim oPymt As SAPbobsCOM.Payments
        Dim totalPayment As Double
        totalPayment = TextBox5.Text
        oPymt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
        oPymt.DocDate = "07/19/10"
        oPymt.CardCode = "TEST"
        oPymt.CashSum = TextBox5.Text '15000 'TextBox2.Text '1000.0
        If TextBox5.Text <= 1 Then
            oPymt.CashAccount = "428104" '"580026"
        Else
            oPymt.CashAccount = "428104"
        End If

        oPymt.Invoices.DocEntry = "538" 'TextBox1.Text
        oPymt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
        oPymt.Invoices.Add()

        oPymt.Invoices.DocEntry = "539" 'TextBox1.Text
        oPymt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
        oPymt.Invoices.Add()
 oErrorInv = oPymt.Add()
        If Not oErrorInv = 0 Then
            MsgBox(oCompany.GetLastErrorDescription)
        Else
            TextBox1.Text = oCompany.GetNewObjectKey()
        End If

Am I doing any mistake..? the same error... Enter Valid Code JDT1.ContraAct line 1 "Test"(BP CardCode)

Thanks,

Vasu Natari,

Former Member
0 Kudos

Hello Vasu,

Did you take al look at the SDK example?

Maybe you must use setcurrentline?

HTH

Regards Teun


Private Sub cmdTest_Click()
   On Error GoTo ErrorHandler
   Dim vCompany As SAPbobsCOM.Company

   'create company object
   Set vCompany = New SAPbobsCOM.Company

   'set paras for connection
   vCompany.CompanyDB = "SBODemo_US"
   vCompany.Password = "manager"
   vCompany.UserName = "manager"
   vCompany.Server = "(local)"

   'connect to database server
   If (0 <> vCompany.Connect()) Then
      MsgBox "Failed to connect"
      Exit Sub
   End If

   Dim nErr As Long
   Dim errMsg As String

   'Set the object's properties
   Dim vPay As SAPbobsCOM.Payments
   Set vPay = vCompany.GetBusinessObject(oIncomingPayments)
   vPay.Address = "622-7"
   vPay.ApplyVAT = 1
   vPay.CardCode = "D10006"
   vPay.CardName = "Card D10004"
   vPay.CashAccount = "288000"
   vPay.CashSum = 0
   'vPay.CheckAccount = "280001"
   vPay.ContactPersonCode = 1
   vPay.DocCurrency = "Eur"
   vPay.DocDate = Now
   vPay.DocRate = 0
   vPay.DocTypte = 0
   vPay.HandWritten = 0
   vPay.JournalRemarks = "Incoming - D10004"
   vPay.LocalCurrency = tYES
   vPay.Printed = 0
   vPay.Reference1 = 8
   vPay.Series = 0
   vPay.SplitTransaction = 0
   vPay.TaxDate = Now
   vPay.TransferAccount = "10100"
   vPay.TransferDate = Now
   vPay.TransferSum = 0

   vPay.Invoices.AppliedFC = 0
   vPay.Invoices.AppliedSys = 0
   vPay.Invoices.DocEntry = 8
   vPay.Invoices.DocLine = 0
   vPay.Invoices.DocRate = 0
   vPay.Invoices.InvoiceType = 13
   vPay.Invoices.LineNum = 0
   vPay.Invoices.SumApplied = 5031.2
   Call vPay.Invoices.Add
   Call vPay.Invoices.SetCurentLine(1)
   vPay.Invoices.AppliedFC = 0
   vPay.Invoices.AppliedSys = 1089.65
   vPay.Invoices.DocEntry = 11
   vPay.Invoices.DocLine = 1
   vPay.Invoices.DocRate = 0
   vPay.Invoices.InvoiceType = it_Invoice
   vPay.Invoices.LineNum = 1
   vPay.Invoices.SumApplied = 1000

   vPay.CreditCards.AdditionalPaymentSum = 0
   vPay.CreditCards.CardValidUntil = CDate("10/31/2004")
   vPay.CreditCards.CreditAcct = "295000"
   vPay.CreditCards.CreditCard = 3
   vPay.CreditCards.CreditCardNumber = "884848448"
   vPay.CreditCards.CreditCur = "EUR"
   vPay.CreditCards.CreditRate = 0
   vPay.CreditCards.CreditSum = 5031.2
   vPay.CreditCards.CreditType = 1
   vPay.CreditCards.FirstPaymentDue = CDate("11/29/2002")
   vPay.CreditCards.FirstPaymentSum = 5031.2
   vPay.CreditCards.LineNum = 0
   vPay.CreditCards.NumOfCreditPayments = 1
   vPay.CreditCards.NumOfPayments = 1
   vPay.CreditCards.OwnerIdNum = "3993939"
   vPay.CreditCards.OwnerPhone = "383838888"
   vPay.CreditCards.PaymentMethodCode = 1
   Call vPay.CreditCards.Add
   Call vPay.CreditCards.SetCurentLine(1)
   vPay.CreditCards.AdditionalPaymentSum = 0
   vPay.CreditCards.CardValidUntil = CDate("10/31/2004")
   vPay.CreditCards.CreditAcct = "295000"
   vPay.CreditCards.CreditCard = 3
   vPay.CreditCards.CreditCardNumber = "884848448"
   vPay.CreditCards.CreditCur = "EUR"
   vPay.CreditCards.CreditRate = 0
   vPay.CreditCards.CreditSum = 1000
   vPay.CreditCards.CreditType = 1
   vPay.CreditCards.FirstPaymentDue = CDate("11/29/2002")
   vPay.CreditCards.FirstPaymentSum = 1000
   vPay.CreditCards.LineNum = 1
   vPay.CreditCards.NumOfCreditPayments = 1
   vPay.CreditCards.NumOfPayments = 1
   vPay.CreditCards.OwnerIdNum = "3993939"
   vPay.CreditCards.OwnerPhone = "383838888"
   vPay.CreditCards.PaymentMethodCode = 1
   If (vPay.Add() <> 0) Then
       MsgBox ("Failed to add a payment")
   End If

   'Check Error
   Call vCompany.GetLastError(nErr, errMsg)
   If (0 <> nErr) Then
       MsgBox ("Found error:" + Str(nErr) + "," + errMsg)
   Else
       MsgBox ("Succeed in payment.add")
   End If

   'disconnect the company object, and release resource
   Call vCompany.Disconnect
   Set vCompany = Nothing
   Exit Sub
ErrorHandler:
   MsgBox ("Exception:" + Err.Description)
End Sub

Former Member
0 Kudos

Did you set up the customizing for small differences i have posted?

Try this (easy to track the changes)

Dim oPymt As SAPbobsCOM.Payments
Dim sum as decimal  = 0' Forget double 4ever

        oPymt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
        oPymt.DocDate = "07/19/10"
        oPymt.CardCode = "TEST"
      
        oPymt.Invoices.DocEntry = "538"
        oPymt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
oPymt.Invoices.SumApplied  = 'SUM OF INVOICE
sum  += 'SUM OF INVOICE
        oPymt.Invoices.Add()
 
        oPymt.Invoices.DocEntry = "539" 
        oPymt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
oPymt.Invoices.SumApplied= 'SUM OF INVOICE
sum  += 'SUM OF INVOICE
        oPymt.Invoices.Add()

if sum = 0 then sum = 0.1
oPymt.CashSum = sum  
oPymt.CashAccount = "428104"
 

 oErrorInv = oPymt.Add()
        If Not oErrorInv = 0 Then
            MsgBox(oCompany.GetLastErrorDescription)
        Else
            TextBox1.Text = oCompany.GetNewObjectKey()
        End If

For me working invoce with 100 and -100

regards

J

Former Member
0 Kudos

Dear J,

In the above sample, 'SUM OF INVOICE has to be replaced by sum ???

And J as u have said that its working for u... can u tell me the exact JE posting that has been posted by this payment document.

Vasu

Edited by: vasu natari on Jul 21, 2010 8:21 AM

Former Member
0 Kudos

Dear J,

I have tried your code, I have 2 invoices with 1000 and -1000. And the currency settings value with Incoming Amt Diff. Allowed as 1 and the cash sum as 2.

And the invoice got added, but in the corresponding JE the cust acc got debited by 2 Rs. Which should not happen, the customer acc should not come into the picture at all. Only the underpayment acc has to be effected in the transacton.

If the setting Incoming Amt Diff. Allowed is less than the Cash sum its adding. (Setting 1 and cash sum = 2 rs)

But if the Incoming Amt Diff. Allowed is more than the Cash sum its throwing Enter Valid acc .(Setting = 1 and cash sum = 1 or 0.5)

The following is the code that I have followed. Please have a look if I missed something.

Dim oPymt As SAPbobsCOM.Payments
        Dim sum As Decimal = 0 ' Forget double 4ever

        oPymt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
        oPymt.DocDate = "07/21/10"
        oPymt.CardCode = "TEST"

        oPymt.Invoices.DocEntry = "538"
        oPymt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
        oPymt.Invoices.SumApplied = 1000 'SUM OF INVOICE
        sum += sum 'SUM OF INVOICE
        oPymt.Invoices.Add()

        oPymt.Invoices.DocEntry = "539"
        oPymt.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
        oPymt.Invoices.SumApplied = -1000 'SUM OF INVOICE
        sum += sum 'SUM OF INVOICE
        oPymt.Invoices.Add()

        If sum = 0 Then sum = 1
        oPymt.CashSum = sum
        oPymt.CashAccount = "580026"


        oErrorInv = oPymt.Add()
        If Not oErrorInv = 0 Then
            MsgBox(oCompany.GetLastErrorDescription)
        Else
            TextBox1.Text = oCompany.GetNewObjectKey()
        End If

Many thanks to you J for ur valuable time....

Thanks,

Vasu

Former Member
0 Kudos

Dear J,

Any inputs??

Vasu Natari.

Former Member
0 Kudos

Hello Vasu

As I have written on my one of previous reply, the reconsilition you would like to do is not possuible in DI API with payments object, because the payment object should post any values different from 0. (we used 1).

Of course the B1 should debit/credit the under/overpayment account and BP , otherwise there would be an unbalanced journal entry.

Right now in DI there is no object supports the reconsiliation you would like to do.

Incoming/outgoing payment is working when the sum of the applied invoices, journal entries, credit memos, down payments, (etc) is not zero.

Regards

János

Former Member
0 Kudos

Janos,

Thanks a lot for your time.

Ur inputs are greatly appreciated.

Regards,

Vasu Natari,

Former Member
0 Kudos

Dear Vasu,

It's possible that your dateformat is not correct.

Take a look at this threads:

[]

[]

HTH Regards Teun

Former Member
0 Kudos

Dear Teun,

The data format was correct. I have check the threads, Cause the same code is working in another scenarios. And i am using SAP 8.8 PL 10.

Vasu,.

Former Member
0 Kudos

Guys,

Any inputs on this one?

Vasu Natari.