cancel
Showing results for 
Search instead for 
Did you mean: 

How to import to UDT

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Tao Iao

Search this forum for "Import UDO".

Also look these threads:

- [Export & Import UDO's to/from XML|;

- [Import Data to UDO|;

- [MSEXCEL TO UDT TRANSFERING DATA...|;

Hope these notes can help you.

Regards

Sierdna S.

Nussi
Active Contributor
0 Kudos

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