cancel
Showing results for 
Search instead for 
Did you mean: 

Delete row in tablecontrol through webdynpro

Former Member
0 Kudos

[http://www.blogger.com/post-create.g?blogID=6914282228603174052]

In the above link,

There is a delete icon.we want to select the particular row in table control and click the delete icon means the row should be deleted in the table control and in the database table.

Another one there is a deleteall button ,If we select all the row in table control and press the deleteall button all the row should be deleted in the table control and in the database table.

I need the sample code for my requirement.Please send me the example code to suit my requirement..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prabhubalraj,

I'm unable to open the link you provided. Still I will suggest my solution to your problem.

Just add two buttons Delete and Delete all in the view.

For Delete the action code is as follows


method ONACTIONDELETE .
  DATA: NODE TYPE REF TO IF_WD_CONTEXT_NODE,
        NUM  TYPE I,
        ITAB TYPE STANDARD TABLE OF IF_MAIN=>ELEMENT_KNA1_NODE.

  NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'KNA1_NODE' ).

  NODE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = ITAB ).


  NUM = NODE->GET_LEAD_SELECTION_INDEX( ).

  DELETE ITAB INDEX NUM.

  NODE->BIND_TABLE( ITAB ).

endmethod.

In the above code, I'm deleting in the internal table and updating the table control. I don't delete in the database for the matter I need my data. You can add an open sql statement for deleting from the database, fetching the key from the itab, as the selected index is available in NUM.

Similarly for delete all,


method ONACTIONDELETE_ALL .

  DATA: NODE TYPE REF TO IF_WD_CONTEXT_NODE,
        NUM  TYPE I,
        ITAB TYPE STANDARD TABLE OF IF_MAIN=>ELEMENT_KNA1_NODE.

  NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'KNA1_NODE' ).

  NODE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = ITAB ).

  CLEAR ITAB.

  NODE->BIND_TABLE( ITAB ).

endmethod.

In this code also I don't delete the records in database. Hope you can add the code easily.

Hope it would be useful to you.

Regards,

Fareez

Former Member
0 Kudos

[http://prabhuabap.blogspot.in/2012/02/webdynpro.html]

Please refer this link it will open now..

Former Member
0 Kudos

Hi Prabhu,

I saw the picture. I'll give you a solution similar to that using buttons.

While creating the node for the table, just add one more attribute for the button (i used boolean type). While binding make this field as button and bind the attribute to some unused property of button (I bound it to tooltip property of the button). Now on WDDOINIT I put the following code to initialize the data



method WDDOINIT .

  data: begin of stru,
          kunnr type kunnr,
          name1 type name1,
          butid type boolean,
        end of stru,
        itab like standard table of stru with key kunnr,
        node type ref to if_wd_context_node.

        node = wd_context->get_child_node( name = 'KNA1_NODE' ).

        select kunnr name1 from kna1 into corresponding fields of table itab.

        loop at itab into stru.
          stru-butid = 1.
          modify itab from stru.
        endloop.


        node->bind_table( itab ).

endmethod.

Now on the action of the button on the table. Add a code similar to the following one. Include your code for deleting from the database.


method ONACTIONDELETE_ROW .

  data: ind type i,
        itab type standard table of if_main=>element_kna1_node,
        node type ref to if_wd_context_node,
        elem type ref to if_wd_context_element.

  wdevent->get_context_element( exporting name ='CONTEXT_ELEMENT' receiving value = elem ).
  elem->get_index( receiving my_index = ind ).

  node = wd_context->get_child_node( 'KNA1_NODE' ).

  node->get_static_attributes_table( importing table = itab ).

  delete itab index ind.

  node->bind_table( itab ).

endmethod.

Now this will delete the corresponding row of which the delete button is pressed. And for delete all my previous post will work I suppose.

Hope it ll be useful for you. If you got the answer, please dont forget to close the thread.

Regards,

Fareez

Former Member
0 Kudos

Thanks alot .I got the answer.

Former Member
0 Kudos

I get the answer but in the t.code cv03n is not deleted.In my requirement if we delete here it should reflect in the t.code also.please send the sample code to delete the file...

Former Member
0 Kudos

I have no idea about cv03n. But in the solution I gave i don't delete in anything in the database, I delete only in the internal table. So if you want to delete something regarding cv03n, delete from the standard table that is associated with that tcode. Use ST05 to check which table cv03n access.

Former Member
0 Kudos

thanks for ur help

Answers (0)