on 10-20-2008 10:15 AM
Hi All!
I create UDT with name @MYUDT1 now I create button in UDT form (Open Form: Tool/User - Define Windows/ MYUDT1 ), When User Click it, will fill data into this UDT and data is get from Excel file. How to do it.?. Thanks
hi,
Dim xlApp As Excel.Application
Dim xlSht As Excel.Worksheet
Dim xlRng As Excel.Range
Dim oMatrix As SAPbouiCOM.Matrix
Dim ExcelSheetName As String
oMatrix = oformBQ.Items.Item("5").Specific
xlApp = New Excel.Application
xlApp.DisplayAlerts = False
Try
xlApp.Workbooks.Open("Path of ExcelFile")
Catch ex As Exception
SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
Exit Function
End Try
For i = 1 To xlApp.Sheets.Count
If UCase(xlApp.Sheets.Item(i).Name) = UCase("Name of ExcelSheet") Then
xlSht = xlApp.Sheets(i)
If xlSht.UsedRange.Rows.Count > 0 Then
Continue = SBO_Application.MessageBox("Do you want to load Data From ImportBOQ.xls File", 1, "Yes", "No")
If Continue = 1 Then
For r = 1 To xlSht.UsedRange.Rows.Count
oformBQ.Freeze(True)
oMatrix.AddRow()
Try
oedit = oMatrix.Columns.Item(0).Cells.Item(r).Specific
oedit.Value = oMatrix.RowCount
xlRng = xlSht.Cells(r, 1)
oedit = oMatrix.Columns.Item("A1").Cells.Item(r).Specific
oedit.Value = xlRng.Value
xlRng = xlSht.Cells(r, 2)
oedit = oMatrix.Columns.Item("1").Cells.Item(r).Specific
oedit.Value = xlRng.Value
xlRng = xlSht.Cells(r, 3)
oedit = oMatrix.Columns.Item("2").Cells.Item(r).Specific
oedit.Value = xlRng.Value
Catch ex As Exception
SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
End Try
oMatrix.SelectRow(r, True, False)
oform.Update()
Next
SBO_Application.StatusBar.SetText("Data loaded successfully", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
Exit Function
End If
Else
SBO_Application.StatusBar.SetText("No Data in Excel sheet " & RS.Fields.Item("PrjCode").Value, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
Exit Function
End If
End If
Next
regards,
varma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tao,
you should use the UserTable Object for adding the Data to the Table.
something like
SAPbobsCOM.UserTable UDT
UDT=Company.UserTables.Item("TableName")
UDT.Code ="newCode"
UDT.Name ="newName"
UDT.UserFields.Fields.Item("U_UDF").Value ="Value"
ErrCode=UDT.Add()
lg David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.