cancel
Showing results for 
Search instead for 
Did you mean: 

How to add atrributes to dynamic node?

Former Member
0 Kudos

Hi Gurus,

I am creating dynamic table with dynamic node and attributes. i am using following 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.

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 = lv_tablename

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' ).

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 = 'TABLE'

NODE = wd_node

RECEIVING

TABLE = lr_table.

cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).

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

It creates empty table.. how to add columns and elements like text view and input fields... Please help

Thanks in advance,

venkat.

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

also you can add columns like input field and text view using the following sample cod..

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_col->set_table_cell_editor( lr_input_field ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'x1').
lr_table_col->set_header( lr_column_name_header ).

lr_table->add_column( lr_table_col ).

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_col1->set_table_cell_editor( lr_text_view ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'X2').
lr_table_col1->set_header( lr_column_name_header ).

lr_table->add_column( lr_table_col1 ).

cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).

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

thanks

sarbjeet

Former Member
0 Kudos

Hi singh

Thanks for ur help. I added your code and tried to create node, attributes and table dynamically, i am getting error at ADD_CHILD( ), i tried by debugging but i am not getting, can u please look at this once...

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 = lv_tablename

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_CONTEXT->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_DYNAMIC_TOOL=>CREATE_TABLE_FROM_NODE

EXPORTING

UI_PARENT = lr_container

TABLE_ID = 'TABLE'

NODE = wd_node

RECEIVING

TABLE = 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_table->add_column( lr_table_col ).

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_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_table->add_column( lr_table_col1 ).

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_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 ).

cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).

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

Thanks

Venkat.

gill367
Active Contributor
0 Kudos

Hi

Lr_container where u r intializing it.

means where are you setting its value . ADD THIS BEFORE ADDING THE TABLE.

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

THANKS

Former Member
0 Kudos

Hi

By adding this statement also getting error.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

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

*lr_container ?= view->get_root_element( ).

cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

I added before creating table. is it right place???

Thanks

venkat.

gill367
Active Contributor
0 Kudos

what is the exact error that you are getting.

can you paste the same here.

thanks

sarb

Former Member
0 Kudos

Hi Sarbjeet

Here is the error...

Note

The following error text was processed in the system DC1 : Access via 'NULL' object reference not possible.

The error occurred on the application server TC01SMX_DC1_00 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: NEW_MATRIX_LAYOUT of program CL_WD_MATRIX_LAYOUT===========CP

Method: NEW_MATRIX_LAYOUT of program CL_WD_MATRIX_LAYOUT===========CP

Method: WDDOMODIFYVIEW of program /1BCWDY/KMBYJIN2OYGOL83020F8==CP

Method: IF_WDR_VIEW_DELEGATE~WD_DO_MODIFY_VIEW of program /1BCWDY/KMBYJIN2OYGOL83020F8==CP

Method: DO_MODIFY_VIEW of program CL_WDR_DELEGATING_VIEW========CP

Method: MODIFY_VIEW of program CL_WDR_VIEW===================CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Method: DO_MODIFY_VIEW of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW=================CP

Thanks,

Venkat

gill367
Active Contributor
0 Kudos

go to st22 and there check the source code extract.

and paste that also .

also double click on the code there, put a break point there and run the application again and check which

value is coming as null.

thanks

sarbjeet

Former Member
0 Kudos

Hi

Code from st22.

Information on where terminated

Termination occurred in the ABAP program "CL_WD_MATRIX_LAYOUT==========

in "NEW_MATRIX_LAYOUT".

The main program was "SAPMHTTP ".

In the source code you have the termination point in line 3

of the (Include) program "CL_WD_MATRIX_LAYOUT===========CM004".

Source Code Extract

Line SourceCde

1 method NEW_MATRIX_LAYOUT.

2 >>>>> CREATE OBJECT control EXPORTING view = container->view id = id.

4 control->_num_bound_attributes = 0.

5 control->vl_STRETCHED_HORIZONTALLY = STRETCHED_HORIZONTALLY.

6 control->vl_STRETCHED_VERTICALLY = STRETCHED_VERTICALLY.

7 container->set_LAYOUT( the_LAYOUT = control ).

8 9 endmethod.

Thanks,

Venkat.

gill367
Active Contributor
0 Kudos

set the root container layout type as matrix layout in the design and then use this code .

i have modified it a bit.


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

use it

thanks

Edited by: sarbjeet singh on Jan 25, 2011 3:13 PM

Edited by: sarbjeet singh on Jan 25, 2011 3:14 PM

Former Member
0 Kudos

Thanks Sarbjeet.

