cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot change CheckBox state on form

Former Member
0 Kudos

Hi,

I created a checkbox on a user defined form and associated it with a user defined datsource to set its value based on a setting in the database during form load. Once the form loads, I am not able to change the state of the checkbox i.e. If its checked during form load, then I am not able to uncheck it by clicking oin the form and vice versa. I am using VB.NET and SDK 6.5. Any help is appeciated.

Thank You,

Gopal Viswanathan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I've tested it with VB.NET & SDK 6.5.

In case the CheckBox is not clickable - that means that your datasource is not connected properly.

Use this syntax to bound your CheckBox to a userDataSource:

<i>'Adding the User DataSource</i>

oDS = oForm.DataSources.UserDataSources.Add("USDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1)

<i>'Binding the CheckBox</i>

oChkB.DataBind.SetBound(True, "", "USDS")

Regards,

Yaniv G.

SDK Consultant,

SAP Manage Israel.

Former Member
0 Kudos

Hi,

Thank you for your quick response. I am doing exactly the same steps as you have mentioned. The code that I have wrotten below is being executed during the form load of my User defined form. I am able to even fill in the checkbox based on some true/false values from the database. But once these are filled I am not able to click the check box to change it. Should I be doing something else to persist the value of the datasource ?(the datasource is a Class level object)

'User defined Datasource

SAP_DS_ChkActive = frmRptDefs.DataSources.UserDataSources.Add("Chk", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)

'Initialize check box

chkActive = frmRptDefs.Items.Item("chkActive").Specific

'Bind ChkBox

chkActive.DataBind.SetBound(True, "", "Chk")

Former Member
0 Kudos

Hi,

I have the same problem. The addon successfully worked with the SDK 6.2 version but when I became to use it with the SDK 6.5 the problems with checkboxes began.

I have made a simple test application that is not work properly. When the test form starts all checkboxes are disabled. If I click on the checkbox it becomes checked but I can not uncheck it back.

I use SBO 6.50.097 SP1.

This is the app code:

Private Sub Form_Load()

Me.Hide

'Connect to SBO Application

Dim clsApplication As SAPbouiCOM.Application

Dim clsGuiApi As SAPbouiCOM.SboGuiApi

Set clsGuiApi = New SAPbouiCOM.SboGuiApi

clsGuiApi.Connect Command()

Set clsApplication = clsGuiApi.GetApplication()

Set clsGuiApi = Nothing

'Load a test form from the xml-file

Dim strXML As String

Dim clsFSO As Scripting.FileSystemObject

Set clsFSO = New Scripting.FileSystemObject

Dim clsTextStream As Scripting.TextStream

Set clsTextStream = clsFSO.OpenTextFile(App.Path + "\" + "Form.xml")

strXML = clsTextStream.ReadAll

clsTextStream.Close

Set clsTextStream = Nothing

Set clsFSO = Nothing

clsApplication.LoadBatchActions strXML

'Fill a matrix cell's

Dim frm As SAPbouiCOM.Form

Set frm = clsApplication.Forms("Form")

frm.Freeze False

Dim i As Long

For i = 1 To 10

With frm.DataSources

.UserDataSources("Row").Value = i

.UserDataSources("String").Value = "Row " & i

.UserDataSources("Checkbox").Value = _

IIf(i Mod 2 = 1, "Y", "N")

Debug.Print IIf(i Mod 2 = 1, "Y", "N")

End With

frm.Items("Matrix").Specific.AddRow

Next i

frm.Freeze False

End Sub

This is the xml form definition:

<Application>

<forms>

<action type="add">

<form appformnumber="2000060006" color="0" default_button="" height="359" left="276" pane="1" title="Checkbox Test" top="88" uid="Form" visible="1" width="563">

<datasources>

<dbdatasources>

<action type="add"/>

</dbdatasources>

<userdatasources>

<action type="add">

<datasource size="4" type="0" uid="Row"/>

<datasource size="20" type="8" uid="String"/>

<datasource size="1" type="9" uid="Checkbox"/>

</action>

</userdatasources>

</datasources>

<menus/>

<items>

<action type="add">

<Item description="" disp_desc="0" enabled="1" from_pane="1" height="270" left="4" linkto="" right_just="0" tab_order="0" to_pane="1" top="24" type="127" uid="Matrix" visible="1" width="545">

<Specific SelectionMode="0" layout="0">

<columns>

<action type="add">

<column description="" disp_desc="0" editable="0" right_just="0" title="#" type="16" uid="Row" val_off="" val_on="" visible="1" width="27">

<databind alias="Row" databound="1" table=""/>

</column>

<column description="" disp_desc="0" editable="1" right_just="0" title="String" type="16" uid="String" val_off="" val_on="" visible="1" width="50">

<databind alias="String" databound="1" table=""/>

</column>

<column description="" disp_desc="0" editable="1" right_just="0" title="Checkbox" type="121" uid="Checkbox" val_off="" val_on="" visible="1" width="30">

<databind alias="Checkbox" databound="1" table=""/>

</column>

</action>

</columns>

</Specific>

</Item>

</action>

</items>

</form>

</action>

</forms>

</Application>

Former Member
0 Kudos

I have found that I needed to change the val_on value (in the XML) to some value other than "". There must be a similar way to do this in code as well.

Former Member
0 Kudos

This works!!!! Thanks a lot buddy. Even SAP support was not able to help me on this one. thanks a lot.

Former Member
0 Kudos

Thank you very much!

It works correctly now.