‎2009 Feb 23 11:17 AM
hi Experts,
how to write a code for delete the data first from ztable before inserting the data into the same table after execution of program.
I have written like
data itab like ztable occurs 0 with header line.
If ztable is not initial.
delete itab.
modify ztable from itab.
endif.
but this code is not working.Plz reply as soon as possible.
Thx in advance.
Regds,
Vipul
‎2009 Feb 23 11:22 AM
Hi
you can use refresh itab[].
this would delete all the data from itab.
‎2009 Feb 23 11:24 AM
‎2009 Feb 23 11:25 AM
i want to delete all the rows but when i put debug it show it skip from the if condition.
‎2009 Feb 23 11:28 AM
I don't think U can check if Ztable is empty or not ..
remove this statement ..
write as ..
If itab[] is not initial.
clear itab[].
modify ztable from itab.
endif.
‎2009 Feb 23 11:26 AM
Hi,
Can i have ur reqiurement clear....
ur trying to delete the table entries first then trying to insert the entries to the same table...
so let me know,that the entries ur deleting are same as that of the entries ur inserting.?
if not y u want to delete the table entries first.
Regards,
Rohan.
‎2009 Feb 23 11:27 AM
Hi,
Your requirement is not clear. Please specify it clearly.
you have deleted itab then modifying ztable from itab. how come data will be there in itab.
thanks,
Srilakshmi.
‎2009 Feb 23 11:27 AM
use
If ztable is not initial.
clear: itab , itab[]."delete itab.
modify itab from ztable.
endif.
clear: itab , itab[].
Edited by: tahir naqqash on Feb 23, 2009 4:28 PM
‎2009 Feb 23 11:31 AM
Hi,
When you are checking a table whether it is initial or not.
Use
if itab[] is not initial.....endifand if you want to delete the data in internal table.
You can always use
Refresh : itab[].or if you want to delete only the cirrent line Use.
delete itab.Hope this may help.
Regards,
Amitteja
‎2009 Feb 23 11:27 AM
try this:
loop at itab.
delete itab from 1.
endloop.
modify ztable from itab.
‎2009 Feb 23 11:28 AM
Hi Vipul,
Simply write the following code:-
If MARA is your table.
*
DELETE from MARA.
*
This will delete all entries.
If you want to delete only some entries, you can provide a where clause.
And then write the code for inserting the entries.
‎2009 Feb 23 11:40 AM
‎2009 Feb 23 11:31 AM
Hi Vipul,
Could you please give your requirement very clearly?
Regards,
Anil
‎2009 Feb 23 11:32 AM
‎2009 Feb 23 12:09 PM
hi Vipul,
Try doing this.....
DATA: itab type standard tabe of ztable.
select * from ztable into table itab.
if sy-subrc = 0.
delete ztable.
else
modify ztable from itab.
endif.
This will work, I have tried it out.
Thanks and Regards
Suraj