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: 

delete the record from the database

Former Member
0 Kudos

hi guys,

how to delete one error record from a table(BUT000) from the production environment

can anyone guide me, if anyone has the code plz paste the code

Thanks alot in advanse

Naveen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

i found all the tables where this value is entered is there any other way to delete this record from those tables

your help will be appreciated

22 REPLIES 22

Former Member
0 Kudos

Hi Naveen,

Fisrst decide on the record which you are going to delete from the database table. Then write the select statement inside the loop.

loop at t_but000.

if t_but000-client = '300' and

t_but000-partner = '0000000321'.

DELETE BUT000 from t_but000.

CLEAR T_BUT000.

endloop.

HOPE THIS WOULD SOLVE YOUR ISSUE.

LAKSHMINARAYANAN

Former Member
0 Kudos

Hi,

loop at <internal table>.

delete from <database table> where <condition for error record in internal table>.

endloop.

Regards,

Aswin

0 Kudos

hi

declare the internal table same as ur database table..

data:t_tab like database_tab occurs o with header line.

select all the fields of the record of the database table which u want to delete into ur internal table..using where clause....

then

delete <dbtab> from t_tab.

reward points if it helps

gunjan

former_member181962
Active Contributor
0 Kudos

HI Naveen,

Whatever may be the requirement, you should not delete update/modify records in standard tables.

YOu should do such things only through transactions or bapis.

Regards,

Ravi

0 Kudos

hi,

look and <b>test</b> abap BUPDELE1

Andreas

0 Kudos

Its not advisable to delete the entry from BUT000 table as there might be some records left out in some tables like but020 etc, don't forget to delete them aswell as it might cause you inconsistencies in furture.

I could not able to exeucte this program BUPDELE1, but you can luse the list of tables to delete from this program code.

DELETE FROM BUT001 WHERE PARTNER IN S_PARNR.

DELETE FROM BUT020 WHERE PARTNER IN S_PARNR.

DELETE FROM BUT021 WHERE PARTNER IN S_PARNR.

DELETE FROM BUT100 WHERE PARTNER IN S_PARNR.

DELETE FROM BUT0BK WHERE PARTNER IN S_PARNR.

DELETE FROM BUT050 WHERE PARTNER1 IN S_PARNR.

DELETE FROM BUT050 WHERE PARTNER2 IN S_PARNR.

DELETE FROM BUT051 WHERE PARTNER1 IN S_PARNR.

DELETE FROM BUT051 WHERE PARTNER2 IN S_PARNR.

DELETE FROM BUT150 WHERE PARTNER1 IN S_PARNR.

DELETE FROM BUT150 WHERE PARTNER2 IN S_PARNR.

DELETE FROM BUT000 WHERE PARTNER IN S_PARNR.

Also you should have authorization to debug inproduction ) which will never be the case, else you need to write a program to do the same.

If you have a chance to debug then from SE16 debug method you can delete any selected record.

Message was edited by: Manohar

0 Kudos

HI Manohar,

as u said it is not advisable to do

but is there anyway to handle this only one error record

what i mean to say is how to delete this record i.e. business partner number 2 from the production environment

<b>i am unable to edit this program in se38 v r using the package BUPT</b>

thanks alot for u r time

Regards,

Naveen

Former Member
0 Kudos

DATA: BEGIN OF WA,

CARRID TYPE SPFLI-CARRID,

CONNID TYPE SPFLI-CONNID,

END OF WA,

ITAB LIKE HASHED TABLE OF WA

WITH UNIQUE KEY CARRID CONNID.

WA-CARRID = 'UA'. WA-CONNID = '0011'.

INSERT WA INTO TABLE ITAB.

WA-CARRID = 'LH'. WA-CONNID = '1245'.

INSERT WA INTO TABLE ITAB.

WA-CARRID = 'AA'. WA-CONNID = '4574'.

INSERT WA INTO TABLE ITAB.

...

DELETE SPFLI FROM TABLE ITAB.

Former Member
0 Kudos

HELLO EXPERTS.

thanks alot for u r feedback

but here my question is, is it possible to delete only single record from the productin environment which is a error record

Andreas what is this

BUPDELE1

Naveen

Former Member
0 Kudos

hi

if u hav any <b>where</b> condition to find out the error record then u can use

delete from dtab <b>where</b> condition.

u can also chk out

Deleting from a Databse Table

Variants:

1. DELETE FROM dbtab. or

DELETE FROM (dbtabname).

2. DELETE dbtab FROM wa. or

DELETE (dbtabname) FROM wa.

3. DELETE dbtab FROM TABLE itab. or

DELETE (dbtabname) FROM TABLE itab.

4. DELETE dbtab. or

DELETE *dbtab.

5. DELETE dbtab VERSION vers. or

DELETE *dbtab VERSION vers.

Effect

