cancel
Showing results for 
Search instead for 
Did you mean: 

Adding rows to table

Former Member
0 Kudos

Hi All,

I want to add 2 rows(Records) to table, after doing some action.(clicking on button), and i want to display some default data. i have context. i know by using bind_element we create one record, empty record.

But i want to add 2 records and with some values, how to create and how to fill data??

Thanks,

Kris.

Accepted Solutions (0)

Answers (2)

Answers (2)

gill367
Active Contributor
0 Kudos

Hi

Suppose in the context you have node TABNOD with three attribute X1, X2, X3 having string type.

and this node is bound to the table's data source.

then use the following code to add two rows with sample data to table.

basically we will create one table with tabnode structure and bind it to the node after filling two rows in it as shown below.

DATA  LR_NODE TYPE REF TO if_wd_context_node.
 DATA ls_data TYPE wd_this->element_TABNOD.
    data lt_data type wd_this->elements_TABNOD.
lr_node = wd_context->get_child_node( ' TABNOD ').

ls_data-X1 = 'abc1'.
ls_data-X2 = 'DEF1'.
ls_data-X3 = 'XYZ1'.

APPEND LS_DATA TO LT_dATA.

ls_data-X1 = 'abc2'.
ls_data-X2 = 'DEF2'.
ls_data-X3 = 'XYZ2'.

APPEND LS_DATA TO LT_dATA.


LR_NODE->BIND_TABLE( LT_DATA ).

this will bind the node with a table having two rows with the data.

and will eb shown in the table UI .

thanks

sarbjeet

Former Member
0 Kudos

Hi

Thanks for your help.

I doubt.. Suppose if i want to fill any dropdown(defalut values) or if i want to create any button action, suppose in once colum contains button i want to create on_action and write some code how to do using this struct?

Thanks,

Kris.

Former Member
0 Kudos

Hi

Thanks for your help.

I doubt.. Suppose if i want to fill any dropdown(defalut values) or if i want to create any button action, suppose in once colum contains button i want to create on_action and write some code how to do using this struct?

Thanks,

Kris.

gill367
Active Contributor
0 Kudos

dropdown you can fill by creating a value set and filling it with different values and then assigning the valueset to the

attribute.

also button you can create but its on_action you cannot give diiferent for different rows.

it will be same for all the rows.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi

In above code suppose at column 'X1' i want button action, how to add on_action in the above code?

button in cloumn means every row contains button and contains some action right?? how to differentiate actions here? is it possible?

Tahnks,

kris.

Former Member
0 Kudos

Hi

In above code suppose at column 'X1' i want button action, how to add on_action in the above code?

button in cloumn means every row contains button and contains some action right?? how to differentiate actions here? is it possible?

Tahnks,

kris.

Former Member
0 Kudos

Hi ,

All the buttons will have same action . But you can try to distinguish differnt rows in the "on click" handler of the button , based on some attrribute value of the element selected(lead selected).

So what you can do is ,

1.)Get the lead selected element.

2.)Read all attributes of the lead selected element.

3.)Based on one of the attributes(which probably should be different for each element) , perform different actions.

Thanks,

Aditya.

gill367
Active Contributor
0 Kudos

HI

yeah as told in th eabove post all the buttons will have same action and in the eventhandler you can write some logic to

know from which element it is coming like as shown below.

DATA: lr_element TYPE REF TO if_wd_context_element,
  lv_index_table TYPE i.


   DATA lo_nd_zdealer TYPE REF TO if_wd_context_node.
   DATA lo_el_zdealer TYPE REF TO if_wd_context_element.
   DATA ls_zdealer TYPE wd_this->element_zdealer.
*  navigate from <CONTEXT> to <ZDEALER> via lead selection
   lo_nd_zdealer = wd_context->get_child_node( name = wd_this->wdctx_zdealer ).

*  get element via lead selection
   lo_el_zdealer = lo_nd_zdealer->get_element(  ).

 lv_index_table = lo_el_zdealer->get_index( ).

here you can then use lv_index_table to know the row number from which the button has been clicked.

thanks

sarb

sahai
Contributor
0 Kudos

hi kissna,

i hope that you must be having those two records in internal table this statement will help you..

DATA LO_ND_CTX_VN_ALV TYPE REF TO IF_WD_CONTEXT_NODE.

LO_ND_CTX_VN_ALV->BIND_TABLE( IT_ZDF_TBL_PM_ADDL ).

where IT_ZDF_TBL_PM_ADDL will be your internal table...

regards,

sahai.s