Creating a database when installing an SAP Business 1 Add on
开发者_JS百科I am creating an SAP Business one add-on payroll application - EIMPayroll. I have created an .ard file and I am able to install this add-on in SAP, ie, going to the add on manager and registering the payroll application using the .exe and .ard files.
However, on the machine that I install this add-on on, I have to manually import/create the Microsoft SQL server database "Eim_payroll.bak" on the computer for this add-on to run.
My question is, is there a way I can write the sql query to create the database and tables needed to run this application on a C# file and then package it together into the ard file such that it installs when I install the add-on in SAP?
I create the ard file using Visual Studio 2010 and using the SAP B1 AddOnInstaller .NET Wizard. My add-on is in C#
Any help will be appreciated, including links on examples of how this is done.
Not sure what exactly you are asking. I believe you want to create user tables and user defined fields when registering the add-on in SAP.
Try this, it may work. For creating tables:
ousertable = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
ousertable.TableName = "OEMP"
ousertable.TableDescription = "Employee Header"
lretcode = ousertable.Add
If lretcode 0 Then
ocompany.GetLastError(lerrcode, serrmsg)
sbo_application.MessageBox(serrmsg)
End If
For creating table fields:
ouserfield = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
ouserfield.TableName = "@OEMP"
ouserfield.Name = "empid"
ouserfield.EditSize = "5"
ouserfield.Type = SAPbobsCOM.BoFieldTypes.db_Numeric
ouserfield.Description = "Employee id"
lretcode = ouserfield.Add
If lretcode 0 Then
ocompany.GetLastError(lerrcode, serrmsg)
sbo_application.MessageBox(serrmsg)
End If
Cheers
精彩评论