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

Table Control

Hi,

I want to delete the selected records from the table control these records are in database , i want to delete these records in database also and i want delete when i press delete row button plzz help me.

Reward helpful answer

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2008 at 10:49 AM

    Hi,

    See my example code by using this i delete the records from database table through table control

    MODULE user_command INPUT.

    CASE ok_code.

    WHEN c_edel. " To delete the selected records

    PERFORM delete_record USING it_timesheet.

    ENDCASE.

    ENDMODULE. " USER_COMMAND INPUT

    "----


    • FORM DELETE_RECORD

    "----


    • This Subroutine is used for delete records in the database

    "----


    • -->pr_IT_TIMESHEET Internal table like table control

    "----


    FORM delete_record USING pr_it_timesheet LIKE it_timesheet.

    IF fs_timesheet-lno IS NOT INITIAL.

    LOOP AT pr_it_timesheet INTO fs_timesheet WHERE c_box EQ c_char_x.

    PERFORM fill_timesheet USING fs_timesheet

    CHANGING fs_temp_ts.

    DELETE zcl_timesheet FROM fs_temp_ts.

    IF sy-subrc EQ c_zero.

    MESSAGE s007.

    ENDIF.

    ENDLOOP.

    ENDIF.

    ENDFORM. " DELETE_RECORD

    "----


    • FORM FILL_TIMESHEET

    "----


    • This Subroutine is used for fill fieldstring fs_temp_ts

    "----


    • <--PR_fs_temp_ts fieldstring like database table

    "----


    FORM fill_timesheet USING pr_fs_timesheet LIKE fs_timesheet

    CHANGING pr_fs_temp_ts TYPE zcl_timesheet.

    CLEAR pr_fs_temp_ts.

    pr_fs_temp_ts-empid = w_empid.

    pr_fs_temp_ts-workdate = pr_fs_timesheet-date.

    pr_fs_temp_ts-groupid = w_groupid.

    pr_fs_temp_ts-projectid = pr_fs_timesheet-pid.

    pr_fs_temp_ts-projectname = pr_fs_timesheet-pname.

    pr_fs_temp_ts-objectid = pr_fs_timesheet-oid.

    pr_fs_temp_ts-objectname = pr_fs_timesheet-oname.

    pr_fs_temp_ts-activityid = pr_fs_timesheet-aid.

    pr_fs_temp_ts-activityname = pr_fs_timesheet-aname.

    pr_fs_temp_ts-timeworked = pr_fs_timesheet-wtime.

    pr_fs_temp_ts-description = pr_fs_timesheet-desc.

    pr_fs_temp_ts-taskstatus = pr_fs_timesheet-tstat.

    pr_fs_temp_ts-billstatus = pr_fs_timesheet-bstat.

    IF pr_fs_timesheet-lno IS INITIAL.

    SELECT linenum " Line number

    FROM zcl_timesheet

    INTO w_linenum

    WHERE empid EQ w_empid

    AND workdate EQ pr_fs_timesheet-date.

    ENDSELECT. " SELECT LINENUM

    IF sy-subrc NE c_zero.

    pr_fs_temp_ts-linenum = 1.

    ELSE.

    w_linenum = w_linenum + 1.

    pr_fs_temp_ts-linenum = w_linenum.

    ENDIF. " IF SY-SUBRC NE C_ZERO

    ELSE.

    pr_fs_temp_ts-linenum = pr_fs_timesheet-lno.

    ENDIF. " IF pr_fs_TIMESHEET-LNO IS INITIAL

    IF pr_fs_timesheet-pid NE c_leave

    AND pr_fs_timesheet-pid NE c_hol.

    pr_fs_temp_ts-wstatus = c_char_w.

    ELSEIF pr_fs_timesheet-pid EQ c_leave.

    pr_fs_temp_ts-wstatus = c_char_l.

    ELSEIF pr_fs_timesheet-pid EQ c_hol.

    pr_fs_temp_ts-wstatus = c_char_h.

    ENDIF. " IF pr_fs_TIMESHEET-PID NE C_LEAVE

    IF sy-ucomm EQ c_save.

    pr_fs_temp_ts-appstatus = c_char_s.

    ELSEIF sy-ucomm EQ c_submit.

    pr_fs_temp_ts-appstatus = c_char_x.

    ENDIF. " IF SY-UCOMM EQ C_SAVE

    ENDFORM. " FILL_TIMESHEET

    Note :

    Write the module in table control in middle of chain and endchain and use your own field string and your own table name and one more thig you can able to delete database record based on my code your field string is also must be same type of database table and fill field string

    Plzz Reward if it is useful,

    Mahi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2008 at 05:52 AM

    hi,

    First.

    u just move ur selected table control fields to one internal table,

    Then.

    when 'DELETE'.

    DELETE dbtable FROM TABLE internaltable.

    commit work.

    that's all,

    reward points if useful,

    sehu.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 19, 2008 at 07:15 AM

    hi ,

    Follow the logic :

    Loop at the table control and collect the records to be deleted into an internal table .

    Delete the records from DB table and do a commit work so that the selecte records will be deleted from the

    Then the rest of the data will be shown except the delete records ...

    Regards,

    Ranjita

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2008 at 07:49 AM

    Hi,

    PROCESS AFTER INPUT.

    LOOP AT ITAB_PHONELIST .

    MODULE EXTRACT_USERDATA.

    ENDLOOP.

    module delete.

    In se38

    MODULE EXTRACT_USERDATA INPUT.

    CASE SAVE_CODE.

    WHEN 'DELE'.

    IF ITAB_PHONELIST-SELECTION EQ 'X' AND

    confirmation = 'G'.

    ITAB_PHONELIST-SELECTION = 'X'.

    modify ITAB_PHONELIST index TCTRL_PHONELIST-CURRENT_line.

    ENDIF.

    ENDMODULE. " EXTRACT_USERDATA INPUT

    MODULE delete INPUT.

    CASE SAVE_CODE.

    WHEN 'DELE'.

    DELETE ITAB_PHONELIST where selection eq 'X'.

    endcase.

    ENDMODULE. " delete INPUT

    Add a comment
    10|10000 characters needed characters exceeded

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.