cancel
Showing results for 
Search instead for 
Did you mean: 

Error while creating dynamic Table

Former Member
0 Kudos

Hi All,

I have a node 'SEG' with 3 attributes, ATTR1.2.3, I am tring to crate dynamic table using this context node. Initialy i am displaying view with button, when click on this button i want to create table dynamically.. if click again one more table i have to create.. its giving dump... here is the code... How to do this???

data: wd_node_info type ref to if_wd_context_node_info,

wd_node type ref to if_wd_context_node,

lr_container type ref to cl_wd_uielement_container,

lv_tablename type string,

lt_db_data type ref to data,

lr_table type ref to cl_wd_table.

field-symbols: <lt_data> type any table.

wd_node_info = wd_context->get_node_info( ).

wd_node = wd_context->get_child_node( name = 'SEG' ).

lr_container ?= view->get_root_element( ).

cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

" Creating internal table with the same structure as our dynamic

  • context node

CALL METHOD CL_WD_DYNAMIC_TOOL=>CREATE_TABLE_FROM_NODE

EXPORTING

UI_PARENT = lr_container

TABLE_ID = 'MY_TABLE'

NODE = wd_node

RECEIVING

TABLE = lr_table.

cl_wd_matrix_data=>new_matrix_data( element = lr_table ).

lr_table->bind_data_source( path = 'SEG' ).

Thanks'

Madhan.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Madhan,

As Sarbeet already pointed out, it is combination of error(s).

Lr_container, my_table are already existing when you are pressing the button more than one time. So make it for yourself clear why do you need a table UI more times in a view with exactly same data and columns ?

if you still stick to your approach then, set a check that you are not creating the lr_container if it is already existing. Moreover generate Table_id every time.

gill367
Active Contributor
0 Kudos

WT IS THE ERROR YOU ARE GETTING.

If it is coming at the second time when you are clicking the button then it will be because ID of the second time created table is same.

so you need to create an attribute for that and update the value everytime the button is clicked and pass it to ID so a new id will be created everytime.

how ever why you want to create more than one table bound to a single node, not a gud design approach.

wht is your requirement actually.

thanks

sarbjeet

Former Member
0 Kudos

Hi Sarbjeet,

Actually my requirement is,

1. When i click button, i want to add table dynamycally with one empty row with different ui elements like textview,inputfield,DDBYKEY,Button like that.

For this i follow this code and i am able to create table dynamically, but not properly with all ui elements. it create only text view( but i wrote code for input field)

METHOD WDDOMODIFYVIEW

DATA lr_table TYPE REF TO cl_wd_table.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.

DATA lr_container TYPE REF TO cl_wd_uielement_container.

DATA lr_column_name TYPE REF TO cl_wd_table_column.

DATA lr_text_view TYPE REF TO cl_wd_text_view.

DATA lr_input_field TYPE REF TO cl_wd_input_field.

DATA lr_button TYPE REF TO cl_wd_button.

DATA lr_dropdown TYPE REF TO cl_wd_dropdown_by_key.

DATA lr_table_header TYPE REF TO cl_wd_caption.

DATA lr_column_name_header TYPE REF TO cl_wd_caption.

IF first_time EQ abap_true.

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

lr_table = cl_wd_table=>new_table(

id = 'IT_DATA'

bind_data_source = 'DATA'

design = cl_wd_table=>e_design-alternating

visible_row_count = 1 ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element =

lr_table ).

lr_container->add_child( lr_table ).

lr_column_name = cl_wd_table_column=>new_table_column(

id = 'TBL_EXAMPLE_NAME' ).

lr_table_header ?= cl_wd_caption=>new_caption(

text = 'TABLE' ).

lr_table->add_column( the_column = lr_column_name ).

*lr_table->ADD_GROUPED_COLUMN( index = 1 THE_GROUPED_COLUMN = lr_column_name ).

lr_table->set_header( lr_table_header ).

lr_input_field = cl_wd_input_field=>new_input_field(

id = 'TXV_NAME'

bind_value = 'DATA.NAME' ).

lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME').

lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR =

lr_text_view ).

lr_column_name->set_header( lr_column_name_header ).

lr_table->add_column( the_column = lr_column_name ).

*lr_table->ADD_GROUPED_COLUMN( index = 2 THE_GROUPED_COLUMN = lr_column_name ).

lr_table->set_header( lr_table_header ).

lr_input_field = cl_wd_input_field=>new_input_field(

id = 'TXV_NAME'

bind_value = 'DATA.NAME2' ).

lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME2').

lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_input_field ).

lr_column_name->set_header( lr_column_name_header ).

endif.

Endmethod.

2. In first row i ahve created row with button also right, if i click this button i want to add one more row with same type of row but some changes like i want to change button name, text view name i want to fill DDBYKEY with different values like that???

For this requirement above followed approch is right??? or any onother way is there? and how to acive this??? please help in this..

Thanks and Regards,

Madhan.

Edited by: MadhanSAP on Jan 24, 2011 6:50 AM

Former Member
0 Kudos

Hi Sarbjeet,

Actually my requirement is,

1. When i click button, i want to add table dynamycally with one empty row with different ui elements like textview,inputfield,DDBYKEY,Button like that.

For this i follow this code and i am able to create table dynamically, but not properly with all ui elements. it create only text view( but i wrote code for input field).

METHOD WDDOMODIFYVIEW

DATA lr_table TYPE REF TO cl_wd_table.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.

DATA lr_container TYPE REF TO cl_wd_uielement_container.

DATA lr_column_name TYPE REF TO cl_wd_table_column.

DATA lr_text_view TYPE REF TO cl_wd_text_view.

DATA lr_input_field TYPE REF TO cl_wd_input_field.

DATA lr_button TYPE REF TO cl_wd_button.

DATA lr_dropdown TYPE REF TO cl_wd_dropdown_by_key.

DATA lr_table_header TYPE REF TO cl_wd_caption.

DATA lr_column_name_header TYPE REF TO cl_wd_caption.

IF first_time EQ abap_true.

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

lr_table = cl_wd_table=>new_table(

id = 'IT_DATA'

bind_data_source = 'DATA'

design = cl_wd_table=>e_design-alternating

visible_row_count = 1 ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element =

lr_table ).

lr_container->add_child( lr_table ).

lr_column_name = cl_wd_table_column=>new_table_column(

id = 'TBL_EXAMPLE_NAME' ).

lr_table_header ?= cl_wd_caption=>new_caption(

text = 'TABLE' ).

lr_table->add_column( the_column = lr_column_name ).

*lr_table->ADD_GROUPED_COLUMN( index = 1 THE_GROUPED_COLUMN = lr_column_name ).

lr_table->set_header( lr_table_header ).

lr_input_field = cl_wd_input_field=>new_input_field(

id = 'TXV_NAME'

bind_value = 'DATA.NAME' ).

lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME').

lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR =

lr_text_view ).

lr_column_name->set_header( lr_column_name_header ).

lr_table->add_column( the_column = lr_column_name ).

*lr_table->ADD_GROUPED_COLUMN( index = 2 THE_GROUPED_COLUMN = lr_column_name ).

lr_table->set_header( lr_table_header ).

lr_input_field = cl_wd_input_field=>new_input_field(

id = 'TXV_NAME'

bind_value = 'DATA.NAME2' ).

lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME2').

lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_input_field ).

lr_column_name->set_header( lr_column_name_header ).

endif.

Endmethod.

2. In first row i ahve created row with button also right, if i click this button i want to add one more row with same type of row but some changes like i want to change button name, text view name i want to fill DDBYKEY with different values like that???

For this requirement above followed approch is right??? or any onother way is there? and how to acive this??? please help in this..

Thanks and Regards,

Madhan.

Edited by: MadhanSAP on Jan 24, 2011 6:46 AM

gill367
Active Contributor
0 Kudos

First of all your code is creating two columns of same name and type because you are creating same colmun twice.

