cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 2004 starts 2 addons at the same time?

Former Member
0 Kudos

I have two addons which may create database tables / user defined fields if don't exist. Now my experience is (at least it appears so) that SAP B1 starts two add-ons at the same time? This could mean that the two add-ons could create database fields concurrently, so they may conflict if they access the same tables (I got an error message if both add-ons create tables or fields)..

Am I right with this? If Yes, how can i avoid this (so that SAP B1 waits with the second addon until the first addon has completely started up)

Regards,

Accepted Solutions (0)

Answers (2)

Answers (2)

rasmuswulff_jensen
Active Contributor
0 Kudos

I have multible addon running at the same time, and there are no problems. just remeber that each til you use the Metadata use the garbage collector in the programming language to clear variables (item = null, GC.Collect())


		public static void Add(string TableName, string TableDescription, BoUTBTableType TableType, ref bool NewTables) {
			if(!SBO.DI.Metadata.UserDefinedTables.ExistTable(TableName)) {
	if(TableName.Length > 19) {
					throw new Exception(SBO.Texts.UserdefinedTables.addUserTable_Template_ForLangtTabelNavn.Replace("%1",TableName));
				}
	UserTablesMD tb_md = (UserTablesMD) SBO.DI.Connection.SboCompany.GetBusinessObject(BoObjectTypes.oUserTables);
				tb_md.TableName = TableName;
				tb_md.TableDescription = TableDescription;
				tb_md.TableType = TableType;
				if(tb_md.Add() != 0) {
					tb_md=null;
					GC.Collect();
					throw new Exception(SBO.Texts.UserdefinedTables.addUserTable_Template_Fejl.Replace("%1",TableName).Replace("%2",GetLastError.ErrorDescription));
				}
				else {
					tb_md=null;
					GC.Collect();
					NewTables = true;
				}
			}
			else {
				if (NewTables) {
					NewTables = true;
				} 
				else {
					NewTables = false;
				}
			}
		}

Former Member
0 Kudos

Hi Martin,

This is the documentation of the UserTablesMD object.

DI API allows only one meta data object instance (with no other instances of any object type). This maintains data integrity by preventing any manipulation of a business object while modifying the object's properties.

You could insert a random timer in each add-on.

rasmuswulff_jensen
Active Contributor
0 Kudos

tb_md=null;

and

GC.Collect();

are the important lines here

And remember to do the same for Fields and Keys

Message was edited by: Rasmus Jensen