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: 

deleting multiple records from table control using module pools

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Frnds i want to delete eventually records from database table.

regards,

satish

0 Kudos

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!;)

kesavadas_thekkillath
Active Contributor
0 Kudos

sort table it_emp by checkbox.

delete IT_EMP where checkbox = 'X'.

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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