In this code we are creating 2 attributes one is input and other is textview but after executing table contains only text view?? no input? why? any reason??

Thanks,

venkat.

Edited by: venkat1011 on Jan 25, 2011 11:29 AM

Edited by: venkat1011 on Jan 25, 2011 11:50 AM

Answers (5)

Answers (5)

Former Member
0 Kudos

.

Former Member
0 Kudos

open

gill367
Active Contributor
0 Kudos

HI

it is creatin the input field and text box both.

the thing is you havenot filled any element in the node so it is showing disabled input field.

for checking the creation of the input field.

modify the creation of the node method like shown below..

one more parameter is_mandatory has been added.

CALL METHOD WD_NODE_INFO->ADD_NEW_CHILD_NODE
EXPORTING
*STATIC_ELEMENT_TYPE = 'ZDEALER'
NAME = 'NODE'
IS_MANDATORY = abap_true                      "this will create one element automatically
IS_MULTIPLE = ABAP_TRUE
IS_INITIALIZE_LEAD_SELECTION = ABAP_FALSE
RECEIVING
CHILD_NODE_INFO = wd_node_info.

thanks

sarb

Former Member
0 Kudos

Hi sarb

one last question... can we add table header, table toolbar like normal table???

I tried to add caption using

table_header ?= cl_wd_caption=>new_caption( text = 'Table'). but i am not getting caption. how to get it???

Thanks,

Venkat.

gill367
Active Contributor
0 Kudos

have you added the header to the table using

lr_table->set_header( table_header ).

regards,

Sarb

Former Member
0 Kudos

hI Sarb

IS_MANDATORY = abap_true is create one element automatically,

suppose i want to create 2 more inputfields or any other ui elements. how to create elements(edit mode) ???

Thanks,

venkat.

gill367
Active Contributor
0 Kudos

you can use this kind of code for adding more elements to the node.

data lr_tbl type table of line.

line-str1 = 'X1X1'.
line-str2 = 'X2X2'.

append line to lr_tbl.

line-str1 = 'X3X1'.
line-str2 = 'X4X2'.

append line to lr_tbl.

 data lo_node type ref to if_wd_context_node.
 LO_NODE = WD_CONTEXT->GET_CHILD_NODE( 'NODE' ).
LO_node->bind_table( lr_tbl ).

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

Already we created attributes and columns also..

CALL METHOD WD_NODE_INFO->ADD_NEW_CHILD_NODE

EXPORTING

*STATIC_ELEMENT_TYPE = 'ZDEALER'

NAME = 'NODE'

IS_MANDATORY = abap_true

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( ).

DYN_ATTR_INFO-NAME = 'X!'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'STRING' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

where to add these lines again???

Thanks,

venkat.

gill367
Active Contributor
0 Kudos

after creating the node and the attribute you need to add the elements also to the node.

In my above post i have given a sample code for the same. add it after the node and attribute creation code.

thanks

sarbjeet

Former Member
0 Kudos

Hi Sarbjeet,

ITs giving error, Field LINE-STR1 does not exist in the new version.

Doubt : So, I need to add element for every attribute i created under node? right?

But initial we created two attributes X1 and X2 and created table with these attributes, it create table with non edit. i created 2 more attributes and i am trying to add columns to table but its giving error. at add_child().???for first 2 attributes also we are not created any elements? but table created without error, while tring to add one more giving error???

Thanks,

Venkat.

Edited by: venkat1011 on Jan 27, 2011 6:18 AM

gill367
Active Contributor
0 Kudos

paste your full code of wddomodify here.

thanks

sarbjeet

Former Member
0 Kudos

Hi sarbjeet

I am trying to creating element like this... after adding every attribute.. but getting error.

DYN_ATTR_INFO-NAME = 'NODE'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'STRING' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

Here complete code to create node,attributes and table dynamycally, and i write this code in wddomodifyview 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.

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.

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_MANDATORY = abap_true

IS_MULTIPLE = ABAP_TRUE

IS_INITIALIZE_LEAD_SELECTION = ABAP_FALSE

RECEIVING

CHILD_NODE_INFO = wd_node_info.

  • Get instance of new node

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.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.

DATA lr_table_header TYPE REF TO cl_wd_caption.

data lr_element TYPE REF TO if_wd_context_element.

DYN_ATTR_INFO-NAME = 'NAME'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'STRING' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

                • ADDED to create element********

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

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

DYN_ATTR_INFO-NAME = 'VALUE'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'STRING' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

                • ADDED to create element********

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

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

DYN_ATTR_INFO-NAME = 'ADDRESS'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'CHAR20' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

                • ADDED to create element********

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

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