you need to modify the code as follows


DATA lr_table TYPE REF TO cl_wd_table.
DATA lr_flow_data TYPE REF TO cl_wd_flow_data.
DATA lr_container TYPE REF TO cl_wd_uielement_container.
DATA lr_column_name TYPE REF TO cl_wd_table_column.
DATA lr_column_name1 TYPE REF TO cl_wd_table_column.
DATA lr_text_view TYPE REF TO cl_wd_text_view.
DATA lr_input_field TYPE REF TO cl_wd_input_field.
DATA lr_button TYPE REF TO cl_wd_button.
DATA lr_dropdown TYPE REF TO cl_wd_dropdown_by_key.
DATA lr_table_header TYPE REF TO cl_wd_caption.
DATA lr_column_name_header TYPE REF TO cl_wd_caption.

IF first_time EQ abap_true.
lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
lr_table = cl_wd_table=>new_table(
id = 'IT_DATA'
bind_data_source = 'DATA'
design = cl_wd_table=>e_design-alternating
visible_row_count = 1 ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element =
lr_table ).
lr_container->add_child( lr_table ).

lr_column_name = cl_wd_table_column=>new_table_column(
id = 'TBL_EXAMPLE_NAME' ).
lr_table_header ?= cl_wd_caption=>new_caption(
text = 'TABLE' ).

lr_column_name1 = cl_wd_table_column=>new_table_column(
id = 'TBL_EXAMPLE_NAME1' ).


lr_table->add_column( the_column = lr_column_name ).
*lr_table->ADD_GROUPED_COLUMN( index = 1 THE_GROUPED_COLUMN = lr_column_name ).

lr_table->set_header( lr_table_header ).
lr_input_field = cl_wd_input_field=>new_input_field(
id = 'TXV_NAME'
bind_value = 'DATA.NAME' ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME').
lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR =
lr_text_view ).
lr_column_name->set_header( lr_column_name_header ).

lr_table->add_column( the_column = lr_column_name1 ).
*lr_table->ADD_GROUPED_COLUMN( index = 2 THE_GROUPED_COLUMN = lr_column_name ).

lr_input_field = cl_wd_input_field=>new_input_field(
id = 'TXV_NAME'
bind_value = 'DATA.NAME1' ).

lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME2').
lr_column_name1->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_input_field ).
lr_column_name1->set_header( lr_column_name_header ).

endif.

and for the main problem its very much possible to change the button text and entries of the dropdown

on the click of the button in one row.

what you need to do is

bind the text of the button element to attribute in the node and dropdown by key to the valuset of some attribute in the same node (do this dynamically).

now on click of the button add one element to the node with new entries.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

Thanks for your reply,

I am trying to create textview,dropdown,input and button ui elements, but i am getting all are as textveiw only... where is the problem,,

IF first_time EQ abap_true.

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

lr_table = cl_wd_table=>new_table( id = 'IT_DATA' bind_data_source = 'DATA'

design = cl_wd_table=>e_design-alternating visible_row_count = 1 ).

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

lr_container->add_child( lr_table ).

lr_table_header ?= cl_wd_caption=>new_caption( text = 'TABLE' ).

lr_column_name = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME' ).

lr_column_name1 = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME1' ).

lr_column_name2 = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME2' ).

lr_column_name3 = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME3' ).

              • TExt VIEW*********

lr_table->add_column( the_column = lr_column_name ).

lr_text_view= cl_wd_text_view=>new_text_view( id = 'TXV_NAME' bind_text = 'DATA.NAME' ).

lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME').

lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_text_view ).

lr_column_name->set_header( lr_column_name_header ).

***Drop down by key**********

lr_table->add_column( the_column = lr_column_name1 ).

lr_dropdown=cl_wd_dropdown_by_key=>NEW_DROPDOWN_BY_KEY( id = 'TXV_NAME1'

bind_selected_key = 'DATA.NAME1' ).

lr_column_name_header1 ?= cl_wd_caption=>new_caption( text = 'NAME1').

