cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete multiple line items

baskaran00
Active Participant
0 Kudos

Hi Experts,

I would like to delete multiple line items from my table in Web dynpro for ABAP.

I could able to delete single line item only.

How to delete multiple line items???

FYI... I'm using foll. code to delete single row

lo_el_flight_list = lo_nd_flight_list->get_element( ).

call method lo_nd_flight_list->remove_element

exporting

element = lo_el_flight_list.

Valuable answers will be rewarded.

Thanks...

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi router....

what you can do is......

once the delete button is clicked......

make use of the method, get_selected_elements in the interface if_wd_context_node....

get all the rows, delete it from internal table and bind it again to the table.

---regards,

alex b justin

baskaran00
Active Participant
0 Kudos

Justin,

I added the following code

data : sets type WDR_CONTEXT_ELEMENT_SET,

wa like LINE OF sets.

call method lo_nd_flight_list->get_selected_elements

receiving

set = sets.

loop at sets into wa.

lo_el_flight_list = lo_nd_flight_list->get_element( ).

call method lo_nd_flight_list->remove_element

exporting

element = lo_el_flight_list.

endloop.

I could loop it. But I couldnt able to delete.

Can you correct me if i'm wrong in the code.

Thanks...

Former Member
0 Kudos

hi router.......

do not use the method......

read the table into an itab.......

delete the records from itab and bind it back again to the table.

---regards,

alex b justin

baskaran00
Active Participant
0 Kudos

Hi Justin,

U r right, but how can i get the indexs to delete multiple rows???

Thansks,

Router

thomas_szcs
Active Contributor
0 Kudos

Hello Router,

you can get the index for each element returned by get_selected_elements() by calling get_index() at the element itself.

Btw: Binding the data again is only recommended for small data. Moreover, you will lose the content of sub nodes by doing so as well as any additional data maintained by the web dynpro runtime.

Best regards,

Thomas

baskaran00
Active Participant
0 Kudos

Thomas,

I tried using get_index, then only i could able to get only the current index.

Can u help me out.

Thanks,

Router

former_member515618
Active Participant
0 Kudos

Hi Router,

The mistake in the code snippet you attached is that you are passing the lead selected(Last selected in case of multiple selections) recore every time by doing get_element.

Do the following and it should work.

loop at sets into wa.

Call method lo_nd_flight_list->remove_element

exporting element = wa.

endloop.

sets is a table type of WDR_CONTEXT_ELEMENT_SET with line reference IF_WD_CONTEXT_ELEMENT.

and the export parameter wa is also of type IF_WD_CONTEXT_ELEMENT. .

The sets holds instances of all the elements selected. So when read into wa we hold the reference of the indivudial element which we are trying to remove. So pass that reference of the element to the the exporting parameter 'element'.