Hi All,
I am using below code , But it does not work , why?
Private Function CreateUDOForm() As Boolean
Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD = Nothing
Dim oUDOFind As SAPbobsCOM.UserObjectMD_FindColumns = Nothing
Try
Dim index As Integer = GetSubMenuId("4352") + 1
oUserObjectMD = DirectCast(oApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD), SAPbobsCOM.UserObjectsMD)
oUserObjectMD.Code = "Hex"
oUserObjectMD.Name = "Hex Trip Details"
oUserObjectMD.TableName = "EAMIN_HTRIP1"
oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_Document
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.EnableEnhancedForm = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FatherMenuID = 4352
oUserObjectMD.MenuCaption = "Hex Trip"
oUserObjectMD.MenuUID = "Hex"
oUserObjectMD.Position = index
oUserObjectMD.FindColumns.ColumnAlias = "DocEntry"
oUserObjectMD.FindColumns.ColumnDescription = "DocEntry"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_PostingDate"
oUserObjectMD.FindColumns.ColumnDescription = "Posting Date"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_PrjCode"
oUserObjectMD.FindColumns.ColumnDescription = "Project Code"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_PrjName"
oUserObjectMD.FindColumns.ColumnDescription = "Project Name"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_ShfCode"
oUserObjectMD.FindColumns.ColumnDescription = "Shift Code"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_MacId"
oUserObjectMD.FindColumns.ColumnDescription = "Machine Code"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.ChildTables.TableName = "EAMIN_HTRIPd1"
oUserObjectMD.FormColumns.SetCurrentLine(0)
oUserObjectMD.FormColumns.FormColumnAlias = "U_StartTime"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "Start Time"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_EndTime"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "End Time"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_ValAdd"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "Value Added"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_TruId"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "truck Id"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_TruNo"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "Trip No"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_Reason"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "Reason"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_Remarks"
'ChildTable ColumnAlias
oUserObjectMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnDescription = "Remarks"
'ChildTable ColumnDescription
oUserObjectMD.FormColumns.SonNumber = 1
' ChildTable SonNumber
oUserObjectMD.FormColumns.Add()
If oUserObjectMD.Add() <> 0 Then
' Throw New Exception(oApplication.Company.GetLastErrorDescription)
End If
Catch ex As Exception
'Throw ex
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
oUserObjectMD = Nothing
GC.WaitForPendingFinalizers()
GC.Collect()
End Try
Return True
End Function
Hi Lakshmi,
It looks fine but you have to post the errorcode and the error description.
A silly question... the tables have the proper type? eg table EAMIN_HTRIP1 have to be MasterData or Document and the table EAMIN_HTRIPd1 have to Master Data Lines or Document lines
Kind Regards
Evangelos D. Plagianos
hi Evangelos D. Plagianos,
I tried it , but The UDO form is not open after REOPEN SAP Business One.
this is my Code
Private Sub CreateUDO()
Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD = Nothing
Dim oUDOFind As SAPbobsCOM.UserObjectMD_FindColumns = Nothing
Dim oUDOForm As SAPbobsCOM.UserObjectMD_FormColumns = Nothing
Try
'Dim index As Integer = GetSubMenuId("43525") + 2
oUserObjectMD = DirectCast(oApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD), SAPbobsCOM.UserObjectsMD)
oUDOFind = oUserObjectMD.FindColumns
oUDOForm = oUserObjectMD.FormColumns
oUserObjectMD.Code = "EAHex"
oUserObjectMD.Name = "Header"
oUserObjectMD.TableName = "EAMIN_HTRIP2"
oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_Document
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.EnableEnhancedForm = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.RebuildEnhancedForm = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FatherMenuID = 43525
oUserObjectMD.MenuCaption = "Hex Trip Details"
oUserObjectMD.MenuUID = "TeHEX"
oUserObjectMD.Position = 13
oUserObjectMD.UseUniqueFormType = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tNO
'' FORM FIELDS
oUDOForm.Add()
oUDOForm.FormColumnAlias = "DocEntry"
oUDOForm.FormColumnDescription = "DocEntry"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.Add()
oUDOForm.FormColumnAlias = "U_PostingDate"
oUDOForm.FormColumnDescription = "Posting Date"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.Add()
oUDOForm.FormColumnAlias = "U_PrjCode"
oUDOForm.FormColumnDescription = "Project Code"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.Add()
oUDOForm.FormColumnAlias = "U_PrjName"
oUDOForm.FormColumnDescription = "Project Name"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.Add()
oUDOForm.FormColumnAlias = "U_ShfCode"
oUDOForm.FormColumnDescription = "Shift Code"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.Add()
oUDOForm.FormColumnAlias = "U_MacId"
oUDOForm.FormColumnDescription = "Machine Code"
oUDOForm.Add()
'' FIND COLUMNS
oUDOFind.ColumnAlias = "DocEntry"
oUDOFind.ColumnDescription = "DocEntry"
oUDOFind.Add()
oUDOFind.ColumnAlias = "U_PostingDate"
oUDOFind.ColumnDescription = "Posting Date"
oUDOFind.Add()
oUDOFind.ColumnAlias = "U_PrjCode"
oUDOFind.ColumnDescription = "Project Code"
oUDOFind.Add()
oUDOFind.ColumnAlias = "U_PrjName"
oUDOFind.ColumnDescription = "Project Name"
oUDOFind.Add()
oUDOFind.ColumnAlias = "U_ShfCode"
oUDOFind.ColumnDescription = "Shift Code"
oUDOFind.Add()
oUDOFind.ColumnAlias = "U_MacId"
oUDOFind.ColumnDescription = "Machine Code"
oUDOFind.Add()
'' Child Table
oUserObjectMD.ChildTables.TableName = "EAMIN_HTRIPd2"
oUDOForm.Add()
oUDOForm.SetCurrentLine(0)
oUDOForm.FormColumnAlias = "U_StartTime"
oUDOForm.FormColumnDescription = "Start Time"
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
oUDOForm.SetCurrentLine(1)
oUDOForm.FormColumnAlias = "U_EndTime"
oUDOForm.FormColumnDescription = "End Time"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
oUDOForm.SetCurrentLine(2)
oUDOForm.FormColumnAlias = "U_ValAdd"
oUDOForm.FormColumnDescription = "Value Added"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
oUDOForm.SetCurrentLine(3)
oUDOForm.FormColumnAlias = "U_TruId"
oUDOForm.FormColumnDescription = "Truck Id"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
oUDOForm.SetCurrentLine(4)
oUDOForm.FormColumnAlias = "U_TruNo"
oUDOForm.FormColumnDescription = "Trip No"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
oUDOForm.SetCurrentLine(5)
oUDOForm.FormColumnAlias = "U_Reason"
oUDOForm.FormColumnDescription = "Reason"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
oUDOForm.SetCurrentLine(6)
oUDOForm.FormColumnAlias = "U_Remarks"
oUDOForm.FormColumnDescription = "Remarks"
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES
oUDOForm.SonNumber = 1
oUserObjectMD.FormColumns.Add()
oUDOForm.Add()
If oUserObjectMD.Add() <> 0 Then
' Throw New Exception(oApplication.Company.GetLastErrorDescription)
End If
Catch ex As Exception
' Throw ex
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
oUserObjectMD = Nothing
GC.WaitForPendingFinalizers()
GC.Collect()
End Try
End Sub
Code runs successfully.
Add a comment