lr_column_name1->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_dropdown ).

lr_column_name1->set_header( lr_column_name_header1 ).

****Input field********

lr_table->add_column( the_column = lr_column_name2 ).

lr_input_field = cl_wd_input_field=>new_input_field( id = 'TXV_NAME2' bind_value = 'DATA.NAME2 ).

lr_column_name_header2 ?= cl_wd_caption=>new_caption( text = 'NAME2').

lr_column_name2->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_input_field ).

lr_column_name2->set_header( lr_column_name_header2 ).

****Button********

lr_table->add_column( the_column = lr_column_name3 ).

lr_button= cl_wd_button=>new_button( id = 'TXV_NAME3' bind_text = 'DATA.NAME3 on_action = 'NEW' ).

lr_column_name_header3 ?= cl_wd_caption=>new_caption( text = 'NAME3').

lr_column_name3->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_button).

lr_column_name3->set_header( lr_column_name_heade3 ).

Endif.

Edited by: MadhanSAP on Jan 24, 2011 8:01 AM

gill367
Active Contributor
0 Kudos

you are making soem syntax mistakes other wise code is fine.

Try using the following code.


IF first_time EQ abap_true.
lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
lr_table = cl_wd_table=>new_table(
id = 'IT_DATA'
bind_data_source = 'DATA'
design = cl_wd_table=>e_design-alternating
visible_row_count = 1 ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element =
lr_table ).
lr_container->add_child( lr_table ).


lr_table_header ?= cl_wd_caption=>new_caption(
text = 'TABLE' ).

lr_column_name = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME' ).
lr_column_name1 = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME1' ).
lr_column_name2 = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME2' ).
lr_column_name3 = cl_wd_table_column=>new_table_column( id = 'TBL_EXAMPLE_NAME3' ).


lr_table->add_column( the_column = lr_column_name ).


lr_text_view = cl_wd_text_view=>new_text_view(
id = 'TXV_NAME'
bind_text = 'DATA.NAME' ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME').
lr_column_name->set_table_cell_editor( THE_TABLE_CELL_EDITOR =
lr_text_view ).
lr_column_name->set_header( lr_column_name_header ).


****Drop down by key***********
lr_table->add_column( the_column = lr_column_name1 ).
lr_dropdown = cl_wd_dropdown_by_key=>NEW_DROPDOWN_BY_KEY(
id = 'TXV_NAME1'
bind_selected_key = 'DATA.NAME1' ).


lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME2').
lr_column_name1->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_dropdown ).
lr_column_name1->set_header( lr_column_name_header ).

*****Input field*********
lr_table->add_column( the_column = lr_column_name2 ).
lr_input_field = cl_wd_input_field=>new_input_field(
id = 'TXV_NAME2'
bind_value = 'DATA.NAME2' ).


lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME2').
lr_column_name2->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_input_field ).
lr_column_name2->set_header( lr_column_name_header ).

*****Button*********
lr_table->add_column( the_column = lr_column_name3 ).
lr_button = cl_wd_button=>new_button(
id = 'TXV_NAME3'
bind_text = 'DATA.NAME3'
on_action = 'NEW' ).


lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'NAME3').
lr_column_name3->set_table_cell_editor( THE_TABLE_CELL_EDITOR = lr_button ).
lr_column_name3->set_header( lr_column_name_header ).

Endif.


thanks

sarbjeet singh

Former Member
0 Kudos

Hi SArbjeet,

Sorry for doing such syntax mistakes,..

I tried with your code, but still facing same problem, getting all columns text views only(display).

Thanks,

Madhan.

gill367
Active Contributor
0 Kudos

HI

i used the same code and i am getting all the UI element.

check whether you have activated the view after updating the code and

do one thing put a break point in the code some where and see whether it is stopping there.

thanks

sarbjeet

Former Member
0 Kudos

Hi Sarbjeet,

