Dear Experts,
I have written code for UDO like below
Public Sub CreateUDOS()
Dim Ct(0) As String
ReDim Ct(1)
Ct(0) = "@INQ1"
createUDO("INQ", "INPQC", "INPQC", Ct, SAPbobsCOM.BoUDOObjType.boud_Document, False, True)
End Sub
Private Sub createUDO(ByVal tblname As String, ByVal udocode As String, ByVal udoname As String, ByVal childTable() As String, ByVal type As SAPbobsCOM.BoUDOObjType, Optional ByVal DfltForm As Boolean = False, Optional ByVal FindForm As Boolean = False)
Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD
Dim creationPackage As SAPbouiCOM.FormCreationParams
Dim objform As SAPbouiCOM.Form
Dim i As Integer
'Dim c_Yes As SAPbobsCOM.BoYesNoEnum = SAPbobsCOM.BoYesNoEnum.tYES
Dim lRetCode As Long
' Exit Sub
oUserObjectMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)
If Not oUserObjectMD.GetByKey(udocode) Then
oUserObjectMD.Code = udocode
oUserObjectMD.Name = udoname
oUserObjectMD.ObjectType = type
oUserObjectMD.TableName = tblname
' oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES
If DfltForm = True Then
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO
'oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FormColumns.FormColumnAlias = "Code"
oUserObjectMD.FormColumns.FormColumnDescription = "Code"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "Name"
oUserObjectMD.FormColumns.FormColumnDescription = "Name"
oUserObjectMD.FormColumns.Add()
End If
If FindForm = True Then
If type = SAPbobsCOM.BoUDOObjType.boud_Document Then
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FindColumns.ColumnAlias = "DocEntry"
oUserObjectMD.FindColumns.ColumnDescription = "DocEntry"
oUserObjectMD.FindColumns.Add()
End If
If udocode = "INPQC" Then
oUserObjectMD.FindColumns.ColumnAlias = "DocNum"
oUserObjectMD.FindColumns.ColumnDescription = "DocNum"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_itemcode"
oUserObjectMD.FindColumns.ColumnDescription = "Item Code"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_itemname"
oUserObjectMD.FindColumns.ColumnDescription = "Item Name"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_procno"
oUserObjectMD.FindColumns.ColumnDescription = "Process Card No"
oUserObjectMD.FindColumns.Add()
End If
End If
If childTable.Length > 0 Then
For i = 0 To childTable.Length - 2
If Trim(childTable(i)) <> "" Then
oUserObjectMD.ChildTables.TableName = childTable(i)
oUserObjectMD.ChildTables.Add()
End If
Next
End If
lRetCode = oUserObjectMD.Add()
If lRetCode <> 0 Then
Else
End If
If DfltForm = True Then
creationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
creationPackage.ObjectType = "1"
creationPackage.UniqueID = udoname
creationPackage.FormType = udoname
creationPackage.BorderStyle = SAPbouiCOM.BoFormTypes.ft_Fixed
objform = SBO_Application.Forms.AddEx(creationPackage)
End If
End If
End Sub
UDO is not being created. what might be the reason?