on 09-18-2008 10:01 AM
Dear members,
In a form, I have a textfield to enter date and it is linked with Userdatasource - Date.
When I try to retrieve data from the table to show in the form, I got an exception ' Invalid date'. Can anyone help to resolve this problem?
objForm.DataSources.UserDataSources.Add("U6", SAPbouiCOM.BoDataType.dt_DATE
objText.DataBind.SetBound(True, "", "U6"))
If Not objRS.EoF Then
objForm.Items.Item("B4").Specific.string = objRS.Fields.Item("U_BatchnumLength").Value
Dim strdate As Date = objAddOn.objGenFunc.GetDateTimeValue(objRS.Fields.Item("U_FirstInsBatchNum").Value)
objForm.Items.Item("B6").Specific.value = strdate
objForm.Items.Item("B8").Specific.value = objAddOn.objGenFunc.GetDateTimeValue(CStr(objRS.Fields.Item("U_FreshBatchNumber").Value))
objForm.Items.Item("B10").Specific.string = CStr(objRS.Fields.Item("U_Separator").Value)
End if
Thanks and Regards,
Tamil
Dear Tamil
You wrote
-
Dear members,
In a form, I have a textfield to enter date and it is linked with Userdatasource - Date.
When I try to retrieve data from the table to show in the form, I got an exception ' Invalid date'. Can anyone help to resolve this problem?
objForm.DataSources.UserDataSources.Add("U6", SAPbouiCOM.BoDataType.dt_DATE
objText.DataBind.SetBound(True, "", "U6"))
If Not objRS.EoF Then
objForm.Items.Item("B4").Specific.string = objRS.Fields.Item("U_BatchnumLength").Value
Dim strdate As Date = objAddOn.objGenFunc.GetDateTimeValue(objRS.Fields.Item("U_FirstInsBatchNum").Value)
objForm.Items.Item("B6").Specific.value = strdate
objForm.Items.Item("B8").Specific.value = objAddOn.objGenFunc.GetDateTimeValue( _
CStr(objRS.Fields.Item("U_FreshBatchNumber").Value))
objForm.Items.Item("B10").Specific.string = CStr(objRS.Fields.Item("U_Separator").Value)
End if
Thanks and Regards,
Tamil
Hi Tamil
-
I think I can help you to solve the problem.
To try this you can use some of SAP B1 SDK Samples.
I'm used COM UI\VB.NET\17.ChooseFromList and at end of CreateForm() subroutine I have inserted this code.
oForm.Width = 400
oForm.Height = 300
Try
''// Adding Init Date field
oEdit = Nothing
oItem = Nothing
'oForm.DataSources.UserDataSources.Add("uIniDate", SAPbouiCOM.BoDataType.dt_DATE)
oForm.DataSources.UserDataSources.Add("U6", SAPbouiCOM.BoDataType.dt_DATE)
' +++++++++++++++++++++++++++++++++++++++++++++++++++++
' Adding a text box
'oItem = oForm.Items.Add("eIniDate", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem = oForm.Items.Add("B6", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem.Left = 120
oItem.Top = 120
oItem.Width = 80
oItem.Height = 20
oItem.Enabled = True
oItem.Description = "Init Date"
' +++++++++++++++++++++++++++++++++++++++++++++++++++++
oEdit = oItem.Specific
'oEdit.DataBind.SetBound(True, "", "uIniDate")
oEdit.DataBind.SetBound(True, "", "U6")
' +++++++++++++++++++++++++++++++++++++++++++++++++++++
Dim dtIni As Date = DateTime.Now
oEdit.Value = _
Microsoft.VisualBasic.Strings.Format(dtIni.Year, "0000") & _
Microsoft.VisualBasic.Strings.Format(dtIni.Month, "00") & _
Microsoft.VisualBasic.Strings.Format(dtIni.Day, "00")
' +++++++++++++++++++++++++++++++++++++++++++++++++++++
oEdit = Nothing
Catch ex As Exception
Dim s As String = ex.Message
Finally
oEdit = Nothing
oItem = Nothing
End Try
oForm.Visible = True
HTH
BR
Sierdna S.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tamil,
I would never use the oEditText.String-Property because it's format depends on the user settings. You would always need to check what the actual display B1-user-setting for date is and then format the date accordingly. But this complicates things too much.
Instead I would use...
1. UserDataSource.ValueEx
Independent from display, language or whatever settings you can set this with a date (as a string!) in format "20080918"
Since a RecordSet gives a real .NET-DateTime Value in case of a date-column you need a function
DateToYYYYMMDDString (ByVal myDate as system.datetime) As String
to cover this (should be no problem ;-).
For Double-Values (EditText is bound to UserDataSourc of type price, quantity...) you must always set a string in format "2349.45" (decimal seperator is always a dot also when the user has defined a "#" as dec.-sep!
2. EditText.Value
The same as above!
You may also have a look at my answer here (same topic):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
After getting the date frm the database and setting the value in the edit text change the formate of the date, Cause when u get the date frm SQL u get it along with the time. U can use the folling to format the date.
date.ToString("mm/dd/yyyy")
Hope it helps,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.