The code is working fine, when i use in wddomodify view method without button click on first time.( I checked this by creating another component). But I am creating dynamic table when click on button(view contains one button initially), for this i created two attributes FLAG OF TYPE wdy_boolean and count of type int1. and in button action i write this code :

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_flag LIKE ls_context-flag.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->set_attribute(

name = `FLAG`

value = abap_true ).

DATA lv_count LIKE ls_context-count.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `COUNT`

IMPORTING

value = lv_count ).

lv_count = lv_count + 1.

lo_el_context->set_attribute(

EXPORTING

name = `COUNT`

value = lv_count ).

*******************************

and in wddomodify view method following code..

Method WDDOMODIFYVIEW

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_flag LIKE ls_context-flag.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `FLAG`

IMPORTING

value = lv_flag ).

DATA lv_count LIKE ls_context-count.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `COUNT`

IMPORTING

value = lv_count ).

if lv_flag = abap_true. ......

                      • Remaining code same post previously************8

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `FLAG`

value = abap_false ).

endif.

endmethod...

I created like this i am not getting other UI elements(input, ddbykey,button).

And if i click view button again it going to dump..

Thanks,

Madhan.

Former Member
0 Kudos

Hi Sarbjeet,

The code is working fine, when i use in wddomodify view method without button click on first time.( I checked this by creating another component). But I am creating dynamic table when click on button(view contains one button initially), for this i created two attributes FLAG OF TYPE wdy_boolean and count of type int1. and in button action i write this code :

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_flag LIKE ls_context-flag.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->set_attribute(

name = `FLAG`

value = abap_true ).

DATA lv_count LIKE ls_context-count.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `COUNT`

IMPORTING

value = lv_count ).

lv_count = lv_count + 1.

lo_el_context->set_attribute(

EXPORTING

name = `COUNT`

value = lv_count ).

*******************************

and in wddomodify view method following code..

Method WDDOMODIFYVIEW

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_flag LIKE ls_context-flag.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `FLAG`

IMPORTING

value = lv_flag ).

DATA lv_count LIKE ls_context-count.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `COUNT`

IMPORTING

value = lv_count ).

if lv_flag = abap_true. ......

                      • Remaining code same post previously************8

endif.

endmethod...

I created like this i am not getting other UI elements(input, ddbykey,button).

And if i click view button again it going to dump..

Thanks,

Madhan.

Edited by: MadhanSAP on Jan 24, 2011 10:13 AM

gill367
Active Contributor
0 Kudos

is it creating the elements first time or then also dump is coming.

put all the code in the wddomodify under the fi condition of first time and

by the way what is the dump . have you checked in the ST22.

go there and see what is ther ein the source extract.

thanks

sarbjeet

Former Member
0 Kudos

Hi Sarbjeet,

I solved this problem by creating new component, now the code is working fine, now problem is if i add one more dynamic table by clicking button, getting error "View Element with ID DATA in View MAIN Already Exists ". Help in this..

Thanks,

Madhan.

gill367
Active Contributor
0 Kudos

mate thats wht i am saying ..

why you are creatin a new table all together on click of the button. strange requirement.

how ever still if you want to do it.

use the count that you are updating everytime you are clicking on the button.

check to which UI element you are passing the ID DATA.

just write some logic there to make that ID unique for every case like as shown below.

data id type string value 'DATA' .
data count type string.

wd_context->get_attribute( 
name = 'COUNT'
value = count.
).

concatenate id count into id.
condense id.

now use this variable id to assign the ID to the UI element you are creating.

thanks

sarbjeet

Former Member
0 Kudos

Hi Sarbjeet..

Actually my requirement is like this...

IF user click ADD_SEG Button, it contains under SEG-NONC,SNONC and PART. I am trying to create this like..

if cilck on button.. displaying table with one row

SEG(Textview)-VALUE(DDBYK)-NAME1(INPUT)...NAME6(INPUT)-NONC(Button). If user click on NONC again i want to create row like this ...NONC1(Textview)-VALUE(DDBYK)-NAME1(INPUT)...NAME6(INPUT)-SNONC(Button)... If user click on SNOC Button i want to insert new row like this.. SNONC(Textview)-VALUE(DDBYK)-NAME1(INPUT)...NAME6(INPUT)-PART(Button)... If user click on PART i want to open one popup... In this DDBK i want to fill dynamically based on..SEG,NONC,SNONC.