Deletes a set of lines in a database table (see relational database). You can specify the name of the database table either directly in the program in the form DELETE FROM dbtab ... or at runtime as the contents of the variable dbtabname in the form DELETE FROM (dbtabname) .... In both cases, the database table must be known to the ABAP Dictionary. By default, the system deletes only data from the current client. You can only use a view to delete data, if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "no restriction".

DELETE is part of the OPEN SQL command set.

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Open SQL and Unicode.

Notes

Authorization checks are not supported by the DELETE statement and must be carried out at program level.

When you delete lines using the DELETE command, the process is only complete after a database commit (see LUW). Before the commit, any database change can be reset using a database rollback (see Programming Transactions).

In dialog systems, synchronizing parallel user access to a single dataset cannot be handled by the locking mechanism of the database system alone. In many cases, you therefore have to use the SAP locking mechanism.

Variant 1

DELETE FROM dbtab. or

DELETE FROM (dbtabname).

Extras:

1. ... WHERE condition

2. ... CLIENT SPECIFIED

3. ... CONNECTION con

Effect

Deletes lines in a database table. If you do not specify a WHERE clause, the system deletes all lines (in the current client). If you specify a WHERE clause, the system deletes all lines that fulfill the WHERE condition.

After the statement is executed, the system field SY-DBCNT contains the number of lines that were deleted.

The Return Code is set as follows:

SY-SUBRC = 0:

At least one line was deleted.

SY-SUBRC = 4:

No line was deleted since no lines were selected.

Example

Delete all flight bookings (in the current client):

DELETE FROM SBOOK.

Addition 1

... WHERE condition

Effect

The system deletes only those lines that fullfill the

condition specified in the WHERE Clause.

Example

Delete all bookings of Lufthansa flight 0400 on 02/28/2001 (in the current client):

DELETE FROM SBOOK WHERE CARRID = 'LH' AND

CONNID = '0400' AND

FLDATE = '20010228'.

Addition 2

... CLIENT SPECIFIED

Effect

Switches off automatic client handling. This allows you

to delete data across all clients in case of client-specific tables. The client field is then handled like a normal table field for which you can specify appropriate conditions in the WHERE clause.

The addition CLIENT SPECIFIED must be specified directly after the name of the database table.

Addition 3

... CONNECTION con

Effect

The Open SQL command is not executed on the

standard database but on the Secondary Database Connection specified using con. con is the name of the database connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can als be specified dynamically in the form (source_text) - the field source_text contains the name of the database connection and must be type C or STRING.

The CONNECTION con addition must be specified directly after the name of the database table or after the CLIENT SPECIFIED addition.

Variant 2

DELETE dbtab FROM wa. or

DELETE (dbtabname) FROM wa.

Extras:

1. ... CLIENT SPECIFIED

2. ... CONNECTION con

Effect

These are SAP-specific short forms to delete a single line from a database table. The primary key for the line to be deleted is taken from the explicitly specified work area wa. The key values are read from left to right according to the structure of the primary key of the database table. The structure of wa is not considered. This is why the work area wa must be at least as wide (DATA) as the primary key of the database table dbtab, and the alignment of the work area wa must correspond to that of the database table. Otherwise, a runtime error occurs.

If the database table dbtab or the work area wa contain strings, wa must be compatible with the line structure of dbtab.

After the statement is executed, the sytem field SY-DBCNT contains the number of lines that were deleted (0 or 1).

The Return Code is set as follows:

SY-SUBRC = 0:

The line was deleted.

SY-SUBRC = 4:

No line could be deleted since there was no line with the primary key specified.

Example

Delete the booking with the booking number 3 of Lufthansa flight 0400 on 02/28/2001 (in the current client):

DATA wa TYPE sbook.

wa-carrid = 'LH'.

wa-connid = '0400'.

wa-fldate = '20010228'.

wa-bookid = '00000003'.

DELETE sbook FROM wa.

Addition 1

... CLIENT SPECIFIED

Effect

As in variant 1.

Addition 2

... CONNECTION con

Effect

As in variant 1.

Variant 3

DELETE dbtab FROM TABLE itab.

DELETE (dbtabname) FROM TABLE itab.

Extras:

1. ... CLIENT SPECIFIED

2. ... CONNECTION con

Effect

Deletes sets: All lines of the database table for which the internal table itab contains values for the fields of the primary key are deleted. The lines of the internal table itab must fulfill the same conditions as the work area wa in variant 2.

The system field SY-DBCNT contains the number of lines that were deleted, that is, the number of lines in the internal table itab for whose key values lines existed in the database table dbtab.

The Return Code is set as follows:

SY-SUBRC = 0:

All lines in itab could be used for deleting lines in dbtab.

SY-SUBRC = 4:

For at least one line of the internal table, the database table did not contain a line with the same primary key. All lines found were deleted.

Note

If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.

Addition 1

... CLIENT SPECIFIED

Effect

As in variant 1.

Addition 2

... CONNECTION con

Effect

As in variant 1.

Variant 4

