Skip to Content
author's profile photo Former Member
Former Member

to delete a row when selected from table view and press delete button.

dear all,

ive a requirement when we select a row from table view and press delete button it should get deleted from database

.please give me step by step procedure how to do this.ihve tried debugging using the examples from post but did not understand . i am new to bsp.please help.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 11:01 AM

    Hi Sushani.

    Please refer the sample code below this will delete the enteries from internal table...please replace them with ur Database table.

    and importatn thing in the

    Proprties tab please keep the staut as STATEFULL FROM NOW ON Enabled.

    On initialization Event

    IF fl_delete IS INITIAL.
      SELECT carrid
             connid
        FROM spfli
        INTO TABLE t_spfli
        WHERE carrid = 'AA'.
    ENDIF.

    On Input Processing Event.

    DATA:
      w_event TYPE REF TO cl_htmlb_event.
    
    CALL METHOD cl_htmlb_manager=>get_event
      EXPORTING
        request = runtime->server->request
      RECEIVING
        event   = w_event.
    
    IF w_event IS NOT INITIAL.
      IF w_event->id = 'del'.
        DATA: table TYPE REF TO cl_htmlb_tableview.
        DATA: selectedrowindex TYPE string.
    
        table ?= cl_htmlb_manager=>get_data( request = request
                                           name    = 'tableView'
                                           id      = 'tab' ).
    
        IF table IS NOT INITIAL.
          DATA: table_event TYPE REF TO cl_htmlb_event_tableview.
    
          CLEAR selectedrowindex.
          table_event = table->data.
          selectedrowindex = table_event->selectedrowindex.
    
        DELETE t_spfli index selectedrowindex.
          fl_delete = 1.
    
        ENDIF.
      ENDIF.
    ENDIF.

    Layout Code.

    <htmlb:tableView id            = "tab"
                           width         = "100%"
                           selectionMode = "SINGLESELECT"
                           table         = "<%= t_spfli %>" >
            <htmlb:tableViewColumn columnName="CARRID" >
            </htmlb:tableViewColumn>
            <htmlb:tableViewColumn columnName="CONNID" >
            </htmlb:tableViewColumn>
          </htmlb:tableView>
          <htmlb:button id      = "del"
                        text    = "delete"
    Click = "OnInputProcessing()"
    />

    Hope this is helpful to you, let me know if you still have any problem.

    Thanks

    Kalyan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 05:51 AM

    Hi Suhashini,

    Please check this wiki to insert and delte the database table entries

    [Delete a row from table-view|http://wiki.sdn.sap.com/wiki/x/MYDvB ]

    Hope this solves the issue, Let me know if any queries.

    Regards,

    Rajani

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi rajani

      row is not getting selected when i double click on the row of table view.how to achieve it.can u explain me the procedure. when i select the row in which event the row index is selected. and when i press delete button in which event its deleted. please expalin me step by step procedure.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 09:49 AM

    Hi,

    Can you paste you code here...

    Thanks

    kalyan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      on input processing

      DATA: table TYPE REF TO CL_HTMLB_TABLEVIEW.

      DATA: selectedrowindex TYPE STRING,

      table ?= CL_HTMLB_MANAGER=>GET_DATA(

      request = request

      id = 'VPF'

      name = 'tableView' ).

      IF table IS NOT INITIAL.

      DATA: table_event TYPE REF TO cl_htmlb_event_tableview.

      CLEAR selectedrowindex.

      table_event = table->data.

      selectedrowindex = table_event->selectedRowIndex.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.