cancel
Showing results for 
Search instead for 
Did you mean: 

How to capture Add-On load event?

Former Member
0 Kudos

I am developing a small add-on and I need to connect to the DI API. I have already made the connection but I realize that this procedure is executed every time I open the SAP add-on form, it is normal?, I have seen that other add-ons show a message of success the first time loads the SAP. So, where should I place my API connection code? How do I capture the event when the add-on is loaded? I had thought of capturing that event and from there execute the connection procedure to the DI API which is the following:

// Connect AddOn
{
this.oApp = Application.SBO_Application;
this.oCompany = ((SAPbobsCOM.Company)(this.oApp.Company.GetDICompany()));
Application.SBO_Application.StatusBar.SetText("Add-On connected: " + appName, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error connecting Add-On " + appName + " a SAB B1: " + ex.Message, "Error Connection", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
}

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member211473
Contributor
0 Kudos

Hi

May be you have created/written the same code to every form that you have made, so when you open your form the above code runs and show you the message. try writing the ui, di connection on the menu level or main function and use the connection property on every class / form that you have.

Thanks

former_member390407
Contributor
0 Kudos

Hi Jorge,

Where is this code running? You need to connect to SBO company when your application starts running and close your application (closing all necessary connections) when an application event aet_ShutDown (or another event, that's up to the add-on logic) happens.