cancel
Showing results for 
Search instead for 
Did you mean: 

Customize System form

Former Member
0 Kudos

Dear Expert,

I want insert new tab to system form then create grid to update custom table .

I can create a tab but don't know how to load data from DB to grid. Can you help me?

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi AdminX,

You cannot bind a DBDataSource to a grid directly.

You have two option,

1. Bind a DataTable to the grid and do the DataTable.ExecuteQuery("SELECT * FROM [YourTable]")

2. Use a Matrix instead of Grid, and bind the matrix column to the DBDataSource.

Regards

Edy

Former Member
0 Kudos

Thank you. You help me a lot

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi AdminX,

Just to elaborate what Edy Simon has explained, here is the sample to do it:

string Sql = "Select SelectRow as 'Select', ItemCode as 'Item Code', ItemName as 'Item Name', Qty as 'Qty.', DocRef , LineID , ProjectDescription as 'Project Details', Project From [@TEMPTABLEFORMATERIALREQUEST] Where UserLogin = '" + SBO_Company.UserName + "'";

              

this.oForm.DataSources.DataTables.Add("MYDATATABLE");               

this.oForm.DataSources.DataTables.Item(0).Clear();               

this.oForm.DataSources.DataTables.Item(0).ExecuteQuery(Sql);               

SAPbouiCOM.Grid oGrid = (Grid)this.m_SBO_Form.Items.Item("GridID").Specific;               

oGrid.DataTable = this.oForm.DataSources.DataTables.Item("MYDATATABLE");               

SAPbouiCOM.EditTextColumn oEditColumn;               

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("DocRef")));               

oEditColumn.Visible = false;               

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("LineID")));               

oEditColumn.Visible = false;               

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Select")));               

oEditColumn.Type = BoGridColumnType.gct_CheckBox;               

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Item Code")));               

oEditColumn.Editable = false;               

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Item Name")));               

oEditColumn.Editable = false;      

oGrid.AutoResizeColumns();               

oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("Item Code")));               

oEditColumn.LinkedObjectType = "4";

Hope it helps.

Thanks & Regards

Ankit Chauhan

Former Member
0 Kudos

I have one more question, how can I update custom table in system form (press Ctr + S).

Please help me

edy_simon
Active Contributor
0 Kudos

Hi AdminX,

If you want to update the form after the user press Ctr+s, you need to catch the event after key down, and check for the pVal.Modifier and pVal.CharPressed. If the modifier is 'Ctrl' key and CharPressed = "s", then go ahead with the saving.

To save, you need to write your own code to update the physical table. SBO does not help you update in this case.

If your table is UDT, use the SAPbobsCOM.UserTable object.

if your table is part of a UDO, use the GeneralService to update the record,

Suggestion, I would usually update the data on the After/Befor Form Data Update event.

This is triggered when SBO update the current form.

Regards
Edy