Showing results for 
Search instead for 
Did you mean: 

Dynamic programming - swap element definition at runtime

0 Kudos

Hi gurus,

I'd like to change dynamically an element definition in a table under certain assumptions.

Please consider the following scenario:

- an item table is shown in SRM;

- under certain assumptions, a specific row must be considered as a "special" one; for this item, I'd love to switch a field, specifically the standard "Product", from InputField to DropDownByKey. Obviously, I will have to substitute the standard search help with a fixed range domain for the DropdownByKey.

Is this possible? Could anyone provide some suggestions/sketch of code regarding this task?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Active Participant
0 Kudos


You can achieve the required funationality by using cell variants.

Please refer to the following link



0 Kudos

Thanks Swati,
I tried with cellVariants creating a new column which can contain both inputfield or dropdownbyKey.

It works, but there's a problem related to the properties of the cells.

I want that the new column behave exactly as the "original" one for what concerns visible, enabled and read_only properties.

These are not statically set in the original column, so my idea was to get at runtime the properties of the original cell and apply them to my custom one.

Is it feasible in your opinion?


Former Member
0 Kudos

Hi Matteo,

Another possibility is, create one more colum as ddk. create one attribute of type wdui_visibility.

And bind both input and dropdown with this. Set this attribute in your special case based on your requirement.



0 Kudos

Hi Kris,

I don't understand the behaviour of this WD.... I'd better clarify what I did:

- The WD table had a standard columns which is bound to a context attribute PRODUCT_ID (the inner element is an inputField);

- I created a new column, with a cellvariant option, in which I created, for cellVariant key "empty", an inputfield. I then binded this inputfield's value to context attribute PRODUCT_ID. Other "static" settings, like visible, enabled and so on ... have been set like the original column.

So.... I expected to see that the "custom" input field share the same properties of the "standard" input field. But that's not the case. My custom input_field is always in READ_ONLY state.

And by the way, I tried to set it dinamically as follows:

     lr_input_field ?= view->get_element('ORDERED_PROD_IF'). "my custom inputfield



        VALUE  = '02'        .



         VALUE  = abap_false         .

but the system returns a dump because "Could not find attribute PRODUCT_ID:READ_ONLY".

(note: PRODUCT_ID is the attribute's name in the Context).

Tried also to statically bind Visibility, Enabled and Read Only properties to an attribute in the context, setting it to 'X' in modifyview. But again the field is closed for modification, as you can see in the attached screenshot.

0 Kudos

Thanks Swati, thanks Kris,

I solved the visibility/enabled/read_only problem, my mistake in setting properties.

But now, another question arises:

now I have a column which can contain both an InputField or a DropdownByKey; these are binded for what concerns the value (valueKey) to the same Context attribute.

In case of InputField, there's already a (standard) search help working; I'd like to set a domain for the dropdown.

The problem is that if I bind the value set to the attribute, then also the original inputfield gets the same domain of the dropdown.


  DATA lo_nd_items TYPE REF TO if_wd_context_node.

  DATA lo_nd_items_info TYPE REF TO if_wd_context_node_info.

  DATA lo_el_items TYPE REF TO if_wd_context_element.

* navigate from <CONTEXT> to <ITEMS> via lead selection

  lo_nd_items = wd_context->path_get_node( path = `COMP_CONTEXT.ITEMS` ).

  lo_nd_items_info = lo_nd_items->get_node_info( ).



      NAME      = 'PRODUCT_ID'

      VALUE_SET = lt_product_ids.

This overrides the inputField's search help.

What I'm looking for is a way to set a value help for an element's attribute, so that I can distinguish whether the attribute is shown as Inputfield or Dropdown and bind the corresponding value set.

I can easily loop over the rows of the table but didn't find a way to set a value set for the specific attribute of an element.

Could anyone give me an idea ? thanks

Active Participant
0 Kudos

Instead of using SET_ATTRIBUTE_VALUE_SET to explicitly adding the value set, try using fixed values of the domain. In you will add the value set as fixed values in the domain, the dropdown will automatically pick the valueset from the domain.

Hope it helps.

0 Kudos

Hi Swati,

the scenario is a bit complex, so I'd better explain what's the difficulty I'm facing.

In my new column created using a cellVariant, I can have both an InputField or a DropdownByKey, depending on the item type.


row 1  Normal item -> inputfield (with a standard search help attached)

row 2  Special item -> Dropdown (I have to restrict values to few ones)

row 3  Normal item -> inputfield...

... and so on.

In Layout section, both InputField and DropDownByKey are binded to the same Context attribute (PRODUCT_ID).

I guess your last reply implies a modification of the domain of PRODUCT_ID, but this is not possible because there's already a standard search help bound to that field (which can extract all the admissible values from COMM_PRODUCT).

Googling a bit, I'm quite convinced up to now that there's no solution to this task; I should bind the dropdown to another attribute in order to differenciate possible values as every modification I set for the value set on the field directly reflects on the standard search help.

Thanks again for your support and inputs

Answers (0)