Skip to Content
0

Add Child Table UDO

Sep 04, 2017 at 06:59 AM

83

avatar image

Dear All,

I am trying to Create UDO using SAP Business One SDK. But UDO is not properly adding Child Table(s).My Code is given below.

''' <summary> ''' To Create Consultant Master in UDO ''' </summary> ''' <param name="strFatherID">Pass Father ID</param> ''' <returns></returns> ''' <remarks></remarks> Friend Function ConsultantMasterUDO(ByVal strFatherID As String) As Boolean '*************************************************** ' Declare Local Variabels '*************************************************** Dim lRetCode As Integer = 0 '' To Get UDO Registered or Not Dim oResult As Boolean '' To Get Function successfully executed Or not [True - Successfully executed ; False - Failed Executed] Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD = Nothing '' Declare User Object for Create UDO '*************************************************** 'Object Intialization '*************************************************** oUserObjectMD = oApplication.SapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD) '' Intialize UDO Object for SAP login Company '*************************************************** Try '*************************************************** '' To Check UDO Unique Id Exists Or Not ' IF Exists , you need to Update UDO else Add '*************************************************** If Not oUserObjectMD.GetByKey("StyConMas") Then '*************************************************** ' Set Setting for UDO like [Cancel,Close,CreateDefaultForm,Delete,Find and SO On] '*************************************************** oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.Code = "StyConMas" oUserObjectMD.Name = "Consultant Master Details" oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData '' To Set Object Type Based on your Table Type oUserObjectMD.TableName = "STY_OCSM" '' TO Pass Header Table Name '************************************************************** ' Handle Menu '' TO Check Father ID Exists Or Not '************************************************************** If CheckMenuIdExists(strFatherID) Then Dim subMenuID As Integer = GetSubMenuId(strFatherID) oUserObjectMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.MenuUID = "StyMnuCM" oUserObjectMD.MenuCaption = "Consultant Master Details" oUserObjectMD.Position = subMenuID oUserObjectMD.FatherMenuID = strFatherID '************************************************************** '' To Find Form Column '' Add Find Column [What you want] '************************************************************** oUserObjectMD.FindColumns.ColumnAlias = "Code" oUserObjectMD.FindColumns.ColumnDescription = "Code" oUserObjectMD.FindColumns.Add() oUserObjectMD.FindColumns.ColumnAlias = "Name" oUserObjectMD.FindColumns.ColumnDescription = "Name" oUserObjectMD.FindColumns.Add() ''**************************************************************************** '' To Add Form Column '' Add Form Column [What you want] - Header '************************************************************** oUserObjectMD.FormColumns.FormColumnAlias = "Code" oUserObjectMD.FormColumns.FormColumnDescription = "Consultant ID" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tNO oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "Name" oUserObjectMD.FormColumns.FormColumnDescription = "Consultant Name" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_St_Con_Per" oUserObjectMD.FormColumns.FormColumnDescription = "Styro Contact Person" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_Grade" oUserObjectMD.FormColumns.FormColumnDescription = "Grade" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_Releation" oUserObjectMD.FormColumns.FormColumnDescription = "Releation" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_Fax" oUserObjectMD.FormColumns.FormColumnDescription = "Fax Number" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_Email" oUserObjectMD.FormColumns.FormColumnDescription = "EMail ID" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_WebSite" oUserObjectMD.FormColumns.FormColumnDescription = "Web Site" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_StrAdd" oUserObjectMD.FormColumns.FormColumnDescription = "Street Address" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_tel" oUserObjectMD.FormColumns.FormColumnDescription = "Telephone Number" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_MobNum" oUserObjectMD.FormColumns.FormColumnDescription = "Mobile Number" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_POBox" oUserObjectMD.FormColumns.FormColumnDescription = "Post Box Number" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_City" oUserObjectMD.FormColumns.FormColumnDescription = "City Name" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() oUserObjectMD.FormColumns.FormColumnAlias = "U_Country" oUserObjectMD.FormColumns.FormColumnDescription = "Country Name" oUserObjectMD.FormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.FormColumns.Add() ''**************************************************************************** oUserObjectMD.EnableEnhancedForm = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.RebuildEnhancedForm = SAPbobsCOM.BoYesNoEnum.tYES ''**************************************************************************** '' Add Child Table --STY_CSM1 ''**************************************************************************** oUserObjectMD.ChildTables.TableName = "STY_CSM1" oUserObjectMD.ChildTables.Add() 'oUserObjectMD.FormColumns.SonNumber = 1 oUserObjectMD.FormColumns.SetCurrentLine(1) oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_PrjCode" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Project Code" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 1 oUserObjectMD.EnhancedFormColumns.ChildNumber = 1 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_PrjName" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Project Name" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 2 oUserObjectMD.EnhancedFormColumns.ChildNumber = 1 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_VisDate" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Date Of Visit" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 3 oUserObjectMD.EnhancedFormColumns.ChildNumber = 1 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_Remarks" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Remarks" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 4 oUserObjectMD.EnhancedFormColumns.ChildNumber = 1 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_Remarks1" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "ToDo" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 5 oUserObjectMD.EnhancedFormColumns.ChildNumber = 1 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_VisDate1" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Next Visit Date" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 6 oUserObjectMD.EnhancedFormColumns.ChildNumber = 1 oUserObjectMD.EnhancedFormColumns.Add() ''**************************************************************************** '' Add Child Table --STY_CSM2 ''**************************************************************************** oUserObjectMD.ChildTables.TableName = "STY_CSM2" oUserObjectMD.ChildTables.Add() oUserObjectMD.FormColumns.SetCurrentLine(1) oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_ConName" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Contact Person Name" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 1 oUserObjectMD.EnhancedFormColumns.ChildNumber = 2 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_Position" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Position" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 2 oUserObjectMD.EnhancedFormColumns.ChildNumber = 2 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_tel" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Telephone Number" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 3 oUserObjectMD.EnhancedFormColumns.ChildNumber = 2 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_MobNum" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "Mobile Number" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 4 oUserObjectMD.EnhancedFormColumns.ChildNumber = 2 oUserObjectMD.EnhancedFormColumns.Add() oUserObjectMD.EnhancedFormColumns.ColumnAlias = "U_Email" oUserObjectMD.EnhancedFormColumns.ColumnDescription = "EMail Id" oUserObjectMD.EnhancedFormColumns.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.Editable = BoYesNoEnum.tYES oUserObjectMD.EnhancedFormColumns.ColumnNumber = 5 oUserObjectMD.EnhancedFormColumns.ChildNumber = 2 oUserObjectMD.EnhancedFormColumns.Add() lRetCode = oUserObjectMD.Add() If lRetCode <> 0 Then Message(oApplication.SapCompany.GetLastErrorDescription(), SAPbouiCOM.BoStatusBarMessageType.smt_Error) Else Message("Please close your SAP application to Apply registered object.", SAPbouiCOM.BoStatusBarMessageType.smt_Error) End If End If End If Catch ex As Exception oResult = False Finally oUserObjectMD = Nothing End Try Return oResult End Function

I used above code .it works fine ,But Child Table Field names are not checked on the Screen.Please refer 2 Modifying fields for a child table and 3 Modifying fields for a child table File(s).Please let em know any mistakes on my code. Please correct me.

3modifying-fields-for-a-child-table-default-form-c.jpg2modifying-fields-for-a-child-table-default-form-c.jpg1linking-additional-child-user-tables.jpg

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers