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
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.
Similar Messages
-
Using a Single Registered UDO for multiple Transactions
Dear Experts,
We are developing a Expense Booking System by using SAP B1 SDK. in .NET
The scenario is like this.
Need to book the expenses independently by using an Expense Booking Screen, and also from a Transaction screen (Sales) where the user enters the expenses details incurred during the sales activity.
Data from both the screens should be saved in a single User defined table.
ie, The Expense Booking Screen uses the table for direct saving and the Sales screen uses the same table as the child table of the transaction where the parent (header) table holds the details of Sales activity.
The table object is registered for the Direct Expense Booking screen.
Can I use the same object for the Sales Expense booking screen?
Is it possible?
If so, how can I implement it?
Please advice..
Thanks in advance
Regards,
TomsSure
Generic services are using to maintain UDO table using SDK. You no need to assign values to datasource items. You can simple collect the values from the form items / user data sources and update the UDO table accordingly.
First you go to this link
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d04b34b5-68cf-2b10-bc98-806feb4299ba
and download the DI GENERAL SERVICE SAMPLES
Applications with full source code is available for
1. Master Data UDO maintenance
2. Master Data UDO + Child Tables Maintenance
3. Document Data UDO maintenance
4. Document Data UDO + Child Tables Maintenance
Thank you
Anoop -
Hello. Upon registering the UDO says "Ref count for this object is higher then 0." Â What could be the problem?. Here is my code. Thank you.
Dim oUserObjectMD As SAPbobsCOM.UserObjectsMD
oUserObjectMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)
If oUserObjectMD.GetByKey("BPAR1") = 0 Then
'/ OUDO /
oUserObjectMD.Code = "BPAR1"
oUserObjectMD.Name = "Conceptos sujetos a Retención (IVA)"
oUserObjectMD.TableName = "TGV_TVATW_INSTAL"
oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData
oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.ExtensionName = ""
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO
oUserObjectMD.OverwriteDllfile = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.UseUniqueFormType = SAPbobsCOM.BoYesNoEnum.tYES
'/ UDO1 /
oUserObjectMD.ChildTables.TableName = "TGV_TVATW_INSHIS"
'/ UDO2 /
oUserObjectMD.FindColumns.ColumnAlias = "Code"
oUserObjectMD.FindColumns.ColumnDescription = "Id Concepto"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "Name"
oUserObjectMD.FindColumns.ColumnDescription = "Descripción"
oUserObjectMD.FindColumns.Add()
'/ UDO3 /
oUserObjectMD.FormColumns.SonNumber = "0"
oUserObjectMD.FormColumns.FormColumnAlias = "Code"
oUserObjectMD.FormColumns.FormColumnDescription = "Id Concepto"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.SonNumber = "0"
oUserObjectMD.FormColumns.FormColumnAlias = "Name"
oUserObjectMD.FormColumns.FormColumnDescription = "Descripción"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.SonNumber = "1"
oUserObjectMD.FormColumns.FormColumnAlias = "U_TGV_FVATW_CODE"
oUserObjectMD.FormColumns.FormColumnDescription = "Cod. Regimen"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.SonNumber = "1"
oUserObjectMD.FormColumns.FormColumnAlias = "U_TGV_FVATW_IDVALUE"
oUserObjectMD.FormColumns.FormColumnDescription = "Valor Alicuota IVA disc."
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.SonNumber = "1"
oUserObjectMD.FormColumns.FormColumnAlias = "U_TGV_FVATW_NDVALUE"
oUserObjectMD.FormColumns.FormColumnDescription = "Valor Alicuota sin IVA disc."
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.SonNumber = "1"
oUserObjectMD.FormColumns.FormColumnAlias = "U_TGV_FVATW_INI_DATE"
oUserObjectMD.FormColumns.FormColumnDescription = "Fecha Desde"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.SonNumber = "1"
oUserObjectMD.FormColumns.FormColumnAlias = "U_TGV_FVATW_TAX_CODE"
oUserObjectMD.FormColumns.FormColumnDescription = "Fc B - Reproweb 2,4,5"
oUserObjectMD.FormColumns.Add()
If oUserObjectMD.Add() <> 0 Then
Dim ErrMsg As String = Nothing
Dim ErrCode As Long
oCompany.GetLastError(ErrCode, ErrMsg)
MsgBox("Error Registrando UDO BPAR1" & vbCrLf & ErrMsg)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
oUserObjectMD = Nothing
End If
End If
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
System.Windows.Forms.Application.DoEvents()Hi Andres,
Delete the second System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD) code line.
You should also put your code in a Try Catch Finally block, and release the oUserObjectMD object in the Finally statement.
Private Function RegisterNP(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application) As Boolean
RegisterNP = False
Dim oUserObjectMD As UserObjectsMD = oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD)
Dim lRetCode As Long
Try
If Not oUserObjectMD.GetByKey("ADAT_NP") Then
oUserObjectMD.Code = "ADAT_NP"
oUserObjectMD.Name = "Nota de Produção"
oUserObjectMD.ObjectType = BoUDOObjType.boud_Document
oUserObjectMD.TableName = "ADAT_ONP"
oUserObjectMD.CanCancel = BoYesNoEnum.tYES
oUserObjectMD.CanClose = BoYesNoEnum.tYES
oUserObjectMD.CanCreateDefaultForm = BoYesNoEnum.tNO
oUserObjectMD.CanDelete = BoYesNoEnum.tYES
oUserObjectMD.CanFind = BoYesNoEnum.tYES
oUserObjectMD.CanLog = BoYesNoEnum.tYES
oUserObjectMD.LogTableName = "AADAT_NP"
oUserObjectMD.CanYearTransfer = BoYesNoEnum.tYES
oUserObjectMD.ManageSeries = BoYesNoEnum.tYES
oUserObjectMD.ChildTables.TableName = "ADAT_NP1"
oUserObjectMD.ChildTables.LogTableName = "AADAT_NP1"
oUserObjectMD.ExtensionName = ""
oUserObjectMD.FindColumns.ColumnAlias = "DocNum"
oUserObjectMD.FindColumns.ColumnDescription = "Nº do Documento"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.SetCurrentLine(1)
oUserObjectMD.FindColumns.ColumnAlias = "Series"
oUserObjectMD.FindColumns.ColumnDescription = "Série"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_CardCode"
oUserObjectMD.FindColumns.ColumnDescription = "Código do PN"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_CardName"
oUserObjectMD.FindColumns.ColumnDescription = "Nome do PN"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_RefNum"
oUserObjectMD.FindColumns.ColumnDescription = "Nº de Ref. do Fornecedor"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FindColumns.ColumnAlias = "U_DataProd"
oUserObjectMD.FindColumns.ColumnDescription = "Data de Recepção"
oUserObjectMD.FindColumns.Add()
lRetCode = oUserObjectMD.Add()
'// Check for known errors
If lRetCode <> 0 Then
oApplication.MessageBox("RegisterNP(Add): " & lRetCode.ToString)
Else
RegisterNP = True
End If
End If
Catch ex As Exception
oApplication.MessageBox("RegisterNP(): " & oCompany.GetLastErrorCode & ", " & ex.ToString)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
oUserObjectMD = Nothing
lRetCode = Nothing
GC.Collect()
End Try
End Function
Regards,
Vítor Vieira -
Hi All,
I've created a simple form based on an registered UDO (2 tables: Document and Document Lines).
This form contains a matrix bounded to the lines of my UDO document.
Everything works fine except the Delete button that should delete a document line in the matrix: it never
deletes the lines from database, although it deletes them from the form. But if I select again the same
record, the deleted line is show again!
My code is very simple:
void btRemove_ClickEvent()
// Remove selected row from Matrix
SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix) oForm.Items.Item("mxMatrix").Specific;
int iPos = oMatrix.GetNextSelectedRow( 0, SAPbouiCOM.BoOrderType.ot_RowOrder );
if( iPos > -1 )
oMatrix.DeleteRow( iPos );
oMatrix.FlushToDataSource();
oForm.Update();
What is the problem with my code? Is it missing something?
Regards,
Manuel DiasThanks Gianluigi,
By the way, I want to delete the Matrix line with DI API has you suggest, so I was thinking in using this code:
SAPbobsCOM.UserTables pUT = Main.oSBOCompany.UserTables;
SAPbobsCOM.UserTable dt = pUT.Item("@PDWC_LINE");
bool xx = dt.GetByKey( sKey );
int res = dt.Remove();
The problem is that UserTable object, has a GetByKey() method that works only for user tables whose PK
contains only one column (GetByKey requires only a single value).
Since my table is created in SBO with the UDO Document Lines template, the PK is composed automatically
by Code and LineId columns, so the GetByKey() method does not allow me to select a specific record in
order to delete it next.
Do you know any workaround for this? Of course I could user the Recordsed object and write SQL to
delete my table line, but I think it must be an esay way to do this....
Regards,
Manuel Dias -
Dear Experts,
I'm going to develop a web application using DI Server. This application will be connected to a SAP Business One Company with registered UDOs.
Does anyone know if it is possible to manipulate UDOs data from DI Server?
On the 8.8 SDK Help center I find that "The DI Server uses the DI core to enable the same functionality provided by the DI API..." but I don't understand how insert/update/delete data from a specified User Defined Object.
Thank you.
Best Regards.
Paolo.Can people please start reading what the post actually says - he clearly asked about the DI server. Giving an answer about the DI API is not useful & the general service is not even exposed to the DI server so instead of helping this would have put the poster in the wrong direction.
All credit goes to Yatsea Li in this thread: Re: Simple DI Server Samples
Note: UDO name is used as xml element in DI Server, thus UDO name shouldn't contain space or other special char.
UDO Code: SAP_OMOV
UDO Name: SAP_OMOVName
UDO Main table: @SAP_OMOVIE
UDO Child table: @SAP_MOV1
UDFs in main table: Code, Name
UDFs in child table: Code, LindId, U_ItemCode, U_Qty
To add a record via UDO Service in DI Server:
<?xml version="1.0" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<MsgHeader xmlnsu2019u201Dhttp://www.sap.com/SBO/DISu201D>
<SessionID>sessionID</SessionID>
<ServiceName>SAP_OMOV</ServiceName>
</MsgHeader>
</soap:Header>
<soap:Body>
<Add xmlns=u201DSAP_MD">
<SAP_OMOVName xmlns=u201Dhttp://www.sap.com/SBO/DISu201D>
<Code>1</Code>
<Name>1</Name>
<SAP_MOV1Collection>
<SAP_MOV1>
<U_ItemCode>A00001</U_ItemCode>
<U_Qty>2</U_Qty>
</SAP_MOV1>
<SAP_MOV1>
<U_ItemCode>A00002</U_ItemCode>
<U_Qty>1</U_Qty>
</SAP_MOV1>
</SAP_MOV1Collection>
</SAP_OMOVName>
</Add>
</soap:Body>
</soap:Envelope> -
Hello Experts,
I want to register an existing SAP AddOn
C:\Program Files\SAP\SAP Business One SDK\Samples\UDO\MealOrder\MealOrderUI
How will I proceed?
Tell me the steps?
Will I have to change anything in the code of it?
Rgds
Subrata
Message was edited by:
Marc RiarHi,
User-defined Object (UDO) is a feature of SAP Business One application that enables partners to create their own business objects, and register them to the application, so that the user defined object becomes part of the application objects collection.
The steps to proceed are creating UDO, registering UDO, deploying UDO and or extending UDO functionality with business logic implementation.
Another info :
Use the User-Defined Objects to add new business logic or new objects to SAP Business One. These objects are created with the help of the SAP Business One existing functionality.
You can create the following types of objects:
· Master data. For example Business Partner
· Master data lines. For example, the Address in the Business Partner Master Data
· Documents. For example, the A/R Invoice
· Document line. For example, the Contents tab in the A/R Invoice
In addition, services for the new object can include history and log information.
To add a user-defined object, you must have a registration - the User-Defined Registration Wizard. As an option, we recommend the Object Implementation - currently we support C++ objects only.
Create a table before you create an object, and then link it during the registration. While you create the table, create an additional new field to set the table type. Additional fields, including all the default properties, are added by SAP Business One automatically.
To access the Registration Wizard, choose Tools --> User-Defined Objects --> Registration Wizard.
Let me know if you need more detail but I suggest you to learn the UDO from SDK help files.
Rgds,
JM -
Automatic Add UDO Document header & Lines Fields
Hello.
I have created a user defined table & also fields and then registered the UDO .
Now i want to automatic add data in that registered UDO through Code .
Is it possible to do this ?
Thanks & Regards,
AmitHi Amit,
Please see the following,
SAPbobsCOM.CompanyService oCompanyService = null;
SAPbobsCOM.GeneralService oGeneralService = null;
SAPbobsCOM.GeneralData oGeneralData = null;
SAPbobsCOM.GeneralDataCollection oChildren = null;
SAPbobsCOM.GeneralData oChild = null;
oCompanyService = oCompany.GetCompanyService();
oGeneralService = oCompanyService.GetGeneralService("UDPOPDN");
oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
oGeneralData.SetProperty("U_DocEntry", GRPO);//收货单号
oGeneralData.SetProperty("U_BaseEntry", dr["订单号"].ToString());//采购订单号
oGeneralData.SetProperty("U_BaseLine", dr["行号"].ToString());//采购订单行号
oGeneralData.SetProperty("U_CardCode", dr["客户编号"].ToString());//供应商编号
oGeneralData.SetProperty("U_CardName", dr["客户名称"].ToString());//供应商名称
oGeneralData.SetProperty("U_ItemCode", dr["物料编码"].ToString());//物料编号
oGeneralData.SetProperty("U_CardCode", dr["物料描述"].ToString());//物料名称
oGeneralData.SetProperty("U_Quantity", Convert.ToDouble(dr["入库重量"].ToString()));//入库重量
oGeneralData.SetProperty("U_FreWeight", Convert.ToDouble(dr["免费重量"].ToString()));//免费重量
//oGeneralData.SetProperty("U_TolWeight", Convert.ToDouble(dr["称重单位毛重"].ToString()));//称重单位毛重
oGeneralData.SetProperty("U_TolWeight", Convert.ToDouble(dr["毛重"].ToString()));//毛重
oGeneralData.SetProperty("U_Unit", Convert.ToDouble(dr["系数"].ToString()));//系数
//oGeneralData.SetProperty("U_PurWeight", Convert.ToDouble(dr["采购单位毛重"].ToString()));//采购单位毛重
oGeneralData.SetProperty("U_PacWeight", Convert.ToDouble(dr["包装"].ToString()));//包装
oGeneralData.SetProperty("U_DedWeight", Convert.ToDouble(dr["扣重"].ToString()));//扣重
oGeneralData.SetProperty("U_ScaleCode", globals_Renamed.gScaleCode);//磅秤编号
oGeneralData.SetProperty("U_ScaleUser", globals_Renamed.gUserCode);//过磅员
oChildren = oGeneralData.Child("U_DPPDN1");
foreach (DataRow drLine in globals_Renamed.gOrderInfo.Tables[dr["行号"].ToString()].Rows)
oChild = oChildren.Add();
oChild.SetProperty("U_LineNum", drLine["序号"].ToString());
oChild.SetProperty("U_Quantity", Convert.ToDouble(drLine["称重值"].ToString()));
oChild.SetProperty("U_Package", Convert.ToDouble(drLine["包装物"].ToString()));
oChild.SetProperty("U_ScaleTime", drLine["称重时间"].ToString());
SAPbobsCOM.GeneralDataParams oGeneralParams = null;
oGeneralParams = oGeneralService.Add(oGeneralData);
Best regards
Huan -
Adding Default Form while Registrasion of UDO
Hi....
I am facing problem while registering UDO using some VB.Net code.
the SAP shows object registed successfully.but
it doesn't create the default form.
Sample Code....
oUserObjectMD.Code = "AssetType"
oUserObjectMD.Name = "ASSET TYPE UDO"
oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData
oUserObjectMD.TableName ="AssetTable"
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES
oUserObjectMD.FindColumns.ColumnAlias = "Code"
oUserObjectMD.FindColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "Code"
oUserObjectMD.FormColumns.FormColumnDescription = "Code"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_AssType" oUserObjectMD.FormColumns.FormColumnDescription = "Asset Type"
oUserObjectMD.FormColumns.Add()
oUserObjectMD.FormColumns.FormColumnAlias = "U_AssName" oUserObjectMD.FormColumns.FormColumnDescription = "Asset Name"
oUserObjectMD.FormColumns.Add()
If oUserObjectMD.Add() <> 0 Then
Dim ErrMsg As String
Dim ErrCode As Long
muc_ParentAddon.SBO_Company.GetLastError(ErrCode, ErrMsg)
muc_ParentAddon.SBO_Application.MessageBox("Error Adding UDO's - " & mst_ErrNumber & ErrMsg) ', SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD)
oUserObjectMD = Nothing
Return False
End If
End If
UDO is Adding But I Am not getting Default Form.
Please Help....Dear Nageswar Venkat,
It seems like a sdk bug.
You could update the UDO in B1 client then the Default Form will appear.
Best Regards
Jane Jing
SAP Business One forums team -
Table Creation taking a lot of time in SAP 2007...
I have an SAP Addon which is created in SAP2005...Right now i changed the code to SAP 2007...But the Problem i am facing is, it takes a lot of time to created the usertabels thorugh SAP 2007 code...Around 5 minutes it takes....But i created the usertables through SAP 2005 less than 2 minutes....I ahve to create 18 usertables thorugh this code....
can anyone help me to solve this issue.. as well as i want to know whether any change is there in codes in SAP 2005 or SAP 2007.for creating Usertables....
My Code:
Private Sub AddUserTable(ByVal Name As String, ByVal Description As String, ByVal Type As SAPbobsCOM.BoUTBTableType)
Try
oUserTablesMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
If oUserTablesMD.GetByKey(Name) = False Then
oUserTablesMD.TableName = Name
oUserTablesMD.TableDescription = Description
oUserTablesMD.TableType = Type
lRetCode = oUserTablesMD.Add
If lRetCode 0 Then
'oCompany.GetLastError(lRetCode, sErrMsg)
'MsgBox(sErrMsg)
End If
End If
Catch ex As Exception
'pEve_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTablesMD)
End Try
End Sub
Waiting for Positive Reply...
Thanks
HariHi hari,
I suggest you create you user tables, fields, keys, permissions through XML.
Here's a sample:
<?xml version="1.0" encoding="UTF-16"?>
<BOM>
<BO>
<AdmInfo>
<Object>153</Object>
</AdmInfo>
<OUTB>
<row>
<TableName>TABLE_ID</TableName>
<Descr>TABLE_DESCRIPTION</Descr>
<ObjectType>1</ObjectType>
</row>
</OUTB>
</BO>
<BO>
<AdmInfo>
<Object>152</Object>
</AdmInfo>
<CUFD>
<row>
<TableID>@TABLE_ID</TableID>
<AliasID>FIELD_NAME</AliasID>
<Descr>FIELD_DESCRIPTION</Descr>
<TypeID>A</TypeID>
<EditType></EditType>
<Dflt></Dflt>
<EditSize>100</EditSize>
</row>
</CUFD>
<UFD1>
</UFD1>
</BO>
</BOM>
If you have already created the fields before (through code or through B1 UI), you can query the OUTB, CUFD and UFD1 tables to check what values you need to put in the XML file.
You can use the following function to process a single XML file with the definition of tables, fields, keys and permissions.
Public Function LoadBDFromXML(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, _
ByRef Directory As String, ByRef FileName As String) As Boolean
Dim sXmlFileName As String
Dim iElementCount As Long
Dim iCounter As Long
LoadBDFromXML = False
Try
'// Inicializar a barra de progresso, caso seja nada.
If BarraDeProgresso Is Nothing Then
BarraDeProgresso = oApplication.StatusBar.CreateProgressBar(UpdatingDB, 1, False)
End If
sXmlFileName = Directory & "" & FileName
iElementCount = oCompany.GetXMLelementCount(sXmlFileName)
BarraDeProgresso.Maximum = iElementCount
BarraDeProgresso.Value = 0
For iCounter = 0 To iElementCount - 1
oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode
Select Case oCompany.GetXMLobjectType(sXmlFileName, iCounter)
'// Tabela de Utilizador
Case BoObjectTypes.oUserTables
Dim oTable As SAPbobsCOM.UserTablesMD = oCompany.GetBusinessObjectFromXML(sXmlFileName, iCounter)
Try
BarraDeProgresso.Value += 1
BarraDeProgresso.Text = "UDT: " & oTable.TableDescription
If oTable.Add <> 0 Then
oApplication.MessageBox(TranslateStr(oApplication, ErrAddUDT) & vbCrLf & _
TranslateStr(oApplication, Error_) & oCompany.GetLastErrorCode.ToString & ", " & _
oCompany.GetLastErrorDescription & vbCrLf & TranslateStr(oApplication, Element) & _
iCounter & ", " & oTable.TableDescription)
Exit Function
End If
Catch ex As Exception
oApplication.MessageBox(TranslateStr(oApplication, Error_) & _
TranslateStr(oApplication, ErrUDT) & ", " & ex.ToString)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oTable)
oTable = Nothing
GC.Collect()
End Try
'// Campos de Utilizador
Case BoObjectTypes.oUserFields
Dim oFields As SAPbobsCOM.UserFieldsMD = oCompany.GetBusinessObjectFromXML(sXmlFileName, iCounter)
Try
BarraDeProgresso.Value += 1
BarraDeProgresso.Text = "UDF: " & oFields.TableName & "." & oFields.Name & " - " & oFields.Description
If oFields.Add <> 0 Then
oApplication.MessageBox(TranslateStr(oApplication, ErrAddUDF) & vbCrLf & _
TranslateStr(oApplication, Error_) & oCompany.GetLastErrorCode.ToString & ", " & _
oCompany.GetLastErrorDescription & vbCrLf & TranslateStr(oApplication, Element) & _
iCounter & ", " & oFields.Name)
Exit Function
End If
Catch ex As Exception
oApplication.MessageBox(TranslateStr(oApplication, Error_) & _
TranslateStr(oApplication, ErrUDF) & ", " & ex.ToString)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oFields)
oFields = Nothing
GC.Collect()
End Try
'// Chaves de Utilizador
Case BoObjectTypes.oUserKeys
Dim oKeys As SAPbobsCOM.UserKeysMD = oCompany.GetBusinessObjectFromXML(sXmlFileName, iCounter)
Try
BarraDeProgresso.Value += 1
BarraDeProgresso.Text = "UDKey: " & oKeys.KeyName & "(" & oKeys.TableName & ")"
If oKeys.Add <> 0 Then
oApplication.MessageBox(TranslateStr(oApplication, ErrAddUDK) & vbCrLf & _
TranslateStr(oApplication, Error_) & oCompany.GetLastErrorCode.ToString & ", " & _
oCompany.GetLastErrorDescription & vbCrLf & TranslateStr(oApplication, Element) & _
iCounter & ", " & oKeys.KeyName)
Exit Function
End If
Catch ex As Exception
oApplication.MessageBox(TranslateStr(oApplication, Error_) & _
TranslateStr(oApplication, ErrUDK) & ", " & ex.ToString)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oKeys)
oKeys = Nothing
GC.Collect()
End Try
'// Árvore de Autorizações
Case BoObjectTypes.oUserPermissionTree
Dim Tree As SAPbobsCOM.UserPermissionTree = oCompany.GetBusinessObjectFromXML(sXmlFileName, iCounter)
Try
BarraDeProgresso.Value += 1
BarraDeProgresso.Text = PermTree & Tree.Name
If Tree.Add <> 0 Then
oApplication.MessageBox(TranslateStr(oApplication, ErrAddUPT) & vbCrLf & _
TranslateStr(oApplication, Error_) & oCompany.GetLastErrorCode.ToString & ", " & _
oCompany.GetLastErrorDescription & vbCrLf & TranslateStr(oApplication, Element) & _
iCounter & ", " & Tree.Name)
Exit Function
End If
Catch ex As Exception
oApplication.MessageBox(TranslateStr(oApplication, Error_) & _
TranslateStr(oApplication, ErrUPT) & ", " & ex.ToString)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(Tree)
Tree = Nothing
GC.Collect()
End Try
'// Objectos de Utilizador
Case BoObjectTypes.oUserObjectsMD
Dim oUDO As SAPbobsCOM.UserObjectsMD = oCompany.GetBusinessObjectFromXML(sXmlFileName, iCounter)
Try
BarraDeProgresso.Value += 1
BarraDeProgresso.Text = "UDO: " & oUDO.Code & "(" & oUDO.Name & ")"
If oUDO.Add <> 0 Then
oApplication.MessageBox(TranslateStr(oApplication, ErrAddUDO) & vbCrLf & _
TranslateStr(oApplication, Error_) & oCompany.GetLastErrorCode.ToString & ", " & _
oCompany.GetLastErrorDescription & vbCrLf & TranslateStr(oApplication, Element) & _
iCounter & ", " & oUDO.Name)
Exit Function
End If
Catch ex As Exception
oApplication.MessageBox(TranslateStr(oApplication, Error_) & _
TranslateStr(oApplication, ErrUDO) & ", " & ex.ToString)
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUDO)
oUDO = Nothing
GC.Collect()
End Try
End Select
Next iCounter
If Not BarraDeProgresso Is Nothing Then
BarraDeProgresso.Stop()
BarraDeProgresso = Nothing
End If
LoadBDFromXML = True
Catch ex As Exception
If oCompany.InTransaction = True Then oCompany.EndTransaction(BoWfTransOpt.wf_RollBack)
oApplication.MessageBox("LoadBDFromXML(" & FileName & "): " & oCompany.GetLastErrorCode.ToString & ", " & ex.ToString)
End Try
End Function
Note: BarraDeProgresso is my progress bar.
You can also register UDO's through XML, but I prefer to do it by code.
Regards,
Vítor Vieira -
Viewing form in Preview Mode Failed. Error: Table not found [131-183]
Hi,
I have created a user form in screen painter in SBODemo. Created UDT, UDF & Registered UDO through my SDK code.
Everything works fine.
But when i run my addon on any other DB, and open my custom form it gives an error : Table Not Found.
I have checked the UDT's , UDF's & my UDO, all are in place and getting created in the DB.
I tried checking the Form again in screen painter everything is in line. But when i try preview in screen painter it gives an error
Viewing form in Preview Mode Failed. Error: Table not found [131-183].
I can't figure out the issue, i have checked my codes & forms many times.
Regards
Johnhi john smith,
Check your screen painter, probably some fields are defined without the "@" character in front.
for fields, check the "U_".
nd.Q -
Add row in Memu Event can't work
1:I create a Master UDO
2:Regist UDO with a child table
3:use UDO form generator tool to generate a UDO form with xml file
4:I use load from xml funtion to call form.
5. Add a buttom name "Add row" and have code with Add a row for matrix
I have two problems
one is,
I can add row by press "Add row" button and I can delete a row by UDO default menu("delete Row CtrlK"). My problem is why the default menu(Add Row CtrlI) don't work? May I write code for add a row by myself?
The other is
When I add menueven sub(catch menueven) in program ,my "Add row" buttom can't work normally. If I remove the menueven sub from my program, the "Add row" buttom work fine. Why? somebody help me.Hi Glen,
In my case, I developed own functionality to add row for a matrix.
I don't use 'add row' menu event actually.
And I don't know about menu event sub problems without any source code.
Regards,
Hyunil. -
How to Create CFL to user defined table
Hi all,
I have a user table with four fields. How to create a CFL for these fields?
Regards,
Fabio Ferreira.this is sub fn required for registration
Here i mentioned heder level table and child table
Fields are mentioned will be displayed on CFL
If u want assign this CFL to any text field assign normal way but object id is:VEDA_PRN_WR_DOC
Public Function UDOExists(ByVal code As String) As Boolean
GC.Collect()
Dim v_UDOMD As SAPbobsCOM.UserObjectsMD
Dim v_ReturnCode As Boolean
v_UDOMD = objMain.objUtilities.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)
v_ReturnCode = v_UDOMD.GetByKey(code)
System.Runtime.InteropServices.Marshal.ReleaseComObject(v_UDOMD)
v_UDOMD = Nothing
Return v_ReturnCode
End Function
'Second fn
Function registerUDO(ByVal UDOCode As String, ByVal UDOName As String, ByVal UDOType As SAPbobsCOM.BoUDOObjType, ByVal findAliasNDescription As String(,), ByVal parentTableName As String, Optional ByVal childTable1 As String = "", Optional ByVal childTable2 As String = "", Optional ByVal childTable3 As String = "", Optional ByVal LogOption As SAPbobsCOM.BoYesNoEnum = SAPbobsCOM.BoYesNoEnum.tNO) As Boolean
Dim actionSuccess As Boolean = False
Try
registerUDO = False
Dim v_udoMD As SAPbobsCOM.UserObjectsMD
v_udoMD = objMain.objUtilities.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)
v_udoMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tNO
v_udoMD.CanClose = SAPbobsCOM.BoYesNoEnum.tNO
v_udoMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO
v_udoMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES
v_udoMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
v_udoMD.CanLog = LogOption
v_udoMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES
v_udoMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES
v_udoMD.Code = UDOCode
v_udoMD.Name = UDOName
v_udoMD.TableName = parentTableName
If LogOption = SAPbobsCOM.BoYesNoEnum.tYES Then
v_udoMD.LogTableName = "A" & parentTableName
End If
v_udoMD.ObjectType = UDOType
For i As Int16 = 0 To findAliasNDescription.GetLength(0) - 1
If i > 0 Then v_udoMD.FindColumns.Add()
v_udoMD.FindColumns.ColumnAlias = findAliasNDescription(i, 0)
v_udoMD.FindColumns.ColumnDescription = findAliasNDescription(i, 1)
Next
If childTable1 <> "" Then
v_udoMD.ChildTables.TableName = childTable1
v_udoMD.ChildTables.Add()
End If
If childTable2 <> "" Then
v_udoMD.ChildTables.TableName = childTable2
v_udoMD.ChildTables.Add()
End If
If childTable3 <> "" Then
v_udoMD.ChildTables.TableName = childTable3
v_udoMD.ChildTables.Add()
End If
If v_udoMD.Add() = 0 Then
registerUDO = True
objMain.objApplication.StatusBar.SetText("Successfully Registered UDO >" & UDOCode & ">" & UDOName & " >" & objMain.objCompany.GetLastErrorDescription, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
Else
objMain.objApplication.StatusBar.SetText("Failed to Register UDO >" & UDOCode & ">" & UDOName & " >" & objMain.objCompany.GetLastErrorDescription, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
registerUDO = False
End If
System.Runtime.InteropServices.Marshal.ReleaseComObject(v_udoMD)
v_udoMD = Nothing
GC.Collect()
Catch ex As Exception
End Try
End Function
This is a code for registration of table that will create CFL with mentioned fields.
Hope help this
By
firos.C
Edited by: firoz101 on Aug 18, 2009 6:07 AM
Edited by: firoz101 on Aug 18, 2009 6:08 AM
Edited by: firoz101 on Aug 18, 2009 6:08 AM -
How to make a choose list with UDF
Hi,
I want add a choose list in matrix
this choose list is a sql
"SELECT Code,Name FROM ""@SIR_COMPOSANT"" ORDER BY Name" for example
my code is
Dim oCFLs As SAPbouiCOM.ChooseFromListCollection
Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams
Dim oCFL As SAPbouiCOM.ChooseFromList
oCFLs = oform.ChooseFromLists
oCFLCreationParams = SBO_application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
oCFLCreationParams.MultiSelection = False
oCFLCreationParams.ObjectType = "????????"
oCFLCreationParams.UniqueID = "CFL1"
oCFL = oCFLs.Add(oCFLCreationParams)
oform.Items.Item("4").Specific.ChooseFromListUID = "CFL1"
Dim oEditText As SAPbouiCOM.EditText = oform.Items.Item("4").Specific
oEditText.ChooseFromListUID = "CFL1"
oEditText.ChooseFromListAlias = "????????"
Can you help me please
Thank youdidier,
You do not need the order. On any ChooseFromList, when you open the list itself, you can press the form settings button, and define the default fields and sorting criterias.
Example
Open Sales Orders
press tab on BP Field - this opens CFL of BP
Press Form Settings icon on toolbar
Set up the correct fields order and soring values
Click ok
You can do the same for your UDO based CFL (when you register UDO, you can define searcable filelds and list of the fields, and positions can be defined there!)
FYI:
Also DI Object SAPbobsCOM.ChooseFromList can be used for defining CFL columns and sort orders, but this is done during UDO registration
Regards
J -
Create .DLL file to register an UDO
Hi,
How do we create a .DLL file to register an UDO? I would appreciate if you can give me a step by step minute details.
Regards
SudattSudatt,
The SAP Business One SDK Documentation covers the creation of a .dll to work with a UDO. You can find the documentation at Customization Tools > User-Defined Objects > Creating a UDO > Step 4: Extending Business Logic.
Eddy -
How to register UDT into UDO through DI API?
Hi All
I am creating User Data tables and fields by using an Add on through DI API.
Now i want to register these tables and fields into User Defined object in SAP B1 using add on through DI API.
What are the possible ways for this?
And can you provide me sample codes?
Thanks in advance.UDO should be built on top of a UDT. So you need to create the UDT first and
then the UDO. You need to use the metadata objects available in DI API, i.e.
objects like UserTablesMD, UserFieldsMD, UserObjectsMD. All of these are
fully documented in the SDK Help.
Maybe you are looking for
-
Restoring iphone, forgot password
so i forgot my password to unlock my phone, and i plug it in to itunes and restore it but in order to restore it i have to update it so i download the update which says it'll take 3 hours. and i dont really have good connection so my internet goes on
-
Hi PP Experts, Can anybody please explain me, What is difference between Standard Available capacity,Available capacity & Pooled capacity. Please explain with giving simple example if possible.Don't define.Please helpout. Edited by: Raja S on Oct 17,
-
Spotlight Window: No keyboard shortcut will work...
I can assign any keyboard shortcut for Spotlight's search bar and it'll work, but the inverse is true for Spotlight's window (which I prefer to use). Any shortcut I assign to the window does not conflict with another. This problem doesn't, and never
-
Adobe security advisory: http://www.adobe.com/support/security/advisories/apsa10-01.html "A critical vulnerability exists in Adobe Flash Player 10.0.45.2 and earlier versions for Windows, Macintosh, Linux and Solaris operating systems..." Is the Flas
-
Omniportlet Connection Failture
Hi, Yesterday the usernames in our portal expired. We fixed this problem by resetting the passwords in the OID and changing the DAD under the portal. Since completing this, our Omniportlets no longer function. When I try to edit the provider properti