Good day everyone,
I was trying to select the "bill to" address under the addresses tab of the BusinessPartners form using the UI API.
This code would execute whenever the customer changed the customer name while adding a new businesspartner, so on a ItemEvent ValidateAfter event.
(This to later update the Address ID field of the ship to to address, also using the UI API, based on the business partner name)
I've tried a number of approaches and none seem to be working:
I always start with changing the Pane like this
Private Sub EditText0_ValidateAfter(sboObject As Object, pVal As SAPbouiCOM.SBOItemEventArg) Handles EditText0.ValidateAfter
If Me.UIAPIRawForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then
'conditie: bedrijfsnaam ingevuld <> ""
If EditText0.String <> "" Then
Dim prevPane = Me.UIAPIRawForm.PaneLevel
Me.UIAPIRawForm.PaneLevel = 7
After that I've tried a number of things.
What seemed the most logical to me was :
Dim b1Matrix As SAPbouiCOM.Matrix
b1Matrix = Me.GetItem("69").Specific
b1Matrix.SelectRow(4, True, False)
but this throws a COMException: 'COMException : Item - The item is not a user-defined item [66000-8]
I understand that it's a system form component.
After that I tried an Cell.Click as follows :
Dim itemAddressShipCell As SAPbouiCOM.Cell = b1Matrix.Columns.Item("20").Cells.Item(4)
itemAddressShipCell.Click()
but this somehow triggers EditText0_ValidateAfter over and over again and makes SAP crash.
I have the same results with b1Matrix.SetCellFocus(4, 20)
Dim editAddressShip As SAPbouiCOM.EditText = b1Matrix.Columns.Item("20").Cells.Item(4).Specific
editAddressShip.Item.Click()
This seems to have no effect but it runs and does not loop.
Any idea on how to do this? Is this possible?
(Version of SAP B1 is 9.1 PL5)
EDIT: I also found out that the system form matrices have a 'fixed' selection mode - SAPbouiCOM.BoMatrixSelect.ms_NotSupported
according to the SDK documentation:
Restrictions on System Forms
Matrix Object
You cannot control the selection mode for system Matrix object. The SelectionMode property will always returnms_NotSupported.
Restricted methods SetLineData, SelectRow, LoadFromDataSource, FlushToDataSource.
And I also tried via the datasource:
Dim ds As SAPbouiCOM.DataSource = Me.UIAPIRawForm.DataSources
Dim dSourceAddresses = ds.DBDataSources.Item("CRD1")
dSourceAddresses.SetValue("1", 1, EditText0.String)
Which also throws the Item - The item is not a user-defined item [66000-8] COMException
Again, the documentation states:
DBDataSource
You cannot access a DBDataSource used by a system form.
You can add a DBDataSource only if the database table does not exist already in the system form's DataSources collection.
Query method is not supported.
So am I doing this fundamentally wrong? Is there some kind of workaround?