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

deleting multiple records from table control using module pools

Hi all,

I am working with TABLE CONTROL in module pools.

i want to delete multiple records which i select from

Table control screen , in my case i am able to delete

single record i.e first line whcih i enter , others i am unable.

below i m providing my logic for delete .

<code>

WHEN 'DEL'.

LOOP AT IT_EMP WHERE CHECKBOX = 'X'.

IF SY-SUBRC EQ 0.

DELETE ZDATA_12 FROM TABLE IT_EMP.

ENDIF.

ENDLOOP.

</code>

looking for some replies as its a urgent requirement.

Any help frnds.

Thanks,

satish

Edited by: satish kau on Dec 19, 2007 11:30 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2007 at 10:44 AM

    Hello,

    I think that you could try:

    a) Verify (debugging) that checkbox is set to 'X' for every row that you have selected --> maybe something is failing and it is only set to 'X' for the first one.

    b) If a) is correct, please try to delete the row using:

    DELETE IT_EMP INDEX SY-TABIX.

    I hope it will help you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2007 at 10:45 AM

    Hi Satish,

    Try this, this is my module program in this the user select the lines and click the push button in the screen then the records are updated in my ztable and these lines are deleted in the screen.

    MODULE app_rej INPUT.

    Case sy-ucomm.

    when 'APP' or 'APP1'.

    perform update using 'A'.

    When 'REJ'.

    Perform update using 'R'.

    w_flag1 = 'x'.

    endcase.

    ENDMODULE. " app_rej INPUT

    FORM update USING VALUE(P_val) type any.

    loop at t_timesheet into fs_timesheet.

    if fs_timesheet-cbox = 'X'.

    fs_timesheet-app_stat = p_val.

    perform fill_time using fs_timesheet.

    update zcl_time_data1 from FS_TIME_data.

    if sy-subrc eq 0.

    delete t_timesheet index sy-tabix.

    if sy-subrc = 0 and p_val = 'A'.

    message s015 with text-113.

    else.

    if sy-subrc = 0 and p_val = 'R'.

    message s015 with text-114.

    endif.

    endif.

    else.

    message s015 with text-115.

    endif.

    endif.

    endloop.

    ENDFORM. " update

    Plzzz 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 Dec 19, 2007 at 11:04 AM

    Frnds i want to delete eventually records from database table.

    regards,

    satish

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Satish,

      From database table? Which database table?

      What are you exactly trying to do? The user selects rows to delect in the table control and then delete this rows in the database table?

      Please specify your requirement.

      Regards, David!;)

  • Posted on Dec 19, 2007 at 11:08 AM

    sort table it_emp by checkbox.

    delete IT_EMP where checkbox = 'X'.

    why are you deleting ZDATA_12 ??? bit confused...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2007 at 11:18 AM

    Hi Friend,

    Your delete statement is in side the loop so don't use table key word it may solve your problem.

    WHEN 'DEL'.

    LOOP AT IT_EMP WHERE CHECKBOX = 'X'.

    IF SY-SUBRC EQ 0.

    DELETE ZDATA_12 FROM TABLE IT_EMP.

    DELETE { {FROM target [WHERE sql_cond]} (use this syntax)

    ENDIF.

    ENDLOOP.

    Plzz Reward if useful,

    Mahi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2007 at 06:49 AM

    Hi Satish,

    I had a similar requirement in my project.

    You will have to use two internal tables in order to delete the entries from the standard Z tables.

    Here, tb_line is the name of internal table used for the table control.

    tb_line_del is the internal table used to store the deleted entries from the table control.

    The code when clicking on DELETE button is :

    case sy-ucomm.

    when 'DELETE'.

    ***To delete the selected line from table control****

    loop at tb_line.

    if tb_line-mark = 'X'.

    move-corresponding tb_line to tb_line_del.

    append tb_line_del.

    delete tb_line.

    endif.

    endloop.

    Once the entries are there in the tb_line_del internal table,now the following code has to be written to delete the entries from the Z table corresponding to the values in the tb_line_del internal table.

    Here,TCL_ITEMS is the name of the table control.First you need to check if there are any entries in the table control.Then you can go ahead withe the deletion of rows from the Z table.

    I have written this code in a form by name 'SAVE' .In the PAI module of the screen when clicking on the save button you should use the following code.

    CASE sy-ucomm.

    WHEN 'SAVE'.

    ****perform Save subroutine to perform save operation******

    PERFORM save.

    The code for form 'SAVE' would be :

    IF TCL_ITEM-LINES NE 0 .

    ****Update the entries into header table****

    MODIFY ztm09_ekko. *ztm09_ekko,ztm09_ekpo are the z tables used*

    LOOP AT tb_line.

    ztm09_ekpo-ebeln = ztm09_ekko-ebeln.

    ztm09_ekpo-ebelp = tb_line-ebelp.

    ztm09_ekpo-matnr = tb_line-matnr.

    ztm09_ekpo-menge = tb_line-menge.

    ztm09_ekpo-meins = tb_line-meins.

    ztm09_ekpo-netpr = tb_line-netpr.

    ztm09_ekpo-waers = tb_line-waers.

    *****Update the entries into item table*****

    MODIFY ztm09_ekpo.

    ENDLOOP.

    LOOP AT tb_line_del.

    ztm09_ekpo-ebeln = ztm09_ekko-ebeln.

    ztm09_ekpo-ebelp = tb_line_del-ebelp.

    ztm09_ekpo-matnr = tb_line_del-matnr.

    ztm09_ekpo-menge = tb_line_del-menge.

    ztm09_ekpo-meins = tb_line_del-meins.

    ztm09_ekpo-netpr = tb_line_del-netpr.

    ztm09_ekpo-waers = tb_line_del-waers.

    ****Delete the entries from ztm09_ekpo****

    DELETE ztm09_ekpo.

    ENDLOOP.

    ***Displaying the corresponding messages****

    MESSAGE 'SAVED SUCCESSFULLY' TYPE 'I'.

    CLEAR ztm09_ekko.

    CLEAR tb_line. REFRESH tb_line.

    LEAVE TO SCREEN 100.

    ENDIF.

    Reward if helpull

    Thanks,

    Kashyap

    Edited by: Kashyap Ivaturi on Dec 21, 2007 7:51 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2007 at 06:59 AM

    hi Satish,

    This is kiran kumar.G.I will send send a sample code plz check it once.

    If u satify with my answer give me REWARD POINTS..

    code in SE38:

    CASE SY-UCOMM.

    when 'DELE'.

    if gt_item-cflag = 'X'.

    *Delete the Record from the Database Table

    delete from yvbap where vbeln = gt_item-vbeln

    and posnr = gt_item-posnr

    and matnr = gt_item-matnr

    and matkl = gt_item-matkl

    and arktx = gt_item-arktx.

    *Delete the Record from the Internal Table

    delete gt_item index my_table-current_line.

    endif.

    endcase.

    HERE my_table is the TABLE CONTROL NAME..

    CODE IN PAI EVENT:

    PROCESS AFTER INPUT.

    *Populate data into internal Table

    loop at gt_item.

    MODULE USER_COMMAND_0110.

    endloop.

    IF U WANT ENTIRE PROGRAM CODE JUST SEND BLANK MAIL TO THIS MAIL ID : gunuputi_kiran@yahoo.co.in.

    subject line :SDN.SAP

    Regards,

    Kiran Kumar.G

    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.