cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete a selected line from table using index?

Former Member
0 Kudos

Hi ,

I want to delete a selected record from a table using the index how can i do that??

Can u please help me regarding this with the code or any relative document.

Thanks,

Deepika

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi deepika....

you can just read the attribute using code wizard... which returns you the index....

then using the index delete the record in teh internal table using

delete <itab> index <i>.

then bind it again to the node.

---regards,

alex b justin

Former Member
0 Kudos

Hi Alex ,

From ur answer i got some idea but i have some more doubt ,

Can u please tell me ur mail id so that i can mail u my doubt?

Thanks,

Deepika

Former Member
0 Kudos

hi deepika.....

you can ask here itself so that others will also be benifited....

---regards,

alex b justin

Former Member
0 Kudos

Hi Alex,

Can i use this code for getting the index of the selected line??????

for eg:

  • alternative access via index

  • lo_el_infty_tab = lo_nd_infty_tab->get_element( index = 1 ).

  • @TODO handle non existant child

  • IF lo_el_infty_tab IS INITIAL.

  • ENDIF.

and in

" DATA: lo_el_infty_tab TYPE REF TO if_wd_context_element."

is "loel_infty_tab"_ my internal table??

Thanks,

Deepika

Former Member
0 Kudos

hi deepika.........

first read the attribute using code wizard....

you will be getting the index.

then use the method get_static_attributes_table in the class if_wd_context_node.

it returns the value to an internal table taht you pass.

now delete the record using index.

now bind it again to the node using bind_table().

---regards,

alex b justin

Former Member
0 Kudos

Hi Alex,

I have tried what u have told in previous reply..... but i have doubt....

please check the code ... what ever i m doing is correct or not ??

Actually i m just a beginner in Web Dynpro world...

Code::::::::::::::::::

DATA lo_nd_z_rfc_prv_emp0023_ge TYPE REF TO if_wd_context_node.

DATA lo_nd_changing TYPE REF TO if_wd_context_node.

DATA lo_nd_infty_tab TYPE REF TO if_wd_context_node.

DATA lo_el_infty_tab TYPE REF TO if_wd_context_element.

DATA ls_infty_tab TYPE wd_this->element_infty_tab .

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

lo_nd_z_rfc_prv_emp0023_ge = wd_context->get_child_node( name = wd_this->wdctx_z_rfc_prv_emp0023_ge ).

  • navigate from <Z_RFC_PRV_EMP0023_GE> to <CHANGING> via lead selection

lo_nd_changing = lo_nd_z_rfc_prv_emp0023_ge->get_child_node( name = wd_this->wdctx_changing ).

  • navigate from <CHANGING> to <INFTY_TAB> via lead selection

lo_nd_infty_tab = lo_nd_changing->get_child_node( name = wd_this->wdctx_infty_tab ).

  • @TODO handle not set lead selection

IF lo_nd_infty_tab IS INITIAL.

ENDIF.

*

    • get element via lead selection

  • lo_el_infty_tab = lo_nd_infty_tab->get_element( ).

*

    • @TODO handle not set lead selection

  • IF lo_el_infty_tab IS INITIAL.

  • ENDIF.

  • alternative access via index

lo_el_infty_tab = lo_nd_infty_tab->get_element( index = 1 ).

  • @TODO handle non existant child

IF lo_el_infty_tab IS INITIAL.

ENDIF.

  • get all declared attributes

lo_el_infty_tab->get_static_attributes(

IMPORTING

static_attributes = ls_infty_tab ).

if sy-subrc = 0.

DELETE ???????????????? INDEX ??????????.

endif.

lo_nd_infty_tab->Bind_Table( ????????????? ).

Note: Which internal table's record i need to delete????

Former Member
0 Kudos

hi deepika....

check this:



  DATA lo_nd_po TYPE REF TO if_wd_context_node.
  DATA lo_el_po TYPE REF TO if_wd_context_element.
  DATA ls_po TYPE wd_this->element_po.
* navigate from <CONTEXT> to <PO> via lead selection
  lo_nd_po = wd_context->get_child_node( name = wd_this->wdctx_po ).

* @TODO handle not set lead selection
  IF lo_nd_po IS INITIAL.
  ENDIF.

* get element via lead selection
  lo_el_po = lo_nd_po->get_element(  ).

* @TODO handle not set lead selection
  IF lo_el_po IS INITIAL.
  ENDIF.

* alternative access  via index
* lo_el_po = lo_nd_po->get_element( index = 1 ).
* @TODO handle non existant child
* IF lo_el_po IS INITIAL.
* ENDIF.

* get all declared attributes
  lo_el_po->get_static_attributes(
    IMPORTING
      static_attributes = ls_po ).

data:
       i1 type i.
lo_el_po->get_index( i1).

lo_nd_po->get_static_attributes_table( itab ).

delete itab index i1.

lo_nd_po->bind_table( itab ).

---regards,

alex b justin

Former Member
0 Kudos

Hi Alex,

My problem got solved.

Thanks a lot to u....

Now can i get ur mail id....?????

In future ,if i have any doubt means i can ask u so that u ll reply me through the forum....

now i have one more doubt...

Answers (2)

Answers (2)

Former Member
0 Kudos

This is deleting the record from that internal table but it is not deleting the record from the Data base table.

So for deleting the record what i need to do???

Former Member
0 Kudos

hi deepika.........

you can now read teh index... so using that you read the primary key....

eg:

your database table has empid as teh primary key,

then

read table <itab> into <wa> index i1.

delete from <dbtab> where <field> = <wa-empid>.

my personal id is: jalexjustin@gmail.com

---regards,

alex b justin.

Former Member
0 Kudos

Hi Alex ,

Once again Thanx a lot ....

my problem got solved.

Former Member
0 Kudos

Hey deepika,

i got the same issue iam able delete the line items on the screen using method remove element but unable to delete in DB?

any help?

Former Member
0 Kudos

Hi Deepika,

You can additionally try using the supply function and capture the selected row into an internal table in the context and read the context element back in the action and delete the captured row from you main table and then rebind it across

and Alex has advised.

regds,

Srini