Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Register UDO

Hello to all. I am trying to register an UDO, need that sera a form for fault, and when I put the option, it me does not recognize. Here this one the code. If someone knows since solving it I will be grateful for it to him.

Private Shared Sub BPAR10(ByVal oCompany As SAPbobsCOM.Company)

Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD

oUserObjectMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)

If oUserObjectMD.GetByKey("BPAR10") = 0 Then

oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.FormColumns.

oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO

oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES

'Columnas que debe traer la grilla

oUserObjectMD.FindColumns.ColumnAlias = "DocEntry"

oUserObjectMD.FindColumns.Add()

oUserObjectMD.FindColumns.SetCurrentLine(1)

oUserObjectMD.FindColumns.ColumnAlias = "DocNum"

oUserObjectMD.FindColumns.Add()

oUserObjectMD.FindColumns.SetCurrentLine(2)

oUserObjectMD.FindColumns.ColumnAlias = "U_TGV_FVATWD_CARDCOD"

oUserObjectMD.FindColumns.Add()

oUserObjectMD.FindColumns.SetCurrentLine(3)

oUserObjectMD.FindColumns.ColumnAlias = "U_TGV_FVATWD_DATE"

oUserObjectMD.FindColumns.Add()

oUserObjectMD.FindColumns.SetCurrentLine(4)

oUserObjectMD.FindColumns.ColumnAlias = "U_TGV_FVATWD_RET_TYP"

oUserObjectMD.FindColumns.Add()

oUserObjectMD.FindColumns.SetCurrentLine(5)

oUserObjectMD.FindColumns.ColumnAlias = "U_TGV_FVATWD_PAYORD"

oUserObjectMD.FindColumns.Add()

oUserObjectMD.LogTableName = ""

'Nombre de la tabla hija si es que tiene

oUserObjectMD.ChildTables.TableName = "TGV_TVATWD_DOCHIS"

oUserObjectMD.UseUniqueFormType = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.ExtensionName = ""

oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES

oUserObjectMD.Code = "BPAR10"

oUserObjectMD.Name = "Certificados de RetenciĆ³n (IVA)"

oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_Document

oUserObjectMD.TableName = "TGV_TVATWD_DOCS"

If oUserObjectMD.Add() <> 0 Then

Dim ErrMsg As String

Dim ErrCode As Long

oCompany.GetLastError(ErrCode, ErrMsg)

MsgBox("Error Registrando UDO BPAR10" & vbCrLf & ErrMsg)

System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)

oUserObjectMD = Nothing

End If

Else

MsgBox("El UDO BPAR10 ya existe.")

End If

System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)

End Sub

Edited by: Andres Blanco on Oct 17, 2008 9:32 PM

replied

Hi

See this working example.

Private Sub Add_UDO(ByVal c_UDO As CUdo)

  Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD
  Try

      Dim lErrCode As Long = 0
      Dim sErrMsg As String = ""

      oUserObjectMD = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)

      If oUserObjectMD.GetByKey(c_UDO.Code) = 0 Then

	  ' General Information
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  oUserObjectMD.Code = c_UDO.Code ' "UDOBDGM"
	  oUserObjectMD.Name = c_UDO.Name ' "Budget Mensile"
	  oUserObjectMD.ObjectType = c_UDO.ObjectType ' SAPbobsCOM.BoUDOObjType.boud_MasterData
	  oUserObjectMD.TableName = c_UDO.TableName ' "O01_BDGTEM"

	  ' Services
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  oUserObjectMD.CanCancel = c_UDO.CanCancel
	  oUserObjectMD.CanClose = c_UDO.CanClose
	  oUserObjectMD.CanCreateDefaultForm = c_UDO.CreateDefaultForm
	  oUserObjectMD.CanDelete = c_UDO.CanDelete
	  oUserObjectMD.CanFind = c_UDO.CanFind
	  oUserObjectMD.CanYearTransfer = c_UDO.CanYearTransfer
	  oUserObjectMD.ManageSeries = c_UDO.ManageSeries

	  ' Log
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  If c_UDO.LogTableName.Equals("") Then
	      oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO
	      oUserObjectMD.LogTableName = ""
	  Else
	      oUserObjectMD.CanLog = c_UDO.CanLog
	      oUserObjectMD.LogTableName = c_UDO.LogTableName
	  End If

	  ' DLL Extension Name
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  oUserObjectMD.ExtensionName = c_UDO.ExtensionName

	  ' Find Columns
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  Dim i As Integer = 0
	  oUserObjectMD.FindColumns.SetCurrentLine(i)
	  oUserObjectMD.FormColumns.FormColumnAlias = "Code"
	  For Each sColName As String In c_UDO.FindFields
	      If Not sColName.Equals("Code") Then
		  i += 1
		  Call oUserObjectMD.FindColumns.Add()
		  oUserObjectMD.FindColumns.SetCurrentLine(i)
		  oUserObjectMD.FindColumns.ColumnAlias = sColName
	      End If
	  Next

	  ' Child Tables
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  If Not oUserObjectMD.ChildTables.Count = 0 _
	  And Not c_UDO.Children Is Nothing _
	  Then
	      If c_UDO.Children.Count > 0 Then
		  Dim oUserObjectMD_ChildTables As SAPbobsCOM.UserObjectMD_ChildTables
		  oUserObjectMD_ChildTables = oUserObjectMD.ChildTables
		  i = -1
		  For Each sChildTable As String In c_UDO.Children
		      i += 1
		      If i > 0 Then
			  oUserObjectMD_ChildTables.Add()
		      End If
		      oUserObjectMD_ChildTables.SetCurrentLine(i)
		      oUserObjectMD_ChildTables.TableName = sChildTable
		  Next
	      End If
	  End If
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  ' ADD UDO +++
	  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	  If oUserObjectMD.Add() <> 0 Then
	      Call SBO_Company.GetLastError(lErrCode, sErrMsg)
	      Throw New Exception("ERROR: NEW UDO [" & c_UDO.Code & ":" & c_UDO.Name & "]: " & sErrMsg)
	  Else
	      Dim str As String = ""
	      str = "UDO [" & c_UDO.Code & ":" & c_UDO.Name & "] created correct."
	      log(str)
	      Application.DoEvents()
	  End If
      Else
	  Dim strMsg As String = "UDO [" & c_UDO.Code & ":" & c_UDO.Name & "] exist'."
	  log(strMsg)
	  Application.DoEvents()
      End If
  Catch ex As Exception
      Dim s As String = "ERRORE: " & ex.Message
      log(s)
  Finally
      If Not oUserObjectMD Is Nothing Then
	  System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
	  oUserObjectMD = Nothing
      End If
      System.GC.Collect()
  End Try

End Sub

Regards

Sierdna S.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question