cancel
Showing results for 
Search instead for 
Did you mean: 

DYNAMIC INPUT FIELD AND CONTEXT

Former Member
0 Kudos

Hello experts,

I have a requirment where i need to create a dynamic input field and dynamic attributes, these attributes are to be binded with the dynamic input field.

help needed????????????

Immedate points rewarded.....

Thanks in Advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Can anyone plz provide the sample code to create a dynamic input field and dynamic attribute, the dynamic attribute should be binded to the input field.

Thanks in Advance.

Former Member
0 Kudos

Hi Suhail,

Try out the following code in WDDOMODIFYVIEW.

IF first_time = abap_true.

DATA: inp_fld type ref to cl_wd_input_field,

lbl type ref to cl_wd_label,

context_info type ref to if_wd_context_node_info,

attr_info type wdr_context_attribute_info,

root_container type ref to cl_wd_transparent_container.

context_info = wd_context->get_node_info( ).

attr_info-name = 'INP1'.

attr_info-type_name = 'STRING'.

CALL METHOD context_info->ADD_ATTRIBUTE

EXPORTING

attribute_info = attr_info.

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

inp_fld = cl_wd_input_field=>new_input_field( id = 'INP' bind_value = 'INP1').

lbl = cl_wd_label=>new_label( id = 'LBL' label_for = 'INP' ).

wd_context->set_attribute( name = 'INP1' value = 'DEFAULT' ).

CALL METHOD CL_WD_MATRIX_LAYOUT=>NEW_MATRIX_LAYOUT

EXPORTING

CONTAINER = root_container.

CALL METHOD CL_WD_MATRIX_HEAD_DATA=>NEW_MATRIX_HEAD_DATA

EXPORTING

ELEMENT = lbl.

CALL METHOD CL_WD_MATRIX_DATA=>NEW_MATRIX_DATA

EXPORTING

ELEMENT = inp_fld.

root_container->add_child( lbl ).

root_container->add_child( inp_fld ).

ENDIF.

Thanks and Regards,

Saravana. S

Answers (3)

Answers (3)

Former Member
0 Kudos

It worked.

thanks.

Former Member
0 Kudos

I have written the following code in modifyview but it throws a <b> NULL</b> error when i bind the dynamic attribute to the input field.

Thanks in advance.

data:

m_input_field type ref to cl_wd_input_field.

data: m_label type ref to cl_wd_label.

DATA:

*Node Info

rootnode_info TYPE REF TO if_wd_context_node_info.

data: dyn_node TYPE REF TO if_wd_context_node.

data: test type string.

rootnode_info = wd_context->get_node_info( ).

data: lr_carrid_attr_info TYPE wdr_context_attribute_info.

lr_carrid_attr_info-name = 'CARRID'.

lr_carrid_attr_info-type_name = 'STRING'.

CALL METHOD rootnode_info->ADD_ATTRIBUTE

EXPORTING

attribute_info = lr_carrid_attr_info.

data:

lr_container type ref to cl_wd_transparent_container,

lr_dropdown type ref to cl_wd_dropdown_by_key.

  • let's do it only once

  • check first_time = abap_true.

  • get a pointer to the RootUIElementContainer

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

  • lets create a label and an input field and add both to the container

  • m_label = cl_wd_label=>new_label( id = 'LABEL1' label_for = 'TXT' ).

wd_context->set_attribute( name = 'CARRID' value = 'text' ).

m_input_field = cl_wd_input_field=>new_input_field( id = 'TXT' ).

m_input_field->BIND_VALUE( 'CARRID' ).

  • lr_container->add_child( m_label ).

lr_container->add_child( m_input_field ).

Former Member
0 Kudos

Hi Suhail,

Could you tell the exact error you are getting because a similar code works perfectly fine for me.

Thanks and Regards,

Saravana. S

S-H
Active Participant
0 Kudos

Hi,

In order to create the context obtain the node info of a node(or root node if you want to create the context below root context) by calling get_node_info(). There you can add a new child node or attributes by calling the corresponding methods. like add_new_child_node, add_attribute etc.

Refer the following blog for creating the UI elements(input field) dynamically:

<a href="/people/thomas.szcs/blog/2006/02/22/dynamic-programming-in-web-dynpro-abap--part-iii-aggregations-and-ddic-binding-of-viewelements:///people/thomas.szcs/blog/2006/02/22/dynamic-programming-in-web-dynpro-abap--part-iii-aggregations-and-ddic-binding-of-viewelements

Also refer:

<a href="/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements:///people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements<a href="/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements:///people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements

Best regards,

Suresh