cancel
Showing results for 
Search instead for 
Did you mean: 

Adding new rows of UI elements dynamically on click of a buttion

UmaArjunan
Active Participant
0 Kudos

WD experts, 

Requirement:     On every click of a buttion Say ADD set of UI element should appear in the screen with empty values.

But it is copying the values of previous UI elements. This is happnening for every click. the previous values are copied. I have kept views in the Multipane.

My first set (block) in the UI element contains some value. On click of a buttion the second block copies the value of the first blcok Acually the second block of UI elements should be emtpy. I m missing something.  I have used the following piece of code :

ls_add points to the structure available in the context.

For action button 'Add'.
        CLEAR ls_add.
        node_add->get_static_attributes_table( IMPORTING table = lt_add ).
        APPEND ls_add TO lt_add.
*    ENDDO.
        node_add->bind_table( lt_add).

How do i clear values of new UI elements ? Please Let me know if the requirement is not clear.

Thanks,

ABAP Dev

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Instead of the approach you have used above just create an element and bind it to the node.

1. Use CREATE_ELEMENT method of the node

2. Use BIND_ELEMENT method of the node.

UmaArjunan
Active Participant
0 Kudos

Thanks for your reply. I have referred some of your thread replies and tried to solve it. But it didnt work out for me.

i tried the following as suggested by you

* get element via lead selection


  elem_add = node_add->create_element).
  node_add->bind_element( elem_add ).

Instead of adding it overwrites the existing one but with the blank values.

I want to the existing UI elements with values. and the other should be empty when a new row is added. Do i have to add anything to the above coding ??

That is the reason i used that get_static_attributes tables.. Please help to resolve this.

Message was edited by: ABAP Dev

Former Member
0 Kudos

What is the cardinality of the node you have bound to the Multipane? It should be <x>:n.

UmaArjunan
Active Participant
0 Kudos

Cardinality is 1 : N

Cardinality : 1.

* get element via lead selection
  elem_add = node_add->create_element(  ).
  node_add->bind_element(  elem_add ).

-------> for this Overwrites the exsitng UI elements with blank values.

  node_add->bind_element( new_item =  elem_add

  set_initial_elements = abap_false ).

------->For this New items added, but copying the contents of previous values

Message was edited by: ABAP Dev

Former Member
0 Kudos

Oh Okie, I think i understood the problem.

BIND_ELEMENT method has a parameter SET_INITIAL_ELEMENTS which is defaulted to ABAP_TRUE.

Call this method like this

node_add->bind_element( new_item = elem_add      set_initial_elements = abap_false  ).

UmaArjunan
Active Participant
0 Kudos

but values are copied, I want blank values for new row added. This is developed SAP Netweaver 7.0 version. Is that an issue ?

Former Member
0 Kudos

I tried to replicate your example and it works perfectly fine for me.

I am not really sure if this is due to the version. I am using 702.

You can try one more thing.

Write this piece of code AFTER bind_element.

elem_irl_amount->set_static_attributes_null( ).

UmaArjunan
Active Participant
0 Kudos

i tried with stati_attributes_null. But then empty values is not coming. If it may be due to version issue ,

Is there any SAP notes available ? Please suggest

Former Member
0 Kudos

I am not aware of any SAP Notes for this.

UmaArjunan
Active Participant
0 Kudos

Can i use set_static_attributes_null for the extra row added in the Node ?

if i use in the Node , i should use index .. How to use set_static_attributes_null( ) for a node with index ?

Former Member
0 Kudos

You can use it with the node.

However i am doubtful that would work either because it does the same thing as with the element.

To use it u just have to write

node_add->set_static_attributes_null( 2 ). If the 2nd element has to be set to Null.

Or

node_add->set_static_attributes_null( EXPORTING index = 2 ).

amy_king
Active Contributor
0 Kudos

Hi,

Instead of creating a new element and binding it to the node, try calling method node->bind_structure. You will need to specify set_initial_elements = false to avoid overwriting the existing elements, but all importing parameters for this method are optional so you don't need to pass an explicit initial element.

Cheers,

Amy