cancel
Showing results for 
Search instead for 
Did you mean: 

Context binding error in Dynamic UI element creation

0 Kudos

Hi,

I am new to Webdynpro. I am trying to build an app for dynamic table data in an ALV,so creating an input field for table name dynamically.

I am facing a issue while binding the dynamic input field to the dynamically created context node attribute. The error description is: ERROR: Error in INPUT_FIELD "IF" of view "ZVK_DYNAMIC1.MAIN": Context binding of property VALUE cannot be resolved: The MAIN.1.INPUT node does not contain any elements (termination: RABAX_STATE).


Following is the code written in wdinit( ) method and wdmodifyview( ) method of the view controller.

METHOD wddoinit .

   DATA: lr_root_node_info  TYPE REF TO if_wd_context_node_info.

   DATA: lr_input_node_info TYPE REF TO if_wd_context_node_info.

   DATA: ls_attribute_info  TYPE wdr_context_attribute_info.

   lr_root_node_info = wd_context->get_node_info( )" get the root node

   CALL METHOD lr_root_node_info->add_new_child_node

     EXPORTING

       name                         = 'INPUT'

       is_multiple                  = abap_false

       is_multiple_selection        = abap_false

*      is_initialize_lead_selection = abap_false

     RECEIVING

       child_node_info              = lr_input_node_info.

   CLEAR ls_attribute_info.

   ls_attribute_info-name          = 'TABLE_NAME'.

   ls_attribute_info-type_name     = 'STRING'.

   CALL METHOD lr_input_node_info->add_attribute

     EXPORTING

       attribute_info = ls_attribute_info.


ENDMETHOD.


METHOD wddomodifyview .

   DATA: lr_ui_root     TYPE REF TO if_wd_view_element.

   DATA: lr_container   TYPE REF TO cl_wd_uielement_container.

   DATA: lr_input_field TYPE REF TO cl_wd_input_field.

   DATA: lr_flow_data   TYPE REF TO cl_wd_flow_data.

   IF first_time EQ 'X'.

     lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

     CALL METHOD cl_wd_input_field=>new_input_field

       EXPORTING

*       activate_access_key        =

*       alignment  = E_ALIGNMENT-AUTO

*       bind_alignment             =

*       bind_display_as_text       =

*       bind_display_only          =

*       bind_enabled               =

*       bind_ime_mode              =

*       bind_input_prompt          =

*       bind_length                =

*       bind_password_field        =

*       bind_read_only             =

*       bind_state =

*       bind_style_class_name      =

*       bind_suggest_filter_method =

*       bind_suggest_values        =

*       bind_suppress_value_help   =

*       bind_text_direction        =

*       bind_tooltip               =

         bind_value = 'INPUT.TABLE_NAME'

*       bind_visible               =

*       bind_width =

*       context_menu_behaviour     = E_CONTEXT_MENU_BEHAVIOUR-INHERIT

*       context_menu_id            =

*       date_picker_reference_id   =

*       display_as_text            =

*       display_only               =

*       enabled    = 'X'

*       explanation                =

         id         = 'IF'

*       ime_mode   = E_IME_MODE-AUTO

*       input_prompt               =

*       length     = '20'

*       multi_field_suggest        =

*       no_history =

*       on_enter   =

*       on_table_paste             =

*       password_field             =

*       read_only  =

*       state      = E_STATE-NORMAL

*       style_class_name           =

*       suggest_filter_method      =

*       suggest_values             =

*       suppress_value_help        =

*       text_direction             = E_TEXT_DIRECTION-INHERIT

*       tooltip    =

*       view       =

*       visible    = E_VISIBLE-VISIBLE

*       width      =

       RECEIVING

         control    = lr_input_field.

     CALL METHOD cl_wd_flow_data=>new_flow_data

       EXPORTING

*       cell_design = E_CELL_DESIGN-PADLESS

         element = lr_input_field

*       id      =

*       v_gutter    = E_V_GUTTER-NONE

       RECEIVING

         control = lr_flow_data.

*

     CALL METHOD lr_input_field->set_layout_data

       EXPORTING

         the_layout_data = lr_flow_data.

     CALL METHOD lr_container->add_child

       EXPORTING

*       index     =

         the_child = lr_input_field.

   ENDIF.

ENDMETHOD.


Please help.


Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Check the cardinality of the node INPUT. seems you have given 1..n/1..n . use 0..n cardinality.

Regards,

Kiran

0 Kudos

Hi,

i have tried that option too(gave is_multiple = abap_true), it gives the same error while running.  I guess the cardinality should be 1..1 because this node INPUT is used for taking the table name through the attribute TABLE_NAME.

ramakrishnappa
Active Contributor
0 Kudos

Hi Vishal,

Actually, for an input field the node should be with cardinality either 1...1 / 1...n. i.e. at least one element should exist. So you need to pass "is_mandatory = abap_true" while creating node.

Please modify your code as below

CALL METHOD lr_root_node_info->add_new_child_node

     EXPORTING

       name                         = 'INPUT'

       is_mandatory = abap_true

       is_multiple                  = abap_false

       is_multiple_selection        = abap_false

*      is_initialize_lead_selection = abap_false

     RECEIVING

       child_node_info              = lr_input_node_info.


Hope this helps you.


Regards,

Rama

0 Kudos

It worked..Thanks a lot. But i have one doubt when we add a context node statically, the UI element is created properly with the dynamic binding.

former_member184578
Active Contributor
0 Kudos

Hi,

For table you have to use 0..n/1..n cardinality. But here, in your example, you are not using a table, you are just creating one input field and binding it to a context node with 0..n cardinality!!

Create a table and then bind the table to the context node, then create a column with cell editor as input field and then bind it to the respective attribute

You can check this doc as reference:

Regards,

Kiran

0 Kudos

I am passing abap_false to parameter is_multiple. I got the problem now, seems like an element is created only when we pass is_mandatory = abap_true which is required for binding.

ramakrishnappa
Active Contributor
0 Kudos

Hi Vishal,

You are welcome

The node can be made as static, where no further changes allowed to the node definition.

Regards,

Rama

Answers (0)