cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric conversion error

Former Member
0 Kudos

Hello everybody,

Good Day to all.

I have a very strange problem in my UDF. I have a Matrix whitch is bound to a Table data source like this:


        Table = oForm.DataSources.DataTables.Add("Lines")
        Table.Columns.Add("ID", SAPbouiCOM.BoFieldsType.ft_Integer)
        Table.Columns.Add("DocEntry", SAPbouiCOM.BoFieldsType.ft_Integer)
        Table.Columns.Add("DocNum", SAPbouiCOM.BoFieldsType.ft_AlphaNumeric, 255)
        Table.Columns.Add("codi_loca", SAPbouiCOM.BoFieldsType.ft_AlphaNumeric, 10)
        Table.Columns.Add("codi_arti", SAPbouiCOM.BoFieldsType.ft_AlphaNumeric, 25)
        Table.Columns.Add("quan_movi", SAPbouiCOM.BoFieldsType.ft_Float)
        Table.Columns.Add("data_tran", SAPbouiCOM.BoFieldsType.ft_Date)
        Table.Columns.Add("hora_tran", SAPbouiCOM.BoFieldsType.ft_Date)

        Matrix = oForm.Items.Item("6").Specific
        Column = Matrix.Columns.Item("V_-1")
        Column.DataBind.Bind("Lines", "ID")
        Column = Matrix.Columns.Item("V_0")
        Column.DataBind.Bind("Lines", "DocNum")
        Column = Matrix.Columns.Item("V_1")
        Column.DataBind.Bind("Lines", "codi_loca")
        Column = Matrix.Columns.Item("V_2")
        Column.DataBind.Bind("Lines", "codi_arti")
        Column = Matrix.Columns.Item("V_3")
        Column.DataBind.Bind("Lines", "quan_movi")

I then fill the table using this SQL


        Dim Matrix As SAPbouiCOM.Matrix
        Dim Table As SAPbouiCOM.DataTable
        Dim SQL As String = ""
        SQL += "DECLARE @Lines TABLE(" & vbNewLine
        SQL += "            ID INT IDENTITY(1,1) PRIMARY KEY NOT NULL," & vbNewLine
        SQL += "      DocEntry INT," & vbNewLine
        SQL += "        DocNum NVARCHAR(255)," & vbNewLine
        SQL += "     codi_loca NVARCHAR(10)," & vbNewLine
        SQL += "     codi_arti NVARCHAR(25)," & vbNewLine
        SQL += "     quan_movi DECIMAL(19,6)," & vbNewLine
        SQL += "     data_tran DATETIME," & vbNewLine
        SQL += "     hora_tran DATETIME)" & vbNewLine
        SQL += "INSERT INTO @Lines(DocEntry, DocNum, codi_loca, codi_arti, quan_movi, data_tran, hora_tran)" & vbNewLine
        SQL += "SELECT T0.DocEntry," & vbNewLine
        SQL += "       T1.SeriesName + '\' + convert(nvarchar, T0.DocNum) as DocNum," & vbNewLine
        SQL += "       T2.codi_loca," & vbNewLine
        SQL += "       T2.codi_arti," & vbNewLine
        SQL += "       T2.quan_movi," & vbNewLine
        SQL += "       T2.data_tran," & vbNewLine
        SQL += "       T2.hora_tran" & vbNewLine
        SQL += "  FROM ORDR T0 INNER JOIN" & vbNewLine
        SQL += "       NNM1 T1 ON (T0.Series = T1.Series) INNER JOIN" & vbNewLine
        SQL += "       EXTERNALDATABASE.dbo.zz_historico_movimento_artigo T2 ON (T1.SeriesName + '\' + convert(nvarchar, T0.DocNum) = T2.nume_docu)" & vbNewLine
        SQL += " WHERE T2.tipo_docu = 'OE'" & vbNewLine
        SQL += "   AND T2.codi_tran = 'SC'" & vbNewLine
        SQL += "   AND T0.DocStatus = 'O'" & vbNewLine
        SQL += "   AND T0.DocEntry = 449" & vbNewLine
        SQL += " ORDER BY T2.codi_loca" & vbNewLine
        SQL += "SELECT ID, DocEntry, DocNum, codi_loca, codi_arti, quan_movi, data_tran, hora_tran from @Lines order by codi_loca" & vbNewLine

        Table = oForm.DataSources.DataTables.Item("Lines")
        Table.ExecuteQuery(SQL)
        Matrix = oForm.Items.Item("6").Specific
        Matrix.LoadFromDataSource()

The Data is beeing loaded correcty and the numeric values are ok in the Table,

But on the SAP BO Application the quan_movi column insted of displaying numbres, it displays funny characters

Like you can see on this [PrintScreen|http://i283.photobucket.com/albums/kk291/hyperbyte2/SAPJap.jpg]

Can any one find anything wrong with my code that explains the numeric conversion failure.

Thanks in Advance

Pedro Gomes

SINFIC SA

Accepted Solutions (1)

Accepted Solutions (1)

Nussi
Active Contributor
0 Kudos

Hi Pedro,

first of all - official it is not allowed to move data with recordsets. if you want to license your addon you will have problems.

second - split the query.

"move" the data in a own recordset and be sure that your executequery only contains the raw select.

the last step is to control if the data you receive from the fields is the same type like the defined column.

regards

David

Answers (0)