cancel
Showing results for 
Search instead for 
Did you mean: 

LoadBatchActions XML Date Parasing

Former Member
0 Kudos

We are using LoadBatchActions to populate a matrix with data in a single call by passing an XML document, but we have noticed that in B1 2005, date columns in the matrix seem to parse the date wrong. When you have the date format set to DD/Month/YYYY then it expects a month name in the XML date value instead of the neutral YYYYMMDD format. I thought XML was supposed to be a language-neutral format, and that data passed to B1 was supposed to be in a language-neutral format. Is there an error here?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Ben,

Have you checked your local setting of SAP Business One?

HTH,

Nick

Former Member
0 Kudos

That's the problem. Local settings should not affect data format at this level. I can work around it by changing the string according to the local settings, but data formats are supposed to be locale-agnostic.

The following code demonstrates the problem. This code should work no matter what the local settings are, but it fails when using DD/Month/YYYY format:

[code]

Sub CreateDateMatrix()

Dim frm As SAPbouiCOM.Form

Dim cp As SAPbouiCOM.FormCreationParams

Set cp = sboApp.CreateObject(cot_FormCreationParams)

cp.FormType = "FSE_TestDate"

cp.BorderStyle = fbs_Sizable

Set frm = sboApp.Forms.AddEx(cp)

frm.Visible = True

Dim mtxItem As SAPbouiCOM.Item

Set mtxItem = frm.Items.Add("Matrix", it_MATRIX)

mtxItem.Left = 10

mtxItem.Top = 10

mtxItem.Width = frm.ClientWidth - 20

mtxItem.Height = frm.ClientHeight - 20

Dim ds As SAPbouiCOM.UserDataSource

Set ds = frm.DataSources.UserDataSources.Add("DateDS", dt_DATE)

Dim mtx As SAPbouiCOM.Matrix

Set mtx = mtxItem.Specific

mtx.Columns.Add("RowMark", it_EDIT).Editable = False

With mtx.Columns.Add("Date", it_EDIT)

.Editable = -False

.DataBind.SetBound True, , "DateDS"

.Width = 100

.TitleObject.Caption = "Date"

End With

Dim populate As String

populate = "<Application><forms><action type=""update"">" & _

"<form uid=""" & frm.UniqueID & """>"

populate = populate & "<items><action type=""update"">" & _

"<Item uid=""Matrix"">"

populate = populate & "<Specific><rows><action type=""add"">"

Const rowCount As Integer = 5

Dim i As Integer

For i = 1 To rowCount

populate = populate & "<row index=""" & CStr(i) & """ />"

Next

populate = populate & "</action><action type=""update"">"

Dim dateString As String

For i = 1 To rowCount

dateString = Format$(Now + i, "yyyyMMdd")

populate = populate & "<row index=""" & CStr(i) & """>" & _

"<column uid=""Date"" string=""" & dateString & """ /></row>"

Next

populate = populate & "</action></rows></Specific></Item></action>" & _

"</items></form></action></forms></Application>"

sboApp.LoadBatchActions populate

MsgBox sboApp.GetLastBatchResults

End Sub

[/code]