cancel
Showing results for 
Search instead for 
Did you mean: 

Add Dynamic Input field

Former Member
0 Kudos

Hi...Experts am new in ABAP Webdynpro. Actually my application is Add Dynamic Input Field in webdynpro. Already One lable, one Input field is there and I add one more button. When I click that button Dynamically Adding same like existing lable and inputfield.Can anyone tel me how to resolve my problem.

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

You can add the input field and label in the screen in the initially during the design and and make them invisible by setting the property visibilty to none. Bind the visiblity property of the UI elements (label and input field in your case) to one context attribute of type WD_Visibility. then on the click of button you can control the visibility by changing the value of context attribute.

OR

the other way is adding the UI element at the runtime dynamically, by wirting the code in the WDDOMODIFY method.

for this you have to get the ROOTUIELEMENT container and add the element there.

Let me know if you need code for these things.

Sarbjeet Singh,

Former Member
0 Kudos

Hi Sarbjeet singh,

I want to generate an Input Field UI element on click of a button.

Please provide me code if u have.

Regards,

Yugesh A.

gill367
Active Contributor
0 Kudos

HI yugesh,

You can start a new thread for your problem.

Thanks

Sarbjeet

Former Member
0 Kudos

Hi Yugesh,

Refer below link.

It deals with the "How to add Input Field dynamically".

For further reference regarding Dynamic Programming, Please go through document

1. 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

2. 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

3. 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

Second link can help you a lot.

Thanks,

Prahsant

Edited by: Prashant Jagdale (Genius) on Jan 6, 2011 5:30 PM

Former Member
0 Kudos

Hi..Yugesh

U will try this,Definitly Ul get Answer.

For Dynamically creating Attribute

DATA : rootnode_info TYPE REF TO if_wd_context_node_info,

dyn_node_info TYPE REF TO if_wd_context_node_info,

dyn_node TYPE REF TO if_wd_context_node.

DATA : dyn_attr_info TYPE wdr_context_attribute_info.

dyn_attr_info-name = 'NAME'. Attribute Name

dyn_attr_info-DEFAULT_VALUE = 'Prakash'. +Iam Setting Default value of attribute,u can change as per ur requirement +

dyn_attr_info-type_name = 'ZDE_NAME' . Data Element(CHAR20) ( Type Of Attribute )

rootnode_info = wd_context->get_node_info( ).

CALL METHOD rootnode_info->add_attribute

EXPORTING

attribute_info = dyn_attr_info.

This will create a attribute at run time...

For Dynamically creating Input Field

DATA lr_container TYPE REF TO cl_wd_uielement_container.

DATA lr_input TYPE REF TO cl_wd_input_field.

DATA lr_table TYPE REF TO cl_wd_table.

DATA lo_nd_sflight TYPE REF TO if_wd_context_node.

DATA lr_button TYPE REF TO cl_wd_button.

DATA lr_grid_data TYPE REF TO cl_wd_grid_data.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.

DATA lr_matrix TYPE REF TO cl_wd_matrix_head_data.

+Note : Before that change the Layout of ROOTUIELEMENTCONTAINER to MATRIX LAYOUT +

  • navigate from <CONTEXT> to <SFLIGHT> via lead selection

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

CALL METHOD cl_wd_input_field=>new_input_field

EXPORTING

bind_value = 'NAME' + attribute which i created above+

id = 'INPUT1'

RECEIVING

control = lr_input.

lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data( lr_input ).

lr_input->set_layout_data( lr_matrix ).

CALL METHOD lr_container->add_child

EXPORTING

index = 1

the_child = lr_input.

ENDIF.

Code it in WDDOMODIFYVIEW...

Former Member
0 Kudos

Hi Sarbjeet Singh,

                            My requirement is:  I have two buttons on a view - If I click on the first button, only then, an input field must be created dynamically ( not by using visible - invisible functionality ). So, we will write the code to generate an input field in wddomodify(). When I did so, I was getting an input field whenever I clicked on any of these two buttons. But, I want to generate an input field iff the first button is pressed but not the second. How to check which button is clicked, to create an input field accordingly ?

Thanks in advance!

Siva

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi...

I solved my problem. Your answer is very helpful Thanku...

abhimanyu_lagishetti7
Active Contributor
0 Kudos

data: lr_image type ref to cl_wd_image.

data: lr_container type ref to cl_wd_transparent_container.

data: lr_flow_data type ref to cl_wd_flow_data.

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

lr_image = cl_wd_image=>new_image( source = lv_url view = view ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element = lr_image ).

lr_container->add_child( lr_image ).

code it in WDDOMODIFYVIEW.

this code is to create a dynamic image ui element, similarly you can add Labels and Inputfield.

Label : CL_WD_LABEL

Input Field: CL_WD_INPUT_FIELD

Note that the layout of ROOTUIELEMENT is FLOW.

Abhi