Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

DI API: 2005A PL: 08 Special Prices

Hi everyone,

I am using the DI-Object SpecialPrices for adding a special price in the Database. We use a German MSSQL Server 2000 and VB.Net (1.1)

My Code:

Public Sub PreislisteZwischenspeichernLöschenUndSetzen()

'Dim oPreisliste As SAPbobsCOM.PriceLists

Dim oSonderpreisliste As SAPbobsCOM.SpecialPrices

Dim oSonderpreislisteDataArea As SAPbobsCOM.SpecialPricesDataAreas

Dim oSonderpreislisteQuantityArea As SAPbobsCOM.SpecialPricesQuantityAreas

Dim oSBOB As SAPbobsCOM.SBObob

oSBOB = oCibAddOn.oCompany.GetBusinessObject(BoObjectTypes.BoBridge)

'oPreisliste = oCibAddOn.oCompany.GetBusinessObject(BoObjectTypes.oPriceLists)

oSonderpreisliste = oCibAddOn.oCompany.GetBusinessObject(BoObjectTypes.oSpecialPrices)

' Staffelpreisliste neu eingeben

' Wichtig, Standardpreis muss in der Preisliste unter ITM1 eingegeben sein

Dim oArtikelPreis As SAPbobsCOM.Items

Dim oArtikelPreise As SAPbobsCOM.Items_Prices

oArtikelPreis = oCibAddOn.oCompany.GetBusinessObject(BoObjectTypes.oItems)

oArtikelPreis.GetByKey("9999")

Dim intIndex As Integer = 0

Dim blExit As Boolean = False

Do While blExit = False And intIndex < oArtikelPreis.PriceList.Count

oArtikelPreis.PriceList.SetCurrentLine(intIndex)

If oArtikelPreis.PriceList.PriceList = 1 Then

oArtikelPreis.PriceList.Currency = "EUR"

oArtikelPreis.PriceList.Price = 12.5

If oArtikelPreis.Update() <> 0 Then

MsgBox(oCibAddOn.oCompany.GetLastErrorDescription)

End If

blExit = True

End If

intIndex += 1

Loop

oSonderpreisliste.CardCode = "70000"

oSonderpreisliste.ItemCode = "9999"

oSonderpreisliste.Currency = "EUR"

oSonderpreisliste.Price = 12.5

oSonderpreisliste.PriceListNum = 1

oSonderpreisliste.SpecialPricesDataAreas.SetCurrentLine(0)

oSonderpreisliste.SpecialPricesDataAreas.AutoUpdate = BoYesNoEnum.tYES

oSonderpreisliste.SpecialPricesDataAreas.DateFrom = New System.DateTime(2006, 4, 26)

oSonderpreisliste.SpecialPricesDataAreas.Dateto = New System.DateTime(2006, 4, 28)

oSonderpreisliste.SpecialPricesDataAreas.PriceCurrency = "EUR"

oSonderpreisliste.SpecialPricesDataAreas.PriceListNo = 1

oSonderpreisliste.SpecialPricesDataAreas.SpecialPrice = 12.5

oSonderpreisliste.SpecialPricesDataAreas.Add()

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SetCurrentLine(0)

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.PriceCurrency = "EUR"

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Quantity = 1

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SpecialPrice = 12.5

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Add()

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SetCurrentLine(1)

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.PriceCurrency = "EUR"

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Quantity = 100

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SpecialPrice = 10

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Add()

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SetCurrentLine(2)

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.PriceCurrency = "EUR"

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Quantity = 1000

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.SpecialPrice = 7.5

oSonderpreisliste.SpecialPricesDataAreas.SpecialPricesQuantityAreas.Add()

If oSonderpreisliste.Add <> 0 Then

MsgBox(oCibAddOn.oCompany.GetLastErrorCode)

MsgBox(oCibAddOn.oCompany.GetLastErrorDescription)

End If

System.Windows.Forms.Application.Exit()

End Sub

We get all the time the errormessage: Date is out of range.

We also try to use the functions SaveAsXML and GetBusinessObjectFromXML, but then the same error comes.

Trinidad wrote a lot of time that the error is solved in the Version 2005, but it isn`t so for us.

Please help

Regards

Jörn

replied

Sorry for the double post; I thought I would be better showing how my code goes.

As with the original poster, I am using the DI-object Special Prices to insert new records. I am trying to create a Special Price that is BP-Item specific, using the default demo company (SBO Demo UK), valid date from 15 Jun to 20 Jun.

Dim oSpecialPrices As SpecialPrices = oCompany.GetBusinessObject(BoObjectTypes.oSpecialPrices)
Dim oSpecialPricesDataAreas As SpecialPricesDataAreas = oSpecialPrices.SpecialPricesDataAreas

' SpecialPrices settings
oSpecialPrices.ItemCode = "A1000"
oSpecialPrices.CardCode = "C1000"
oSpecialPrices.AutoUpdate = BoYesNoEnum.tYES
oSpecialPrices.PriceListNum = 3
oSpecialPrices.DiscountPercent = 50

' ------------------ START ------------------
' SpecialPricesDataAreas settings
oSpecialPricesDataAreas.SetCurrentLine(0)
oSpecialPricesDataAreas.DateFrom = New DateTime(2006, 6, 15)
oSpecialPricesDataAreas.Dateto = New DateTime(2006, 6, 20)
oSpecialPricesDataAreas.AutoUpdate = BoYesNoEnum.tYES
oSpecialPricesDataAreas.Discount = 15
oSpecialPricesDataAreas.PriceListNo = oSpecialPrices.PriceListNum
oSpecialPricesDataAreas.PriceCurrency = "GBP"
oSpecialPricesDataAreas.Add()
' ------------------- END -------------------

' Adding and checking for any errors
oSpecialPrices.Add()

oCompany.GetLastError(lErrCode, sErrMsg)
If lErrCode <> 0 Then
    MsgBox(lErrCode & ": " & sErrMsg)
End If

If the portion of the code between START and END was commented out the insertion was successful. Else as it is, it will keep prompting Invalid Date Range (-10).

Can anyone please shower some enlightenment?

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question