cancel
Showing results for 
Search instead for 
Did you mean: 

new Rows in a table?

MarkusRest
Participant
0 Kudos

Hi folks....

I searched the web, I searched the Wiki, but I still have the following problem:

Im new to Webdynpros, and I only made the NET310 - course....

Now I have want to develop an input-table ...

I built a view, mapped the context (in this example its 'sflight' ) and wanted to insert 2 Rows.

But the only thing I can do is filling the first row ....

I can imagine, I have to create and bind a 'second row' to the context, but how do I do that?

thanks in advance..

best regards

Markus Voelker

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you want insert the 2 rows into db table, then you have to call get_static_Attributes_table method of context node, to get all the values of 2 rows into e.g lt_node table. And then Use insert statement to insert the records into the db table. You have to create a button on screen like 'save'. And on the propeties of 'save', there is one property 'OnAction', create that and give some name of the method suppose save. Then go inside the method and follow the steps which i mentioned abobe.

If you just want to display suppose 2 rows from your db table, then in the wddoinit method, use

select * from db_table into table lit_itab.
lt_node->bind_Table( lit_itab ).

In context, create a node and refer it to db structure/table(from where you are fetching/inserting the records) and then bind the table control to this context node.

Hope it works..

MarkusRest
Participant
0 Kudos

ok you got me wrong...

lets say it this way:

I made a table on the view in the webdynpro, and set the visible lines to 20.

Now I want the user to put in some Data.

But he can only input the first line.

He cant either select nor input something into the second line....

That means: I see 20 Lines, of the correct structure, but Im not able to put Data in all 20 lines.

What do I do wrong?

(I dont want to get data from the DB into the table, but I want the user to put in Data, which I will store in the DB! )

Edited by: Markus Voelker on Nov 11, 2008 6:26 PM

Former Member
0 Kudos

hi,

What i understood , U want to disply 20 lines of table on view. and u want first line editable to user only. when u click on any button it got saved. so next time when u open that application , that table filled up with that data as at second line. and first line again with editable format where user can enter.

right?

saurin shah

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi.

You can use the following code to make your table rows editable.

DATA lo_nd_cn_try TYPE REF TO if_wd_context_node.

DATA lo_el_cn_try TYPE REF TO if_wd_context_element.

DATA ls_cn_try TYPE wd_this->element_cn_try.

DATA ls_cn_try1 TYPE wd_this->elements_cn_try.

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

lo_nd_cn_try = wd_context->get_child_node( name = wd_this->wdctx_cn_try ).

do 5 times.

clear ls_cn_try.

append ls_cn_try to ls_cn_try1.

lo_nd_cn_try->bind_table( ls_cn_try1 ).

enddo.

s_cn_try1 = UI element

cn_try = node name

I hope this would help you.

Thanx.

Edited by: saurav mago on Nov 12, 2008 6:05 AM

MarkusRest
Participant
0 Kudos

Hi saurav..

Thx for your help! 6 points to you ...

Another thing:

If I want to APPEND a line to the 5 your code makes, I do have to get all the data from the table, and then append a line, correct?

thx in advance

EDIT:

Yeah,

got it!

For everyone searching for the same problem:

-


"FLUG" is my node in Context, and it is a structure of sflight.....

*INSERTING ONE ROW TO AN EXISTING TABLE:

DATA lo_nd_sflight TYPE REF TO if_wd_context_node.

DATA lo_el_sflight TYPE REF TO if_wd_context_element.

DATA ls_sflight TYPE wd_this->element_flug.

DATA lt_sflight type table of sflight.

lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_flug ).

lo_nd_sflight->get_static_attributes_table(

IMPORTING

table = lt_sflight

).

CLEAR ls_sflight.

APPEND ls_sflight TO lt_sflight.

lo_nd_sflight->bind_table( lt_sflight ).

-


Edited by: Markus Voelker on Nov 12, 2008 8:50 AM

former_member188831
Contributor
0 Kudos

Hi Saurav,

this is fine, in the same fashion if i increase the rows in dynamic like at runtime i may click add few more rows.. do i need to use again bind_table ??

hope this is okay, but in case of interactive forms like i have a pdf table then how to handle to add the rows ?

Thanks,

Mahesh.Gattu

Former Member
0 Kudos

Hi Markus,

There are n number of ways you can add row to a table. One is bind table with node and you can keep on inserting in your internal table. Also to add new row to table at runtime you always need not to get all the data in internal table and then again bind it to the node what you can do is just add an element to the node and set your new data in a structure with this new element. Code goes like this:

data: lv_node type ref to if_wd_context_node,

lv_elem type ref to if_wd_context_element,

ls_struc type xxx. (Where xxx is the structure of your node element).

Get the instance of the node in lv_node.

lv_elem = lv_node->create_element( ).

populate ls_struc with your data for new row.

lv_elem->set_static_attributes( static_attributes = ls_struc ).

lv_node->bind_element( NEW_ITEM = lv_elem SET_INITIAL_ELEMENTS = abap_false ).

Regards,

Neha