cancel
Showing results for 
Search instead for 
Did you mean: 

AddOn termination and company changed

former_member369006
Participant
0 Kudos

Hello experts.

Please suggest me how to properly handle the events aet_ShutDown and aet_CompanyChanged.
When you close the application case is quite obvious, Addon child should be stopped.
What should I do when changing company?
I am quite often facing the issue AddOn remains in task manager or AddOn refuses to start when changing company.
How can I avoid these problems?


Best regards,

Pawel

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Pawel,

Add AppEvent to your application In main method of your Program class in Program.cs as follows.


Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);

Here is the implementation of the event.


static void SBO_Application_AppEvent(SAPbouiCOM.BoAppEventTypes EventType)

{

            if (EventType == SAPbouiCOM.BoAppEventTypes.aet_ShutDown)

            {

                // you can write code to remove your menu items if you have.

                Environment.Exit(-1);

            }

}

Hope this will help.

Regards,

J S L Geeganage

former_member369006
Participant
0 Kudos

Hi.

Thank you but I care more for handling event aet_CompanyChanged. Should I close AddOn application or not. Maybe there are some issues concerning installation. How to avoid problems with running AddOn.


Best regards,

Pawel

Former Member
0 Kudos

Hi,

I think you should close your add-on when changing the company. Because your add-on will run automatically when you log in, if you have registered your add-on by selecting its group as automatic.


Environment.Exit(-1);

Consider the placing above line in change company block as well. And the code in my above reply will solve the problem of 'add-on keep running after close the SAP'

Regards,

J S L Geeganage

Answers (1)

Answers (1)

former_member369006
Participant
0 Kudos

Hello.

Anyone else has any idea how to ensure AddOn works stable, reliable, and does not stay in memory or causes an error in the time of the change of the company?


Regards,

Pawel

edy_simon
Active Contributor
0 Kudos

Hi Pawel,

On Company Change, IMHO, exit your customized addon.

As has pointed out, another instance of your addon would be restarted on company change.

Regards

Edy

former_member369006
Participant
0 Kudos

Hi.

Ok I understand. But still I am facing the problem AddOn stays in memory or crashes.

Maybe this is not caused by incorrect handling of aet_CompanyChanged event, but something else: AddOn installation settings?


Regards,

Pawel

edy_simon
Active Contributor
0 Kudos

Hi Pawel,

Can I see your code in the company change event ?

Regards

Edy

former_member369006
Participant
0 Kudos

Sure:

void SBO_Application_AppEvent(BoAppEventTypes EventType)

        {

            try

            {

                switch (EventType)

                {

                    case BoAppEventTypes.aet_CompanyChanged:

                    case BoAppEventTypes.aet_ServerTerminition:

                    case BoAppEventTypes.aet_ShutDown:

                        customMenuItems.RemoveMenuItems(be1App.SapApp);

                        System.Environment.Exit(0);

                        break;

                }

            }

            catch

            {

            }

        }

edy_simon
Active Contributor
0 Kudos

Hi Pawel,

Your code looks ok.

Can you debug and make sure, the RemoveMenuItems does not throw error ?

or Just to be sure, can you copy your System.Environment.Exit(0);

into your catch block ?

void SBO_Application_AppEvent(BoAppEventTypes EventType)

        {

            try

            {

                switch (EventType)

                {

                    case BoAppEventTypes.aet_CompanyChanged:

                    case BoAppEventTypes.aet_ServerTerminition:

                    case BoAppEventTypes.aet_ShutDown:

                        customMenuItems.RemoveMenuItems(be1App.SapApp);

                        System.Environment.Exit(0);

                        break;

                }

            }

            catch

            {

                   System.Environment.Exit(0);

            }

        }

Regards

Edy

former_member369006
Participant
0 Kudos

Hi Edy.

I am quite sure that function RemoveMenuItems does not throw error.

But anyway. This is good idea to move System.Environment.Exit to catch or finally block.


Thank you.


Regards,

Pawel