Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Can't get example C# Blanket to work

Hi, since I don't know basic, I tried to translate the code to C# and I have this questions:

When I received the Application_MenuEvent, the function DrawForm is executed, and the ComboBox for the ItemCode is populated. the Following code didnt work, becuase I could seem to get the correct object, either by an incorrect cast or an incorrect initialized Company. I did checked the company was indeed connected.

void AddItemsToCombo(SAPbouiCOM.Column oColumn) {

SAPbobsCOM.SBObob oSBObob;

SAPbobsCOM.Recordset oRecordSet;

try {

oSBObob = (SAPbobsCOM.SBObob)m_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);

oRecordSet = (SAPbobsCOM.Recordset)m_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

oRecordSet = oSBObob.GetItemList();

while (!(oRecordSet.EoF == true)) {

oColumn.ValidValues.Add(oRecordSet.Fields.Item(0).Value.ToString(), oRecordSet.Fields.Item(1).Value.ToString());





catch (Exception ex) {




For the above to work I had to change the method of connection to the database to this:

m_oCompany = new SAPbobsCOM.Company();

m_oCompany = (SAPbobsCOM.Company)SBO_Application.Company.GetDICompany();

My problem comes when I receive the SBO_Application_ItemEvent for the Matrix column ItemCode

//' After selecting an item from the combo box

if (pVal.ItemUID == "mat" && (pVal.ColUID == "ItemCode" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT)) {

SAPbouiCOM.EditText oEdit;

SAPbouiCOM.ComboBox oCombo;

oCombo = (SAPbouiCOM.ComboBox)m_colItemCode.Cells.Item(pVal.Row).Specific;

oEdit = (SAPbouiCOM.EditText)m_colItemName.Cells.Item(pVal.Row).Specific;

oEdit.Value = oCombo.Selected.Description;


I get an error of reference not set to an instance of an object, and I checked and it refers to both the oCombo and the oEdit objects, although they seem to be getting the cast all right, they do not inherit all the normal com properties. I have to take note, that this casting does work if its not generated by the event.

Please help!.

Thank you!

Not what you were looking for? View more on this topic or Ask a question