cancel
Showing results for 
Search instead for 
Did you mean: 

Problem canceling an incoming Payment

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello Gordon

I tried this: no change.

Hello Jane

The incoming payement and the invoice are on the same period. I even tried creating a new invoice, new incming payment allin the same day: this did not change anything: same error.

Former Member
0 Kudos

You may check this thread:

Former Member
0 Kudos

I've already seen that post but there is no answer in it.

Former Member
0 Kudos

Try change

lRetCode = oDocIP.Cancel() to lRetCode = oDocIP.Cancel

Former Member
0 Kudos

You may be better off to post complete codes for others to check.

Former Member
0 Kudos

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

Former Member
0 Kudos

Have you got the ip.xml file on the C: drive? If you do, have you checked the file?

Former Member
0 Kudos

Yes I hve the file and i checked it... Nothing seems anormal:

Here are the first nodes


<?xml version="1.0" encoding="UTF-16"?>
<BOM>
<BO>
<AdmInfo>
<Object>24</Object>
</AdmInfo>
<ORCT>
<row>
<DocEntry>9003549</DocEntry>
<DocNum>9003549</DocNum>
...

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hello,

Have you tried to cancel this incoming payment manually?

Thanks,

Gordon

Former Member
0 Kudos

Hello Gordon

Yes and in the SBO Client there is no problem cancelling it.

Best Regards

former_member185703
Active Contributor
0 Kudos

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