Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Delete rows in the database table by using Table Control

Former Member
0 Kudos

Hi Experts,

I wrote one program.

In that program i used table control.

I displayed data from database table in the table control, but i want to delete selected rows.

Can anybody please tell me this by writing sample code

thank you

Basu

3 REPLIES 3

former_member181962
Active Contributor
0 Kudos

YOu can see the demo program: RSDEMO_TABLE_CONTROL

Regards,

Ravi

Former Member
0 Kudos

Hi,

Put the First column is SEL in the table control, then

LOOP AT ITAB where SEL = 'X'   " Table control ITAB.
Selete DATABASE_TABLE where FIELD1 = ITAB-Field1. 
* You can write as many fields as you want in the Where condition
ENDLOOP.

Regards

Sudheer

Former Member
0 Kudos

Hi ,

Pls try this coding below or check the prg demo - RSDEMO02 in se38


WHEN 'DELL'.
* remove marked lines
      LOOP AT IT_SPFLI WHERE MARKED = 'X'.
        DELETE IT_SPFLI.
      ENDLOOP.
      IF SY-SUBRC <> 0.
        GET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
        SET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
        IF FLD CP 'IT_SPFLI*' AND SY-SUBRC = 0.
          LINNO = LINNO + TC_SPFLI-TOP_LINE - 1.
          DELETE IT_SPFLI INDEX LINNO.
          TC_SPFLI-LINES = TC_SPFLI-LINES - 1.
        ENDIF.
      ENDIF.

or another eg :

MODULE USER_COMMAND_0100 INPUT.
    SAVE_CODE = OK_CODE.
    CLEAR OK_CODE.
    CASE SAVE_CODE.

WHEN 'DELE'.
            CALL FUNCTION 'COPO_POPUP_TO_GOON'
                EXPORTING
                     TEXTLINE1 = 'Selected rows will be deleted!'
                     TEXTLINE2 = 'Are you sure?'
                     TITEL     = 'Delete rows'
                IMPORTING
                     answer    = confirmation.
            IF CONFIRMATION = 'G'.
                REFRESH ITAB_PHONELIST.
                CLEAR ITAB_PHONELIST.
            ENDIF.

MODULE EXTRACT_USERDATA INPUT.
    CASE SAVE_CODE.
        WHEN 'DELE'.
            IF SELECTION IS INITIAL AND
               confirmation = 'G'.
                 CLEAR ITAB_PHONELIST.
    ITAB_PHONELIST-NAME = RECORD-NAME.
    ITAB_PHONELIST-PHONE = RECORD-PHONE.
    ITAB_PHONELIST-EMAIL = RECORD-EMAIL.
    APPEND ITAB_PHONELIST.

<b>Reward pts if found usefull :)</b>

regards

Sathish