Skip to Content
author's profile photo Former Member
Former Member

Unable to catch the form load event.


I am trying to catch the form load event for the Sales Quotation form.

My task is to add a new button when the form opens.

This is how my code looks -

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If pVal.FormType = 149 Then

If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then

' Add button on form load

oForm = SBO_Application.Forms.Item(FormUID)

oItem = oForm.Items.Add("Button", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 140

oItem.Width = 65

oItem.Top = oForm.ClientHeight - 30

oItem.Height = 19

oButton = oItem.Specific

oButton.Caption = "Button"

End If

End If

End Sub

But the form load event never occurs and thus my code is not executed. SBO_Application_ItemEvent is not called when the form is opening.

I am able to catch the click events on the form.

What am I missing?

Please help me solve this issue.

Thank you for your help.



Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 24, 2005 at 07:34 AM


    try this, it's working for me on the Deliveries form

    Private Sub sboApplication_ItemEvent(ByVal FormUID As String, pVal As SAPbouiCOM.IItemEvent, BubbleEvent As Boolean)

    If pVal.FormType = 140 Then

    If pVal.EventType = et_FORM_LOAD Then

    Set frmDelivery = sboApplication.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)

    'here I do something like adding items on the form


    Of course remove any event filter if you set 'em.

    I know, I'm using the deprecated method instead of GetForm, but it works fine

    Finally, let me say that event handling in SBO is so poorly documented that you have to experiment a bit to achieve some good results.

    Hope this helps


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 24, 2005 at 06:57 AM

    Hi Sheetal,

    Have you defined an EventFilter before this? This could be a reason why it doesn´t get fired.

    Did you try a messagebox just where you get the form?

    Becouse I can see that you are not managing the BeforeEvent property, and then it would execute your code twice. And as your button ID would be repeated, it should give an error.

    Are you sure it doesnt get fired?


    Ibai Peñ

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 24, 2005 at 07:03 AM


    Try to change in your code:

    oForm = SBO_Application.Forms.Item(FormUID)

    for this

    oForm = SBO_Application.Forms.getactiveform()

    or this

    oForm = SBO_Application.Forms.getform("149",1)

    This is the code that i have used for adding a button to a system form, you only need to change 139 to 149.

    Perhaps you may try SBO_App.forms.getactiveform instead getform("139",1).

    if pVal.typeEx="139" then
     If pVal.EventType = et_FORM_LOAD Then
        Dim oForm As SAPbouiCOM.Form
        Dim obj As SAPbouiCOM.Item
        Dim btn As SAPbouiCOM.Button
        Set oForm = SBO_App.Forms.GetForm("139", 1)
        Set obj = oForm.Items.Add("BtnDsdFac", it_BUTTON)
        obj.Left = oForm.Items.Item("37").Left + 120
        obj.Width = 120
        obj.Top = oForm.Items.Item("37").Top
        obj.Height = oForm.Items.Item("37").Height
        Set btn = objeto.Specific
        btn.Caption = "caption of button"
     end if
    end if

    Salvador Biot

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 24, 2005 at 07:13 AM


    for my knowledge the FORM_LOAD event doesn't raise a BeforeAction, so it couldn't be an error.

    The EventFilter could be a good reason...

    I don't really see an error in your code, you could try to set some breakpoints to see what instructions are exectuted correctly.

    In my codes i'm writing something similar to add buttons... the difference is that i use the new SDK 2004 objects and methods:

    --- pVal.FormTypeEx = "149" ---

    --- oForm = SBO_Application.GetForm(pVal.FormTypeEx, pVal.FormTypeCount) ---

    but i don't think this can solve your problem...

    Kind regards,

    Fabio Salucci

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.