DYN_ATTR_INFO-NAME = MARKS'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'CHAR4' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

lr_container ?= view->get_root_element( ).

*cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( 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'

design = cl_wd_table=>e_design-alternating

visible_row_count = 1

RECEIVING

control = lr_table.

lr_table_header ?= cl_wd_caption=>new_caption(

text = 'TABLE').

lr_table->set_header( lr_table_header ).

data lr_table_col type ref to cl_wd_table_column.

data lr_table_col1 type ref to cl_wd_table_column.

data lr_table_col2 type ref to cl_wd_table_column.

data lr_table_col3 type ref to cl_wd_table_column.

data lr_table_col4 type ref to cl_wd_table_column.

data lr_table_col5 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_input_field1 TYPE REF TO cl_wd_input_field.

DATA lr_input_field2 TYPE REF TO cl_wd_input_field.

DATA lr_input_field3 TYPE REF TO cl_wd_input_field.

DATA lr_input_field4 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_column_name_header TYPE REF TO cl_wd_caption.

lr_text_view = cl_wd_text_view=>new_text_view(

bind_text = 'NODE.NAME' ID = 'TXT' ).

LR_TABLE_COL1 = cl_wd_table_column=>new_table_column( id = 'COL1' ).

lr_table->add_column( lr_table_col1 ).

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

lr_table_col1->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_text_view ).

lr_table_col1->set_header( lr_column_name_header ).

lr_input_field = cl_wd_input_field=>new_input_field(

bind_value = 'NODE.VALUE' ID = 'INP' ).

LR_TABLE_COL = cl_wd_table_column=>new_table_column( id = 'COL2' ).

lr_table->add_column( the_column = lr_table_col ).

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

lr_table_col->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_input_field ).

lr_table_col->set_header( lr_column_name_header ).

lr_input_field1 = cl_wd_input_field=>new_input_field(

bind_value = 'NODE.ADRESS' ID = 'INP1' ).

LR_TABLE_COL = cl_wd_table_column=>new_table_column( id = 'COL3' ).

lr_table->add_column( the_column = lr_table_col1 ).

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

lr_table_col->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_input_field1 ).

lr_table_col->set_header( lr_column_name_header ).

lr_input_field1 = cl_wd_input_field=>new_input_field(

bind_value = 'NODE.MARKS' ID = 'INP2' ).

LR_TABLE_COL = cl_wd_table_column=>new_table_column( id = 'COL4' ).

lr_table->add_column( the_column = lr_table_col1 ).

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

lr_table_col->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_input_field1 ).

lr_table_col->set_header( lr_column_name_header ).

lr_container->add_child( lr_table ).

*cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element =

lr_table ).

endif.

endmethod.

Thanks,

Venkat.

gill367
Active Contributor
0 Kudos

paste it inside the code quotes

 .....    

to help others understand.

this way its not readable

thanks

sarbjeet

Former Member
0 Kudos

Hi Sarbjeet,

I dont know how to paste complete code normal format... i am psting by two posts, please dont mind.

Complete code..

METHOD WDDOMODIFYVIEW

if first_time = abap_true.

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.

wd_node_info = wd_context->get_node_info( ).

CALL METHOD WD_NODE_INFO->ADD_NEW_CHILD_NODE

EXPORTING

NAME = 'NODE'

IS_MANDATORY = abap_true

IS_MULTIPLE = ABAP_TRUE

IS_INITIALIZE_LEAD_SELECTION = ABAP_FALSE

RECEIVING

CHILD_NODE_INFO = wd_node_info.

  • Get instance of new node

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.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.

DATA lr_table_header TYPE REF TO cl_wd_caption.

data lr_element TYPE REF TO if_wd_context_element.

DYN_ATTR_INFO-NAME = 'NAME'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'STRING' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

DYN_ATTR_INFO-NAME = 'VALUE'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'STRING' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

DYN_ATTR_INFO-NAME = 'ADD'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'CHAR20' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

DYN_ATTR_INFO-NAME = 'MARKS'. "Attribute Name

DYN_ATTR_INFO-TYPE_NAME = 'CHAR4' .

DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE

EXPORTING

ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).

wd_node->bind_element( new_item = lr_element

set_initial_elements = abap_false ).

lr_container ?= view->get_root_element( ).

*cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( lr_container ).

Edited by: venkat1011 on Jan 27, 2011 8:27 AM

Edited by: venkat1011 on Jan 27, 2011 8:32 AM

Former Member
0 Kudos

....continues

CALL METHOD CL_WD_table=>new_table

