Skip to Content
0
Former Member
Jul 28, 2016 at 10:23 PM

Error add Special Prices for Visual Basic

114 Views

Experts have a code in Visual Basic to load with SDK but I get error while performing load


Add picture the Excel, add code the Visual Basic


Thanks for help

Public Sub Imp_Items()

    Dim oCompany As SAPbobsCOM.Company
    Dim lRetCode, ErrorCode As Long
    Dim ErrorMessage As String

    Set oCompany = New SAPbobsCOM.Company

    oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008
    oCompany.DbUserName = "sa"
    oCompany.DbPassword = "xxxxxx"
    oCompany.Server = "SRVSAP"
    oCompany.CompanyDB = "SBOXXXXXX"
    oCompany.UserName = "manager"
    oCompany.Password = "manager"
    oCompany.UseTrusted = False

    lRetCode = oCompany.Connect()

   
    Dim oSpp As SAPbobsCOM.SpecialPrices
        Set oSpp = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSpecialPrices)
       
        Row = 4
        Do While ActiveSheet.Cells(Row, 1)
        oSpp.CardCode = ActiveSheet.Cells(Row, 1)
        oSpp.ItemCode = ActiveSheet.Cells(Row, 2)
        oSpp.PriceListNum = 7
       
        oSpp.Add
        oSpp.SpecialPricesDataAreas.PriceListNo = 7
        oSpp.SpecialPricesDataAreas.DateFrom = ActiveSheet.Cells(Row, 3)
        oSpp.SpecialPricesDataAreas.DateTo = ActiveSheet.Cells(Row, 4)
        oSpp.SpecialPricesDataAreas.Discount = 10
        oSpp.SpecialPricesDataAreas.SpecialPrice = ActiveSheet.Cells(Row, 5)
       
        Row = Row + 1
        Loop
      
        lErr = oSpp.Add
        If lErr <> 0 Then
            Dim sErr As String
            sErr = oCompany.GetLastErrorDescription
            MsgBox (sErr)
        End If
    oCompany.Disconnect
End Sub


Run error

Sheet Excel and add all the columns and rows

Attachments

Excel.jpg (184.7 kB)
Excel Error.jpg (8.8 kB)