cancel
Showing results for 
Search instead for 
Did you mean: 

Special Prices DI Object in 2005 SP1 PL4

Former Member
0 Kudos
87

Hi all, I've been trying to use DI Object's Special Prices to add a new record. I'm using SAP B1 2005 SP01 PL4. I've heard that this Special Price bug revolving Invalid Date Range was fixed in this patch, but I've tried many times to no avail.

Here is my code:

Private Sub InsertSpecialPrices()

Try

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

' SpecialPrices settings

oSpecialPrices.ItemCode = "A1000"

oSpecialPrices.CardCode = "C1000"

oSpecialPrices.AutoUpdate = BoYesNoEnum.tYES

oSpecialPrices.PriceListNum = 3

oSpecialPrices.DiscountPercent = 50

' -


START -


' SpecialPricesDataAreas settings

oSpecialPrices.SpecialPricesDataAreas.SetCurrentLine(0)

oSpecialPrices.SpecialPricesDataAreas.DateFrom = "2006-06-13"

oSpecialPrices.SpecialPricesDataAreas.Dateto = "2006-06-20"

oSpecialPrices.SpecialPricesDataAreas.AutoUpdate = BoYesNoEnum.tYES

oSpecialPrices.SpecialPricesDataAreas.Discount = 15

oSpecialPrices.SpecialPricesDataAreas.PriceListNo = oSpecialPrices.PriceListNum

oSpecialPrices.SpecialPricesDataAreas.PriceCurrency = "GBP"

oSpecialPrices.SpecialPricesDataAreas.Add()

' -


END -


oSpecialPrices.Add()

oCompany.GetLastError(lErrCode, sErrMsg)

If lErrCode <> 0 Then

MsgBox(lErrCode & ": " & sErrMsg)

End If

Catch ex As Exception

MsgBox(ex.ToString)

End Try

End Sub

I always get the message "Invalid Date Range", unless I comment out the region between START and END as shown above.

I've even tried other forms of dates like "new Date(2006, 06, 15)", "20060516", "2006-05-16", etc. Can someone tell me if there is anything wrong?

Thanks for assisting,

Keith Leow

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi All ,

          I am also getting the same problem. Please help me .

Thanks & Regards

Madhubalan .R

Former Member
0 Kudos

Hi Keith

Those fields are of date type, I suggest you convert before asign to date.

oSpecialPrices.SpecialPricesDataAreas.DateFrom = CDate("2006/06/13")

Former Member
0 Kudos

Hi Jose

Thanks for replying. I've tried using Date objects too:

oSpecialPrices.SpecialPricesDataAreas.DateFrom = CDate("2006/06/13")

oSpecialPrices.SpecialPricesDataAreas.Dateto = CDate("2006/06/20")

and even

oSpecialPrices.SpecialPricesDataAreas.DateFrom = new Date(2006, 06, 13)

oSpecialPrices.SpecialPricesDataAreas.Dateto = new Date(2006, 06, 20)

but both still gave the [Invalid Date Range] error. =(

Keith

Former Member
0 Kudos

The error is a SAP o System?

I think of the format search "13/06/2006" or "06/13/2006".

You verifies the format search of the system

Former Member
0 Kudos

Hi Jose,

Yes this error is from SAP, specifically from the oCompany.GetLastError method.

I've tried all sorts of Date format, and using both String and Date type, and in all cases I still get the Invalid Date Range error.

I'm pretty sure this is not about the date input format, because incorrect date format would have thrown me an exception on SQL's expression error. This error is more likely that SAP treats my input to be of incorrect RANGE.

I've made sure that my DateFrom is definitely earlier than my DateTo field. So now I'm at a total lost about what to do.

Perhaps I should ditch the Special Prices object and directly manipulate the data from OSPP and SPP1?