on 07-19-2010 10:29 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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,
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
12 | |
11 | |
6 | |
6 | |
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.