Skip to Content

Matrix Validate After event infinite loop

Greetings,

I have a Matrix Validate After event which results in infinite loop sometimes. Sometimes it executes correctly some other times i loops until death. Any ideas why this happens and if there is something i am not currently handling?

I add dates on the top right matrix and columns on the bottom matrix should unlock and lock when i remove the date

private void Matrix0_ValidateAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            switch (pVal.Row)
            {
                case 1:


                   if( ((SAPbouiCOM.EditText)(Matrix0.Columns.Item(1).Cells.Item(pVal.Row).Specific)).Value.ToString() != "")
                    Matrix1.Columns.Item(3).Editable = true;
                   else


                       Matrix1.Columns.Item(3).Editable = false;
                   EditText1.Item.Click(SAPbouiCOM.BoCellClickType.ct_Regular);


                    break;
                case 2:


                    if (((SAPbouiCOM.EditText)(Matrix0.Columns.Item(1).Cells.Item(pVal.Row).Specific)).Value.ToString() != "")
                        Matrix1.Columns.Item(4).Editable = true;
                    else
                        Matrix1.Columns.Item(4).Editable = false;
                    EditText1.Item.Click(SAPbouiCOM.BoCellClickType.ct_Regular);
                    break;
screenshot-3.jpg (65.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 25, 2016 at 10:23 AM

    Hi Varnavas,

    The Validate event is triggered every time a control is "about to sync data with the data source". Action like clicking on another control will trigger the validate event on the current control.

    One way to stop this from happening is to temporarily disable all events during your handling of the validate event:

    public void AfterValidateHandler(ItemEvent e)
    {
    var currentEventFilters = application.GetFilter();
    application.SetFilter(null);
    // do your actions here
    application.SetFilter(currentEventFilters);
    }
    

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 26, 2016 at 05:54 AM

    After having remote aid from Pedro Magueija we managed to solve this using filters. Just a side not, its not the first time Pedro does something like this. He's an SDK Dictionary. any page you flip you learn something :)

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 25, 2016 at 07:52 AM

    Note to my above code, the part

     EditText1.Item.Click(SAPbouiCOM.BoCellClickType.ct_Regular);

    I was removed since it was causing worse things. You can see the behavior here

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02, 2016 at 10:13 AM

    After submitting my code through a ticket to SAP Development, they returned back saying that we discovered a bug in the current event (matrix validate after which has now been marked as "to be fixed with a patch". So currently work with what Pedro suggested until we hear something new.

    Add comment
    10|10000 characters needed characters exceeded