Skip to Content
0
Former Member
Dec 02, 2009 at 05:28 AM

Find Credit Note by UDF and Add Items

66 Views

Hi all

I'm a newbie when it comes to the SAP SDK, so hope my question isn't out of place here. I have been searching for answers for a while but can't seem to find a solid example.

I am developing using VB.NET and need to write code to:

a) Retrieve a Credit Note by RA Number (a user defined field)

b) Add items to that Credit Note

The SDK has a lot of info but I'm just not sure about the syntax. My first attempt is below, but this creates a new credit note and adds the item. I'm not sure how to proceed from here.

        If RetCode <> 0 Then
            vCmp.GetLastError(ErrCode, sErrMsg)
        End If

        Dim RetVal As Long
        Dim ItemCode As String

        Dim vCreditNote As Documents
        vCreditNote = vCmp.GetBusinessObject(BoObjectTypes.oCreditNotes)

        vCreditNote.UserFields.Fields.Item("U_ranumber").Value = "30004"
        vCreditNote.CardCode = "A4276"
        vCreditNote.Lines.ItemCode = ItemCode
        vCreditNote.Lines.Quantity = 1

        RetVal = vCreditNote.Add

        If RetVal <> 0 Then
            vCmp.GetLastError(ErrCode, sErrMsg)
            MsgBox(ErrCode & " " & sErrMsg)
        End If