In another case... If user click on NONC again i want to add one more row like this...

NONC2(Textview)-VALUE(DDBYK)-NAME1(INPUT)...NAME6(INPUT)-SNONC(Button).... and so..on

2. If user click on ADD_SEG button again i want to add one more table like this... and so on..

SEG1

--NONC

--SNONC

--PART

--NONC2

--SNONC

--PART

SEG2

--NONC

--SNONC

--PART

--NONC2

--SNONC

--PART

I think u understood about my requirement... if any thing requ let me know,,

I am Following approch is right or wrong?? can u suggest any another way for this please help me..

Thanks,

Madhan.

Edited by: MadhanSAP on Jan 24, 2011 11:22 AM

gill367
Active Contributor
0 Kudos

Hello Madan,

That is quite a complex requirement.

this you can achieve by two methods.

1. using the concept of transparent cantainer. in this you create everything dynamically and add it to the tranparent container.

means one table in your case will be one transparent container.

2. using the table concept, where you will add the element to the node that is bound to the table and new row will be created.

and when you want to create the new table itself then you need to create one more node also dynamically.

but which approach you should use depends on the way you are going to use the values of the input field and dropdown.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

My requirement is like this...

In view one button ADD_SEG. If clik on this i wnat to open one dynamic table contains one row like this...

CASE1:

