11-09-2007 6:29 PM
Hi,
Please, i need to modify the content of a table, but before i want to delete this content. See follow the code that is used actually:
DELETE (pr_name_table).
MODIFY (pr_name_table) FROM TABLE prt_table.
MESSAGE s000(zbrx) WITH text-i02 pr_name_table.
The ABAP Editor don't accept the expression "DELETE (pr_name_table).".
How to delete this content???
Best Regards,
Daniel Sanchez
11-09-2007 6:36 PM
Hi,
call function 'DB_DELETE_TABLE'
exporting
tablename = table "<Dynamic Name
tables
inttab = <tab> " Content
exceptions
db_error = 1
not_found = 2
wrong_param = 3
internal_error = 4
others = 5.
a®
11-09-2007 6:36 PM
11-09-2007 6:38 PM
11-09-2007 6:41 PM
11-09-2007 6:39 PM
OK, I see:
DELETE FROM (pr_name_table).
But this looks really dangerous. what if you misspell the table name and delete the wrong one?
Rob
11-09-2007 6:48 PM
Rob,
When i use the command "DELETE FROM (pr_name_table)." the ABAP Editor expected a "WHERE" too, don't compiling with this command.
Regards,
Daniel Sanchez
11-09-2007 6:50 PM
Hi,
Try to use
SELECT * FROM (TABLENAME) INTO TABLE INTTAB.
DELETE (TABLENAME) FROM TABLE INTTAB.
Here INTTAB contains the entries to be deleted.
a®
11-09-2007 6:50 PM
Yes - you can say something like
WHERE one-of-the-required-key-fields NE space.
Rob
11-09-2007 6:53 PM
Hi Daniel,
Use COMMIT WORK statement after DELETE statement. it should work.
<b>Reward points if it helps,</b>
Satish
11-12-2007 11:47 AM
Hi,
The solutions proposals above did not work.
I need to delete the ALL ENTRIES of a database table and after add new entries with "MODIFY" command.
I'm using this code:
DELETE (pr_name_table).
MODIFY (pr_name_table) FROM TABLE prt_table.
MESSAGE s000(zbrx) WITH text-i02 pr_name_table.
I'm waitinf for more helps!
Tks,
Daniel Sanchez
11-12-2007 11:54 AM
Daniel,
do like this
DELETE (pr_name_table) where <keyfield> <> ' '.
COMMIT WORK.
Reward points if it helps,
Satish
11-12-2007 11:54 AM
11-12-2007 11:57 AM
Hi,
If you are changing the non-key fields of a database table, use Update command instead of Modify.
MODIFY pr_name_table FROM prt_table.
If sy-subrc = 0.
DELETE pr_name_table FROM TABLE prt_table.
Endif.
Note: Check the syntax by clicking on F1
Bye,
KC
11-12-2007 12:07 PM
11-12-2007 12:14 PM
I need to use this operation for diversified tables. For this, I can´t use the "WHERE" command.
Also, I don't use the expression "DELETE pr_name_table FROM TABLE prt_table" why the number of entries between the 2 tables are diferent.
When used just the expression "DELETE (pr_name_table).", the ABAP Editor show the error message: "FROM wa" must follow "DELETE (dbtab)"
Please, i need more helps.
Message was edited by:
Daniel Sanchez
11-12-2007 12:48 PM
Hi.
1º load all the table pr_name_table in the internal table ptr_table
select *
from pr_name_table
appending corresponding fields of table ptr_table.
the tables are equals.
2º delete pr_name_table from table ptr_table.
11-12-2007 2:59 PM
You have to use the solution I proposed above, but you will also have to add a dynamic WHERE clause that will choose all table entries.
Rob
11-12-2007 3:24 PM
Daniel,
What on Earth is going on? Read the SAP help as I believe the statement you need is as follows:
DELETE FROM (pr_name_table).
Deletes lines in a database table. If you do not specify a WHERE clause, the system deletes all lines (in the current client).
Hope it helps.
11-12-2007 4:01 PM
I think the help is incorrect. In earlier releases you could delete without a WHERE clause, but now I think you get a syntax error if you try it.
Rob
11-12-2007 4:06 PM
11-12-2007 4:13 PM
my SAPHelp tells it is optional since release 6.10 (I think this is the ABAP version, not the SAP version). It was mandatory <i>before</i>, and optional since that (i. e. no WHERE ==> all entries will be deleted in DB table).
ec
11-12-2007 4:18 PM
You seem to be right, but I recall it being needed in earlier versions. Maybe the original poster could let us know which version he is on.
Rob
11-13-2007 11:15 AM
Hi,
Thanks for helps! The problem been resolved with this solution:
>> Call of Call:
IF sy-subrc IS INITIAL.
PERFORM z_upload_table TABLES t_zpf0012 t_bkp_zpf0012
USING c_zpf0012.
ENDIF.
>> In the Form: (after processing of Form)
FORM z_upload_table TABLES prt_table prt_table2
USING pr_nome_table.
.
.
.
IF sy-subrc <> 0.
MESSAGE i000(zbrx) WITH text-i03 l_file.
ELSE.
DELETE (pr_name_table) FROM TABLE prt_table2.
MODIFY (pr_name_table) FROM TABLE prt_table.
ENDIF.
Best Regards,
Daniel Sanchez