EXPORTING

bind_data_source = 'NODE'

ID = 'TABLE'

design = cl_wd_table=>e_design-alternating

visible_row_count = 1

RECEIVING

control = lr_table.

lr_table_header ?= cl_wd_caption=>new_caption(

text = 'Demand Planning' ).

lr_table->set_header( lr_table_header ).

data lr_table_col type ref to cl_wd_table_column.

data lr_table_col1 type ref to cl_wd_table_column.

data lr_table_col2 type ref to cl_wd_table_column.

data lr_table_col3 type ref to cl_wd_table_column.

data lr_table_col4 type ref to cl_wd_table_column.

data lr_table_col5 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_input_field1 TYPE REF TO cl_wd_input_field.

DATA lr_input_field2 TYPE REF TO cl_wd_input_field.

DATA lr_input_field3 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_column_name_header TYPE REF TO cl_wd_caption.

lr_text_view = cl_wd_text_view=>new_text_view(

bind_text = 'NODE.NAME' ID = 'TXT' ).

LR_TABLE_COL1 = cl_wd_table_column=>new_table_column( id = 'COL1' ).

lr_table->add_column( lr_table_col1 ).

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

lr_table_col1->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_text_view ).

lr_table_col1->set_header( lr_column_name_header ).

lr_input_field = cl_wd_input_field=>new_input_field(

bind_value = 'NODE.VALUE' ID = 'INP' ).

LR_TABLE_COL2 = cl_wd_table_column=>new_table_column( id = 'COL2' ).

lr_table->add_column( the_column = lr_table_col2 ).

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

lr_table_col2->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_input_field ).

lr_table_col2->set_header( lr_column_name_header ).

lr_input_field1 = cl_wd_input_field=>new_input_field(

bind_value = 'NODE.ADD' ID = 'INP1' ).

LR_TABLE_COL3 = cl_wd_table_column=>new_table_column( id = 'COL3' ).

lr_table->add_column( the_column = lr_table_col3 ).

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

lr_table_col3->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_input_field1 ).

lr_table_col3->set_header( lr_column_name_header ).

lr_input_field1 = cl_wd_input_field=>new_input_field(

bind_value = 'NODE.MARKS' ID = 'INP2' ).

LR_TABLE_COL4 = cl_wd_table_column=>new_table_column( id = 'COL4' ).

lr_table->add_column( the_column = lr_table_col4 ).

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

lr_table_col4->set_table_cell_editor(

THE_TABLE_CELL_EDITOR = lr_input_field1 ).

lr_table_co4l->set_header( lr_column_name_header ).

lr_container->add_child( lr_table ).

*cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_table ).

lr_flow_data = cl_wd_flow_data=>new_flow_data( element =

lr_table ).

endif.

endmethod.

Thanks,

Venkat.

Edited by: venkat1011 on Jan 27, 2011 9:20 AM

Edited by: venkat1011 on Jan 27, 2011 9:32 AM

gill367
Active Contributor
0 Kudos

Hi

ok we will divide the code in two methods..

put the code for creation of the node, attributes and elements in the wddoinit method. like as shown below.

method WDDOINIT .
  data: wd_node_info type ref to if_wd_context_node_info,
wd_node type ref to if_wd_context_node,
lv_tablename type string,
lt_db_data type ref to data,
ls_attribute type wdr_context_attribute_info.

wd_node_info = wd_context->get_node_info( ).

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

* Get instance of new node
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.
data lr_element TYPE REF TO if_wd_context_element.

DYN_ATTR_INFO-NAME = 'NAME'. "Attribute Name
DYN_ATTR_INFO-TYPE_NAME = 'STRING' .
DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).
wd_node->bind_element( new_item = lr_element
set_initial_elements = abap_false ).

DYN_ATTR_INFO-NAME = 'VALUE'. "Attribute Name
DYN_ATTR_INFO-TYPE_NAME = 'STRING' .
DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).
wd_node->bind_element( new_item = lr_element
set_initial_elements = abap_false ).

DYN_ATTR_INFO-NAME = 'ADD'. "Attribute Name
DYN_ATTR_INFO-TYPE_NAME = 'CHAR20' .
DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

lr_element = wd_node->create_element( ).
wd_node->bind_element( new_item = lr_element
set_initial_elements = abap_false ).

DYN_ATTR_INFO-NAME = 'MARKS'. "Attribute Name
DYN_ATTR_INFO-TYPE_NAME = 'CHAR4' .
DYN_ATTR_INFO-NODE_INFO = wd_node_info.

CALL METHOD wd_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

