Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 02, 2017 at 07:58 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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