DELETE dbtab. or

DELETE *dbtab.

Addition:

... CLIENT SPECIFIED

The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.See Cannot Use Short Forms and Cannot Use * Work Areas.

Note

This variant is obsolete.

Effect

These are the SAP-specific short forms of variant 2. They work like variant 2 but the work area is not specified explicitly. Instead, the table work area dbtab or *dbtab is implicitly used which is declared with a TABLES statement.

DELETE dbtab. or

DELETE *dbtab.

is also equivalent to

DELETE dbtab FROM dbtab. or

DELETE dbtab FROM *dbtab.

After the statement is executed, the system field SY-DBCNT contains the number of lines that were deleted (0 or 1).

The Return Code is set as follows:

SY-SUBRC = 0:

The line was deleted.

SY-SUBRC = 4:

No line could be deleted since no line with the primary key specified existed.

Example

Delete the booking with the booking number 3 of Lufthansa flight 0400 on 02/28/2001 (in the current client):

TABLES sbook.

sbook-carrid = 'LH'.

sbook-connid = '0400'.

sbook-fldate = '20010228'.

sbook-bookid = '00000003'.

DELETE sbook.

Note

If you do not explicitly specify a work area, the values for the line to be deleted are taken from the table work area dbtab even if the statement occurs in a subroutine (FORM) or function module (FUNCTION), in which the table work area is obscured by an identically named formal parameter or local variable.

Addition

... CLIENT SPECIFIED

Effect

As in variant 1.

Variant 5

DELETE dbtab VERSION vers.

DELETE *dbtab VERSION vers.

This variant is not allowed in an ABAP Objects context.See Cannot use the VERSION Addition.

Note

This variant has become obsolete since the variants 1 - 3 allow you to specify the database table name dynamically.

Effect

Deletes a line in a database table whose name is taken from the field vers at runtime. The database table must be known to the ABAP Dictionary, and its name must comply with the following naming convention: The name must begin with a 'T' and may contain at most five characters, including the leading 'T'. The field vers must contain the table name without the leading 'T'. The system deletes only lines in the current client. The line to be deleted is taken from the statically specified table work area dbtab or *dbtab.

The Return Code is set as follows:

SY-SUBRC = 0:

The line was deleted.

SY-SUBRC = 4:

No line could be deleted since no line with the primary key specified existed.

Additional help

Deleting Table Lines

plz reward if useful

0 Kudos

hi,

goto transaction SE38 - program BUPDELE1

A.

0 Kudos

Hi

You have to copy the program BUPDELE1 into ZBUPDELE1 and here delete the abap row with comand EXIT.

So use this copy to delete the records, this report have a selection-screen where you can indicate the partner to be deleted.

You can delete all abap rows where the report deletes the table different from BUPT00

Max

Former Member
0 Kudos

BUPDELE1 is a good option in most cases but it should not be used if you are using some enhancement like BUPT packages for your Business partner.

Former Member
0 Kudos

i found all the tables where this value is entered is there any other way to delete this record from those tables

your help will be appreciated

0 Kudos

Hi Naveen,

If you have authorization to debug in production then you can delete the records from the tables,

Go to SE16 -> BUT000

Give the BP you want to delete then F8.

select the record then press F7

Give /H for debugging and press enter

Change 'Code' variable to 'DELE' then press F8

Click Delete entry button.

Repeat the same for all tables.

Hope this helps.

Message was edited by: Manohar

0 Kudos

Manohar,

in debugger i have the code to if code ='dele'...........

when i am trying to debug at that point control is not going to this dele line

what i need to change here can u let me know

and after changing some code how to replace it once again do i need to fallow the same line

thanks alot for u r advise

Naveen

0 Kudos

Hi Naveen,

Check the note 865271, its a report.

Run the report in test mode first, and them run it in update mode, it will remove all inconsistencies in the BUT000, BUTXXX and ADRC tables.

Let me know if it works.

Thanks

Sanju

0 Kudos

After you change the code to 'DELE' then press F8,

here in this screen you could see an button to delete the entry.

Click this button to delete the record.

You need to repeat the same for all tables.

0 Kudos

Sanju,

it is not anything related to errors occured in the record

but i entered an extra record into the production environment which is not existing in the legessy system by mistake

now i need to delete that record that it

anyhow thank alot for u r guidance n note

Regards,

Naveen

0 Kudos

Manohar,

dele is already existing in that list of case statement

what i need to change related to it

sorry to trouble u Manohar

thanks alot for u r patience

Naveen

0 Kudos

Yes DELE will be there, but by default it shows 'SHOW' as a 'CODE' variable value.

Here you need to change the value from SHOW to DELE, then after changing press F8.

Here now you need to press Shift+F2 (Delete Entry button).

0 Kudos

K Manohar i resolved the issue with the customer itself

anyhow i am verymuch thankful for u r guidance, patience and feedback u deserve the full points here i am going to reward the point

Naveen