cancel
Showing results for 
Search instead for 
Did you mean: 

proper way to add to a system form a combobox with values from user defined table

Former Member
0 Kudos

hello all,

i'm facing some difficulties in adding a combobox to a system form.

i've created a user defined table called @TABLENAME with only CODE and NAME fields

i'm trying to add to ITEMS form ( 150 ) a combobox showing values stored in @TABLENAME.

combobox selected value has to be bound to a user defined field (U_USERDEFINEDFIELD ) created in table OITM.

i've succesfully added a combobox to OITG form ( 63 ) showing values from OITB table and putting selected value in a user defined field OITG.U_CUSTOMFIELD.

so the issue is about using system tables vs user defined tables as source for valid values.

my custom combo box is added to an existing panel, here is my code


          string cmbId = "cmb";

          tmpItem = form.Items.Add(cmbId, SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX);

          tmpItem.FromPane = 0;

          tmpItem.ToPane = 0;

          tmpItem.Left = 212;

          tmpItem.Top = 200;

          tmpItem.Width = 200;

          tmpItem.Height = 19;

          SAPbouiCOM.ComboBox cmb = (SAPbouiCOM.ComboBox)tmpItem.Specific;

          tmpItem.DisplayDesc = true;

          tmpItem.Enabled = true;

          tmpItem.AffectsFormMode = true;

          cmb.DataBind.SetBound(true, "@TABLENAME", "U_USERDEFINEDFIELD");

          cmb.ExpandType = SAPbouiCOM.BoExpandType.et_ValueDescription;

i face "table not found [131-183]" error.

if i bind my combobox to OITM.U_USERDEFINEDFIELD and fill the valid values with a query everything works. eg.


cmb.DataBind.SetBound(true, "OITM", "U_USERDEFINEDFIELD");

        cmb.LoadValidValues(" SELECT CODE, NAME FROM [@TABLENAME]");

        cmb.ExpandType = SAPbouiCOM.BoExpandType.et_ValueDescription;


i'm puzzled. what is the OFFICIAL and PROPER way to add to a system form a combobox with values from user defined table?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Christian,

I think this is quite good for me, If I would have a requirement like this, I will happy to do the same.

Best Regards,
J S L Geeganage

Former Member
0 Kudos

excuse me sir, i'm asking a question. i'm not stating this is the way things have to be coded. at all.

pedro_magueija
Active Contributor
0 Kudos

Hi Christian,

Any way that uses the API (and works) is official. I think what you mean is: is there another, more efficient way of loading the values?

Well, loading values one by one will start being noticeable when you have a lot of values. One way to do it in one go is to generate the XML to update the form (with all the ValidValues in it) and then use LoadBatchActions to update the form.

However, the technique above introduces unnecessary complexity if you'll only ever have a few dozens of valid values to load.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

i'm afraid there's a little misunderstanding.

i do not understand why if i bind the combobox to OITB everything runs fine, whereas if i bind the combobox to a user defined table i face the 'table not found' error even if i find here on scn code samples telling me the exact opposite.
as far as i get, working with this almost undocumented and buggy sdk is more a matter of 'if it works it's ok' than following best practices and design patterns.

thanks for the help

pedro_magueija
Active Contributor
0 Kudos

Hi Christian,

Aha, ok. Have you added the table to the form (might not be possible in system forms)? It is possible after all

form.DataSources.DBDataSources.Add("@TABLENAME");


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Great answer Pedro, straight to the point!

Thanks!

Answers (0)