cancel
Showing results for 
Search instead for 
Did you mean: 

problem in adding a new row in a table.. plsss hlppp

Former Member
0 Kudos

Hi Friends,

I have a table defaulted to 4 rows. I have a add button to add a new row in the table.

When i have already 4 rows in table, and when i click add its adding that 5th row correctly( and i used set_lead_selection for this new row ).

But i want to automatically make a next page once i hit the ADD button here. Each time now i m hitting next page then only able to see hte 5th row. I need once ADD is clicked, i want to see the 5th row visible..

Can someone tell me how to code or do this

thanks friends,,,

Niraja

Accepted Solutions (1)

Accepted Solutions (1)

pranav_nagpal2
Contributor
0 Kudos

hii nirija,

if you want to see first row as fifth row on click of add button what you can do is set the global variable i have suggested in previous post to a table property firstvisiblerow. say if you have set the firstvisiblerow to 4 what it will do is it will make your 5th row the first row in the table page...

regards

pranav

Edited by: Pranav Nagpal on Dec 8, 2008 7:29 AM

Answers (3)

Answers (3)

pranav_nagpal2
Contributor
0 Kudos

hi nirija,

make a global or local variable say icount.

now when you are reading the data from database to display it in the table use

DESCRIBE TABLE itab1_info LINES lv_lines.

it will fetch you number of lines in your internal table into variable lv_lines....

now set the icount = lv_lines.......

now set this icount dynamically once in the number of row visible property...

now when you click on add button increment the global variable icount and again set the default number of rows visible to that icount......

hope this will help

regards

pranav

Former Member
0 Kudos
Former Member
0 Kudos

amit i dont want to edit the table.. i want the new record which i added to be visible .. when the visible page is filled ... i see only when i go to next page..

Arjun,

I did same as ur code, only diff is in bind_table i didnt used initial values.. will that work ?

will tbat go to the newly added row?

niraja

arjun_thakur
Active Contributor
0 Kudos

hi niraja,

yes, it'll work. This code works for me. i am sure it'll solve your problem as well.

regards

arjun

Former Member
0 Kudos

Hi Arjun,

I tried that.

elem_servprod = node_servprod->create_element( ).

elem_servprod->get_static_attributes(

IMPORTING

static_attributes = stru_servprod ).

node_servprod->bind_structure(

EXPORTING

new_item = stru_servprod

set_initial_elements = abap_false ).

v_lines = v_lines + 1.

node_servprod->set_lead_selection_index( EXPORTING

index = v_lines ).

But its not working for me... it says cannot set lead selection index 2.

can u tell me how it has to be done?

Niraja

Former Member
0 Kudos

ok

arjun_thakur
Active Contributor
0 Kudos

hi,

do you want to see all the 5 rows in the same page or do you want to see the 5th row in the next page of the table.

Former Member
0 Kudos

see i defaulted to 4 rows in the table. when i add 5th row and hit ADD button its creating a new row. But to see that new row i have to click next page ... when i hit it then only i am able to ssee it..

But i want to see it once i hit add button...

Niraja

Former Member
0 Kudos

Hi

Niraja,

Change row count to more than 4 and uncheck display empty rows.

Or bind the row count property with a attribute and keep increasing this value after addding each row.

arjun_thakur
Active Contributor
0 Kudos

hi niraja,

Just change the VISIBLEROWCOUNT property of the table to -1.

this will make your table dynamic. so when you'll click on add, 5th row will be visible on the same page.

regards

Former Member
0 Kudos

Guys sorry if i am not making u to understand my issue..

I want my table to be defaulted to 4 visible row count. OK.

now suppose in my table i already have data of 4 records.

I want to add a new row.. i click ADD button(new record is getting created ).

But to see that record i m clicking the next page button of the table(footer). this i dont want to do.

whenever i click ADD.. the table's first visible row should become 5th row. To check previous 4 rows's i can go with previous page of table(footer).

-1 visiblerowcount doesnt work for me.. ..

so hope now its clear.

kindly help.

niraja

arjun_thakur
Active Contributor
0 Kudos

hi niraja,

Plz refer to the following code:

method onactiononadd .

node_material type ref to if_wd_context_node.

elem_material type ref to if_wd_context_element.

stru_material type sflight.

node_material = wd_context->get_child_node( name = 'ANNA' ).

elem_material = node_material->get_element( ).

if ( elem_material is initial ).

call method node_material->create_element

receiving

element = elem_material.

endif.

call method elem_material->get_static_attributes

importing

static_attributes = stru_material .

call method node_material->bind_structure

exporting

new_item = stru_material

set_initial_elements = abap_false.

endmethod.

i hope it helps

regards

arjun