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

delete records in an internal table

I uploaded the data incorrectly into a ztable .how can i delete all entries in a that table now. I am afraid the table gets deleted.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2007 at 06:19 PM

    Hi Deepti,

    Go through the syntax for Delete command

    DELETE

    Delete from a database table

    <b>- DELETE FROM dbtab WHERE condition.

    - DELETE FROM (dbtabname) WHERE condition.

    - DELETE dbtab.

    - DELETE *dbtab.

    - DELETE (dbtabname) ... .

    - DELETE dbtab FROM TABLE itab.

    - DELETE (dbtabname) FROM TABLE itab.

    - DELETE dbtab VERSION vers.

    - DELETE *dbtab VERSION vers.</b>

    Delete from an internal table

    - DELETE itab.

    - DELETE itab INDEX idx.

    - DELETE itab FROM idx1 TO idx2.

    - DELETE itab WHERE condition.

    - DELETE ADJACENT DUPLICATES FROM itab.

    Delete a program

    - DELETE REPORT prog.

    Delete text elements

    - DELETE TEXTPOOL prog LANGUAGE lg.

    Delete a data cluster

    - DELETE FROM DATABASE dbtab(ar) ...ID key.

    Delete a file

    - DELETE DATASET dsn.

    Delete a screen

    - DELETE DYNPRO f.

    regards

    Sanjeev

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2007 at 06:18 PM

    hi

    go to <b>SM30</b>.. give table name and Maintain

    there u can delete the entries from the ZTABLE..

    or u can do it programatically by

    <b>DELETE ZTABLE.</b>

    place a cursor on delete and <b>press F1</b> then u will get sytanx for all options with <b>DELETE</b> command.

    Regards

    CNU

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2007 at 06:19 PM

    Hi,

    you can delete the entries in the table by using DELETE command.

    1. DELETE FROM dbtab WHERE cond.

    DELETE FROM (dbtabname) WHERE cond.

    2. DELETE dbtab.

    DELETE *dbtab.

    DELETE (dbtabname) ...

    3. DELETE dbtab FROM TABLE itab.

    DELETE (dbtabname) FROM TABLE itab.

    4. DELETE dbtab VERSION vers.

    DELETE *dbtab VERSION vers.

    Effect

    Deletes lines from a database table(see Relational Databases ). You can specify thename of the database table either in the program itself with DELETEFROM dbtab ... or at runtime as the contents of the fielddbtabname with DELETE FROM (dbtabname) .... In bothcases, the database table must be known to the ABAP Dictionary.Only data from the current client is usually deleted. You can deletedata using a view only if the view refers to a singletable and was created in the ABAP Dictionary with themaintenance status "No restriction".

    DELETE belongs to the Open SQLcommand set.

    Notes

    The DELETE statement does not performauthorization checks. You must programthese yourself.

    The final (irrevocable) deletion of lines with the DELETEstatement is not performed until after a database commit (seeLogical Unit of Work (LUW)). Prior to this,you can reverse any database update with a database rollback (seeProgramming Transactions).

    You cannot rely exclusively on the locking mechanism of the database system to synchronize several users trying toaccess the same dataset at the same time. You should therefore use theSAP locking mechanism.

    <b>Variant 1</b>

    DELETE FROM dbtab WHERE cond.

    DELETE FROM (dbtabname) WHERE cond.

    Addition:

    ... CLIENT SPECIFIED

    Effect

    Deletes lines in a database table that satisfy the WHERE clause cond. With thisvariant, specification of a WHERE condition is obligatory .

    When the statement has been executed, the system field SY-DBCNTcontains the number of deleted lines.

    The return code is set as follows:

    SY-SUBRC = 0:

    At least one line was deleted.

    SY-SUBRC = 4:

    No lines were deleted, since no line was selected.

    Example

    Delete all bookings for the Lufthansa flight 0400 on02.28.1995 (in the current client):

    TABLES SBOOK.

    DELETE FROM SBOOK WHERE CARRID = 'LH' AND

    CONNID = '0400' AND

    FLDATE = '19950228'.

    Note

    To delete all the lines in a table, you must specify aWHERE condition that is true for all lines. You can achieve thiswith

    ... WHERE f IN itab

    If the internal table itab is empty, such a condition wouldselect all lines.

    Addition

    ... CLIENT SPECIFIED

    Effect

    Switches off automatic client handling. This allows youto delete data across all clients in the case of client-specifictables. The client field is then treated like a normal table field, forwhich you can formulate suitable conditions in the WHERE clause.

    You must specify the addition CLIENT SPECIFIED immediately afterthe name of the database table.

    <b>Variant 2</b>

    DELETE dbtab.

    DELETE *dbtab.

    DELETE (dbtabname) ...

    Additions:

    1. ... FROM wa

    2. ... CLIENT SPECIFIED

    See Short forms not allowed and* work areas not allowed.

    Effect

    These are SAP-specific short forms used to deleteone line of a database table. If the name of the database tableis specified in the program, the primary key ofthe line to be deleted is taken from the specified work area -dbtab or *dbtab. If the name of the database table is notdetermined until runtime ( DELETE (dbtabname) ...), the addition... FROM wa is obligatory .

    When the statement has been executed, the system field SY-DBCNTcontains the number of deleted lines (0 or 1).

    The return code is set as follows:

    SY-SUBRC = 0:

    The line was deleted.

    SY-SUBRC = 4:

    No lines could be deleted, since no line exists withthe primary key specified.

    Example

    Delete the booking with the booking number 3 for theLufthansa flight 0400 on 28.02.1995 (in the current client):

    TABLES SBOOK.

    SBOOK-CARRID = 'LH'.

    SBOOK-CONNID = '0400'.

    SBOOK-FLDATE = '19950228'.

    SBOOK-BOOKID = '00000003'.

    DELETE SBOOK.

    Addition 1

    ... FROM wa

    Effect

    Takes the primary key for the line to be deleted notfrom the table work area dbtab, but from the explicitlyspecified work area wa. Here, the key values from left to rightare taken from wa according to the structure of the primarykey in the table work area dbtab (see TABLES). The structure of wa is not taken intoaccount. Therefore, the work area wa must be at least as wide(see DATA) as the primary key in thetable work area dbtab and the alignment ofthe work area wa must correspond to the alignment of the primarykey in the table work area. Otherwise, you get a runtime error.

    Note

    If a work area is not explicitly specified, the values forthe line to be deleted are taken from the table work area dbtab,even if the statement appears in a subroutine (see FORM) or function module (see FUNCTION) where the table work area is stored in a formalparameter or a local variable of the same name.

    Addition 2

    ... CLIENT SPECIFIED

    Effect

    As with variant 1.

    <b>Variant 3</b>

    DELETE dbtab FROM TABLE itab.

    DELETE (dbtabname) FROM TABLE itab.

    Addition:

    ... CLIENT SPECIFIED

    Effect

    Mass deletion: Deletes all database table lines forwhich the internal table itab contains values for theprimary key fields. The lines of the internaltable itab must satisfy the same condition as the work areawa in addition 1 to variant 2.

    The system field SY-DBCNT contains the number of deleted lines,i.e. the number of lines of the internal table itab for whosekey values there were lines in the database table dbtab.

    The return code is set as follows:

    SY-SUBRC = 0:

    All lines from itab could be used to deletelines from dbtab.

    SY-SUBRC = 4:

    For at least one line of the internal table in thedatabase table, there was no line with the same primary key. All foundlines are deleted.

    Note

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

    Addition

    ... CLIENT SPECIFIED

    <b>

    Effect</b>

    As with variant 1.

    <b>Variant 4</b>

    DELETE dbtab VERSION vers.

    DELETE *dbtab VERSION vers.

    This variant is not allowed in an ABAP Objectscontext. See VERSION addition not allowed.

    <b>Note</b>

    This variant is now obsolete, since variants 1 - 3 allowyou to specify the database table name dynamically.

    <b>Effect</b>

    Deletes a line in a database table, the name of which istaken from the field vers at runtime. The database table must beknown to the ABAP Dictionary and its name must conform to thefollowing naming convention: It must begin with 'T' and canconsist of four additional characters. The field vers mustcontain the table name without a leading 'T'. Only lines in thecurrent client are deleted. The line to be deleted is taken from thestatically 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 lines could be deleted because no line existedwith the specified primary key.

    Regards,

    Vara

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 25, 2007 at 06:22 PM

    Hi,

    You can run standard program RADCVBTC to delete all entries in your ztable.

    OBJ_NAME = <ztable>

    OBJ_TYPE = 'TABL'

    FCT = 'MDF'

    Also you can use transaction SE14 (database utility).

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2007 at 06:23 PM

    Hi Deepthi,

    Write a simple program & upload the same data into internal table using GUI_UPLOAD. & use the following code to delete all the records you uploaded:

    Loop at itab.

    Delete form DBTABLE where field = itab-field.

    endloop.

    Ashven

    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.