cancel
Showing results for 
Search instead for 
Did you mean: 

setting BubbleEvent=true in BEFORE click event handler does not cause SAP to handle event

Former Member
0 Kudos

Hi,

I have trapped the BEFORE click event for the ADD button of an UDO's default form (see Button0_ClickBefore below).

After displaying "hello world" I want SAP to continue processing event so I set BubbleEvent=true, but SAP seems to ignore. I would have expected errors as I did not enter any data to form before clicking Add, but SAP just returns to the form:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using SAPbouiCOM.Framework;

namespace ApprovalStatusReport2 {

[FormAttribute("UDO_FT_PDC4")]

class PDC : UDOFormBase

{

public PDC() { }

/// <summary>

/// Initialize components. Called by framework after form created.

/// </summary>

public override void OnInitializeComponent()

{

this.Button0 = ((SAPbouiCOM.Button)(this.GetItem("1").Specific)); this.Button0.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.Button0_ClickBefore); this.OnCustomInitialize();

}

/// <summary>

/// Initialize form event. Called by framework before form creation.

/// </summary>

public override void OnInitializeFormEvents()

{

}

private SAPbouiCOM.Button Button0;

private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)

{

//throw new System.NotImplementedException();

Program.sbo_application.MessageBox("Hello World");

BubbleEvent = true;

}

private void OnCustomInitialize(){ }

}

}

It seems I do not understand how BubbleEvent works. Furthermore pVal.BeforeAction does not exist (I am using the SDK.dll) so I cannot test it.

All help much appreciated. Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi Bahadur,

By Default, UDO of type Documents can accept empty user fields record.
That is why even though you did not enter any data, the form is committed to database.
If you want to restrict empty fields, you need to set your UDFs as mandatory.

Regards
Edy

Former Member
0 Kudos

Edy,

Thank you very much for your response.

However it seems that I did not explain myself properly. Default behaviour (without my addon) after Add button clicked will not allow data to be added and displays standard error as form has various mandatory fields (as you mentioned):

Issue is that when I trap the before click event of the default ADD button and just display "Hello World":

private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
{
//throw new System.NotImplementedException();
Program.sbo_application.MessageBox("Hello World");
BubbleEvent = true;
}
<br>

I am trying to get SAP to continue processing (i.e. behave as it did without my addon). I thought that just setting BubbleEvent=true would achieve this but in my case above it does not as SAP no longer displays any errors There must be something I am thinking/doing wrong. I appreciate any help as this is a basic requirement of all my future addons.

blessings,

edy_simon
Active Contributor
0 Kudos

Hi Bahadur,

I suggest instead of 'ClickBefore' you use 'PressBefore' event.
Click event is not supported if you want to allow your customization to run in web-access.

Nevertheless, BubbleEvent = true; is already correct.
Are you sure there is no error message from SAP, can you try to open the Message Log and see if it is there.

Regards
Edy

Former Member
0 Kudos

Dear Edy,

Below is System log after I have tried to click Add WITH my AddOn running (*** NOTE error#1 is from when I previously clicked Add button WITHOUT my Addon running):

Then after I click OK to the "Hello World" message:

I would expect to see another "Enter valid code" message but it does not appear either in status bar or log.

blessings,

edy_simon
Active Contributor
0 Kudos

Hi Bahadur,

Below is the chain of events when you click the button starting from 'Click before'.

ClickBefore
PressedBefore
BeforeFormDataAdd
AfterFormDataAdd
PressedAfter
ClickAfter

Do you have any handler on PressBefore?
If you remove the event handler for 'ClickBefore' does it give you the message?


Regards
Edy

Former Member
0 Kudos

Dear Edy,

I do not have any other handlers for that Add button.

Below is my program.cs:

using System;
using System.Collections.Generic;
using SAPbouiCOM.Framework;


namespace pdc1
{
    class Program
    {
        public static SAPbouiCOM.Application sbo_application;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                Application oApp = null;
                if (args.Length < 1)
                {
                    oApp = new Application();
                }
                else
                {
                    oApp = new Application(args[0]);
                }


                sbo_application = SAPbouiCOM.Framework.Application.SBO_Application;
                Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
                oApp.Run();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }


        static void SBO_Application_AppEvent(SAPbouiCOM.BoAppEventTypes EventType)
        {
            switch (EventType)
            {
                case SAPbouiCOM.BoAppEventTypes.aet_ShutDown:
                    //Exit Add-On
                    System.Windows.Forms.Application.Exit();
                    break;
                case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged:
                    break;
                case SAPbouiCOM.BoAppEventTypes.aet_FontChanged:
                    break;
                case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged:
                    break;
                case SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition:
                    break;
                default:
                    break;
            }
        }
    }
}<br>

And the code for the UDO form:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAPbouiCOM.Framework;


namespace pdc1
{
    [FormAttribute("UDO_FT_PDC4")]
    class UDOForm1 : UDOFormBase
    {
        public UDOForm1()
        {
        }


        /// <summary>
        /// Initialize components. Called by framework after form created.
        /// </summary>
        public override void OnInitializeComponent()
        {
            this.Button0 = ((SAPbouiCOM.Button)(this.GetItem("1").Specific));
            this.Button0.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.Button0_ClickBefore);
            this.OnCustomInitialize();


        }


        /// <summary>
        /// Initialize form event. Called by framework before form creation.
        /// </summary>
        public override void OnInitializeFormEvents()
        {
        }


        private SAPbouiCOM.Button Button0;


        private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            //throw new System.NotImplementedException();
            Program.sbo_application.MessageBox("Hello World");
            BubbleEvent = true;
        }


        private void OnCustomInitialize()
        {


        }
    }
}<br>

Also is it proper to get handle to the app by using:

sbo_application = SAPbouiCOM.Framework.Application.SBO_Application;

I get the error msg even if I just comment out "Program.sbo_application.MessageBox("Hello World");" otherwise I do not get the error msg.

As I had stated in my original question I am using the SDK framework i.e. SAPBusinessOneSDK.dll - could that be the issue?

blessings,

bahadur