SEG1(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-NONC(Button) - if user click on NONC button i want to open one more row like this...NONC(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-SNONC(Button)- if user click on SNONC i want to open one more row like this...SNONC1(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-PART(Button)--- if user click on PART i want to open one popup.

CASE2: If user click on NONC again i want to add one more row like this... NONC2(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-SNONC(Button)---if again on NONC -- NONC3(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-NONC(Button)... If user click on SNONC i want to add row like this... SNONC2(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-PART(Button)... and so..on.

Here DDBK i want to fill according to button... like ADD_SEG(Related values), NONC( RElated Values )... like that.

CASE3: If user click on ADD_SEG button again i want to add one more table like above.. and so on..

Hope you understand my requirement, anything require please let me know..

My approcing method is right or wrong??? or any anotherway to reach this type of requirement?? pelase help me in this...

Thanks,

Madhan.

Former Member
0 Kudos

Hi Sarbjeet

Thanks for your valuable suggestions,

1. By adding transparent container - means first i have to add transparent cont dynamycally and to this i want to add table dynamycally and so on ... right??? any sample code please..

2. Do u have any related code creating node and table dynamically??? any help please

Thanks,

Madhan

Edited by: MadhanSAP on Jan 24, 2011 1:01 PM

Edited by: MadhanSAP on Jan 25, 2011 8:35 AM

gill367
Active Contributor
0 Kudos

Hi

here is the code for creating node and its attribute dynamically and then creating a table based on them .

use this sample code.


data: wd_node_info type ref to if_wd_context_node_info,
wd_node type ref to if_wd_context_node,
lr_container type ref to cl_wd_uielement_container,
lv_tablename type string,
lt_db_data type ref to data,
lr_table type ref to cl_wd_table,
ls_attribute type wdr_context_attribute_info.

field-symbols: <lt_data> type any table.
wd_node_info = wd_context->get_node_info( ).

CALL METHOD WD_NODE_INFO->ADD_NEW_CHILD_NODE
EXPORTING
*STATIC_ELEMENT_TYPE = 'ZDEALER'
NAME = 'NODE'
IS_MULTIPLE = ABAP_TRUE
IS_INITIALIZE_LEAD_SELECTION = ABAP_FALSE
RECEIVING
CHILD_NODE_INFO = wd_node_info.

wd_node = wd_context->get_child_node( name = 'NODE' ).
wd_node_info = WD_node->GET_NODE_INFO( ).

data dyn_attr_info type wdr_context_attribute_info.

DYN_ATTR_INFO-NAME = 'X1'. "Attribute Name
DYN_ATTR_INFO-TYPE_NAME = 'STRING' ." Data Element(CHAR20) ( Type Of Attribute )
DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

DYN_ATTR_INFO-NAME = 'X2'. "Attribute Name
DYN_ATTR_INFO-TYPE_NAME = 'STRING' ." Data Element(CHAR20) ( Type Of Attribute )
DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_container ?= view->get_root_element( ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

" Creating internal table with the same structure as our dynamic context node
CALL METHOD CL_WD_table=>new_table
EXPORTING
bind_data_source = 'NODE'
ID = 'TABLE'

RECEIVING
control = lr_table.




cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).
*lr_table->bind_data_source( path = 'NODE' ).

data lr_table_col type ref to cl_wd_table_column.
data lr_table_col1 type ref to cl_wd_table_column.
data lr_text_view type ref to cl_wd_text_view.
data lr_input_field type ref to cl_wd_input_field.
DATA lr_column_name_header TYPE REF TO cl_wd_caption.


lr_input_field = cl_wd_input_field=>new_input_field(
bind_value = 'NODE.X1' ID = 'INP' ).
LR_TABLE_COL = cl_wd_table_column=>new_table_column( id = 'COL1' ).
lr_table->add_column( the_column = lr_table_col ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'X1').
lr_table_col->set_table_cell_editor(
THE_TABLE_CELL_EDITOR = lr_input_field ).
lr_table_col->set_header( lr_column_name_header ).


lr_text_view = cl_wd_text_view=>new_text_view(
bind_text = 'NODE.X2' ID = 'TXT' ).
LR_TABLE_COL1 = cl_wd_table_column=>new_table_column( id = 'COL2' ).
lr_table->add_column( lr_table_col1 ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'X2').
lr_table_col1->set_table_cell_editor(
THE_TABLE_CELL_EDITOR = lr_text_view ).
lr_table_col1->set_header( lr_column_name_header ).

lr_container->add_child( lr_table ).

cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).


thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

I created Node, attributes and table dynamycally. Table with one row one of the column contains button. If i click on this button i want to add one more row with some changes

SEG1(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-NONC(Button) - if i click on this button i want to add row like this..

NONC(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-SNONC(Button)--- and so on...

My doubt is actually we create node and attributes right, can we create any struct like this??? or how can solve this.. can u please help me.

Thanks,

Madhan.

Former Member
0 Kudos

Hi Sarbjeet,

I created Node, attributes and table dynamycally. Table with one row one of the column contains button. If i click on this button i want to add one more row with some changes

SEG1(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-NONC(Button) - if i click on this button i want to add row like this..

NONC(textview)-VALUE(DDBK)-NAME1(Input)-NAME2....NAME6-SNONC(Button)--- and so on...

I write code in wddomodifyview method, can we try like this

if <action-nonc>

i want to add new row with same like struct above..

endif.

My doubt is actually we create node and attributes right, can we create any struct like this??? or how can solve this.. can u please help me.

Thanks,

Madhan.

Edited by: MadhanSAP on Jan 27, 2011 12:31 PM

vishesh_malik
Participant
0 Kudos

Hi Madhan ,

You can use following code to declare a structure.

TYPES:

BEGIN OF ty_struct,

att_name TYPE string,

att_data TYPE string,

END OF ty_struct.

Could you specify more about your requirements ?

The code given by Sarabjeet is really good. But you are getting dump again on click of button because of same IDs of dynamically generated UI. For that use concatenation of some name such as for drop down you can use 'DDBK' with the counter that you are using (lv_count) . If you want to restrict the dynamic generation to click of button only then you can set the value of flag inside Handledefault method of windows. Just create mapping for the flag variable.

If you wanna know anything else , please specify only that part, so that I can help you for particular solution .

Is your requirement is to just add the rows into table or you also wanna implement delete functionality for dynamically generated UI ?

Vishesh