cancel
Showing results for 
Search instead for 
Did you mean: 

Correct usage of SBO_Application.RemoveWindowsMessage

iNDdM
Participant
0 Kudos

I am trying to optimize reading of a UI grid that has a large number of rows. This grid is a user defined grid on a user defined form used in a UI Addon om Business One V 10 hana.

I have over a 10,000 rows that I need to process however looping through them crashes the entire addon roughly every  100 rows.

Note that there are no updates done to the grid or the data table behind that grid during the loop. Only reading.

It has been suggested that this issue may relate to the issue noted on SAP note  below even though I don't directly get the same error message. SAP note contents are appended below too.

Can someone explain the correct usage of the 2nd solution given in the note please - the usage of

SBO_Application.RemoveWindowsMessage 

 

<< 1506163 - UI_UI API break down with RPC error>>

==================================================

Symptom

Your add-on is running long-time operations, also the UI API keeps sending events to this add-on. After the long-time operation is done, you may get the error:

Exception: System.InvalidCastException: Unable to cast COM object of type 'SAPbouiCOM.ApplicationClass' to interface
type 'SAPbouiCOM.IApplication'. This operation failed because the QueryInterface call on the COM component for the interface with
IID '{D1F75D47-137C-4335-AC2A-3FE209831B6A}' failed due to the following error: System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)).

Cause

Limitation

Solution

Workaround

Set the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\“USERPostMessageLimit” in regedit. Make this key large enough like 400,000

Or you can use the RemoveWindowsMessage method which is exposed in 8.82 like this:

System.Threading.Thread.Sleep(1000 * 60);    //replace with your real working code  
SBO_Application.RemoveWindowsMessage(SAPbouiCOM.BoWindowsMessageType.bo_WM_TIMER, true); 

This method enables you to deal with extreme scenarios. When an add-on needs to take a long time to process a UI API event, it prevents SAP Business One from processing the Windows message queue.

Other terms

RPC Call, Thread, SDK, synchronous, asynchronous

Accepted Solutions (0)

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi iNDdM,

Instead of it, you can create a ProgressBar and keep sending the message to UI API which will keep it active and your add-on will not crash.

Refer to the SDK help file for ProgressBar object.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

iNDdM
Participant
0 Kudos

Hi Ankit,

Thanks for the suggestion. I already have a UI action that is done within the loop of reading the rows. That job is updating a label field ( that label is out of the grid but on the same form).  That label simple displays the currently updating row.

I would have thought that would do the same job as a progress bar in keeping the UI alive.