on 10-22-2009 5:10 PM
Hello Everybody
I'm trying to cancel an Incoming Payment using DI API.
When i do
oDocIP.GetByKey(iDocIPnumber)
I have the document (checked that by saving it as an XML File)
But wen i call the cancel method i have a -2028 Error "No Entry Found"
The incoming payment's payment mean is a bill of exchange.
Thanks in advance for your help
Best Regards
Dear SOFIANE FAESSEL,
Is the payment posted in a previous period?
If yes then try define the relevant series as the default one (in the Series - Incoming Payment -
Setup screen). then try cancel it by DI API.
Best Regards
Jane Jing
SAP Business One Forums team
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may be better off to post complete codes for others to check.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the code
sQueryDE = "SELECT T0.DocEntry FROM ORCT T0 INNER JOIN RCT2 T1 ON T0.DocNum = T1.DocNum Where T1.DocEntry = '" & oInvoices.DocEntry & "' AND T1.InvType=13 "
oRs.DoQuery(sQueryDE)
oRs.MoveFirst()
While Not oRs.EoF
oDocIP.GetByKey(CInt(oRs.Fields.Item(0).Value))
oDocIP.SaveXML("c:\ip.xml")
lRetCode = oDocIP.Cancel()
If CBool(lRetCode) Then
oDI.oCompany.GetLastError(lErrCode, sErrMsg)
Try
Throw New Exception("Impossible d'annuler l'encaissement " & oDocIP.DocEntry & ". Error " & lErrCode & ": " & sErrMsg)
Catch ex As Exception
ExceptionManager.Publish(ex, My.Settings.ExceptionPath, My.Settings.ExceptionFile)
End Try
End If
oRs.MoveNext()
End While
Hello,
For me working Fine my code, which i publish here.
I really do now know what object you are using... oDI.oCompany, but not a problem....
Maybe please cleanup you SM_OBS_DLL, this somethimes solves the the problem...
So my code is....
Private Sub CancelPayment(ByVal sIvoiceID As String)
Try
Dim oPay As SAPbobsCOM.Payments = oCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments)
Dim oRs As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(BoObjectTypes.BoRecordset)
Dim s As String = String.Format("SELECT T0.DocNum FROM ORCT T0 INNER JOIN RCT2 T1 ON T0.DocNum = T1.DocNum Where T1.DocEntry = '{0}' and T1.InvType=13", sIvoiceID)
oRs.DoQuery(s)
Do While Not oRs.EoF
oPay = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
If oPay.GetByKey(oRs.Fields.Item(0).Value.ToString()) Then
If oPay.Cancel <> 0 Then
MsgBox(String.Format("{0}-{1}", oCompany.GetLastErrorCode, oCompany.GetLastErrorDescription))
End If
Else
MsgBox("Payment not found")
End If
oRs.MoveNext()
Loop
Catch ex As Exception
MsgBox(ex.Message)
Finally
GC.Collect()
End Try
End Sub
Take care:
When you pay an invoice partially, example using 2 payments, each payments should be cancelled -> Put the payment object inside the loop, otherwise
you will have some problems with the garbage of DI API. Maybe this causes the problem....
Tested on B1 2007 PL49 and SP1PL05
Regards
J.
Hello,
Have you tried to cancel this incoming payment manually?
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sofiane,
This sounds rather like a bug than an issue in the (small piece of) code.
I would suggest that you raise it to SAP Support...
Sorry for the inconvenience,
Frank
PS:... but please note that GetByKey returns a boolean value so you could check that instead of using exception handling...
Edited by: Frank Moebius on Nov 2, 2009 6:13 PM
User | Count |
---|---|
105 | |
8 | |
6 | |
6 | |
5 | |
5 | |
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.