data : begin of line,
  str1(20) type c,
  str2(20) type c,
  chr1(20) type c,
  chr2(4)  type c,
  end of line.
data lr_tbl type table of line.
append line to lr_tbl.
append line to lr_tbl.
append line to lr_tbl.

 data lo_node type ref to if_wd_context_node.
 LO_NODE = WD_CONTEXT->GET_CHILD_NODE( 'NODE' ).
LO_node->bind_table( lr_tbl ).




endmethod.

and in the wddomodify create table and bound it to the node as follow in the next post

gill367
Active Contributor
0 Kudos

.... continues..

method WDDOMODIFYVIEW .
  if first_time = abap_true.

 data:
lr_container type ref to cl_wd_uielement_container,
lt_db_data type ref to data,
lr_table type ref to cl_wd_table.

DATA lr_flow_data TYPE REF TO cl_wd_flow_data.
DATA lr_table_header TYPE REF TO cl_wd_caption.


lr_container ?= view->get_root_element( ).

*cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
lr_flow_data = cl_wd_flow_data=>new_flow_data( lr_container ).

CALL METHOD CL_WD_table=>new_table
EXPORTING
bind_data_source = 'NODE'
ID = 'TABLE'
design = cl_wd_table=>e_design-alternating
visible_row_count = 5
RECEIVING
control = lr_table.

lr_table_header ?= cl_wd_caption=>new_caption(
text = 'Demand Planning' ).
lr_table->set_header( lr_table_header ).
data lr_table_col type ref to cl_wd_table_column.
data lr_table_col1 type ref to cl_wd_table_column.
data lr_table_col2 type ref to cl_wd_table_column.
data lr_table_col3 type ref to cl_wd_table_column.
data lr_table_col4 type ref to cl_wd_table_column.
data lr_table_col5 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_input_field1 TYPE REF TO cl_wd_input_field.
DATA lr_input_field2 TYPE REF TO cl_wd_input_field.
DATA lr_input_field3 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_column_name_header TYPE REF TO cl_wd_caption.

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

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

lr_input_field1 = cl_wd_input_field=>new_input_field(
bind_value = 'NODE.ADD' ID = 'INP1' ).
LR_TABLE_COL = cl_wd_table_column=>new_table_column( id = 'COL3' ).
lr_table->add_column( the_column = lr_table_col1 ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'ADRESS').
lr_table_col->set_table_cell_editor(
THE_TABLE_CELL_EDITOR = lr_input_field1 ).
lr_table_col->set_header( lr_column_name_header ).

lr_input_field1 = cl_wd_input_field=>new_input_field(
bind_value = 'NODE.MARKS' ID = 'INP2' ).
LR_TABLE_COL = cl_wd_table_column=>new_table_column( id = 'COL4' ).
lr_table->add_column( the_column = lr_table_col1 ).
lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'MARKS').
lr_table_col->set_table_cell_editor(
THE_TABLE_CELL_EDITOR = lr_input_field1 ).
lr_table_col->set_header( lr_column_name_header ).

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

endif.

endmethod.

thanks and Regards,

Sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

Thanks for your support.

No need to create 'Line' to create element, actually i did some mistakes in col names. i given LR_TABLE_COL1,2,3,4.. like that, and now it working fine.

Thanks,

Venkat.

gill367
Active Contributor
0 Kudos

Yeah using create element also it will create.

thanks

sarbjeet singh

gill367
Active Contributor
0 Kudos

you can add the attribute using the add_attribute function of the node_info as shown below.

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 = lr_node_info.

CALL METHOD lr_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 = lr_node_info.

CALL METHOD lr_node_info->ADD_ATTRIBUTE
EXPORTING
ATTRIBUTE_INFO = DYN_ATTR_INFO.

thanks

sarbjeet

Former Member
0 Kudos

CALL METHOD WD_NODE_INFO->ADD_NEW_CHILD_NODE

EXPORTING

STATIC_ELEMENT_TYPE = lv_tablename

NAME = 'NODE'

IS_MULTIPLE = ABAP_TRUE

IS_INITIALIZE_LEAD_SELECTION = ABAP_FALSE

RECEIVING

CHILD_NODE_INFO = wd_node_info.

i am not sure that the child_node_info receiving is referring the WD_NODE_INFO, should it not be node_info of the child node you create ?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

CREATE_TABLE_FROM_NODE should be creating columns for each attribute in the bound node. Check the coding at the end of this method. Have you looked in the debugger to see if your dynamic node is created correctly? Or perhaps you might consider using the ALV instead of the table so that you don't even have to bother with the dynamic creation of the UI elements.