Skip to Content
0

Matrix Validate After event infinite loop

Oct 25, 2016 at 07:00 AM

258

avatar image

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)
10 |10000 characters needed characters left characters exceeded
0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
avatar image
Former Member Oct 25, 2016 at 10:23 AM
0

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded

I removed the Click event on the textbox. Loop occurs when i erase something i have written in the matrix cell and click tab. When i am writing data or changing from X to Y it is ok. The problem is when you completely remove the data from a single cell

0
Former Member
Varnavas Eleftheriou

Hi Varnavas,

If it's looping you can (using the debugger) see exactly where it triggers the validate again. Note that click is just one type of action that triggers the validate, if you write to another cell, click a button, focus another control, etc... all these will trigger it as well.

Make sure that in your that in your Matrix0_ValidateAfter you are not performing any operation that will trigger another validate.

Pedro Magueija

LinkedIn | Twitter | Blog

0

Still it does not make sense. Here is what happens:

1) i enter a value in the cell i click tab and everything is fine.

this ←code executes:

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;

2) i don't enter a value in the cell i click tab everything is fine

this ← code executes

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; ←←←←←←←

3) i enter a value in the cell i click tab and up until here its ok. i go back to the cell, erase the data click tab and it loops infinitely on the ELSE statement why? since in scenario 2 it executes normally. disabling a column of another matrix triggers validation on a different matrix?

0
Former Member
Varnavas Eleftheriou

Hi Varnavas,

Have you used the EventLogger tool to check the event chain?

There you can see what and when the events are being fired. Then you can adjust your code accordingly.

Pedro Magueija

LinkedIn | Twitter | Blog

0
Varnavas Eleftheriou Oct 26, 2016 at 05:54 AM
1

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 :)

Share
10 |10000 characters needed characters left characters exceeded
Varnavas Eleftheriou Oct 25, 2016 at 07:52 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Varnavas Eleftheriou Nov 02, 2016 at 10:13 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded