Application Development and Automation 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: 
Read only

Some query about report

Former Member
0 Likes
1,168

Hi all,

Can u plz explain me the diff between update and modify, insert and append.What exactly they will do on itab.

Also tell me if I use delete itab where <condition> it will delete each and every record which matches condition or only first matching condition or the entire table.

Plz experts explain me the concepts as I am new to ABAP programming.

With regards,

Abir.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,037

In the se38 editor's application toolbar, there will be a button for help on key words(BUtton will have and 'I' symbol).(CTRL+f8)

Press that button and type in the keyword that you want to know about. It will give you a detailed example and help on the key word.

If you want info about database updates,

then:

modify: modifies records if they exist .

If they are not there in the table, then creates a new entry.

insert: INserts a record .

update: UPdate the specified fields if match is found.

If you are talking about internal table:

then

Modify, Modifies the record which matches the where cond or index number specified.

Insert inserts the record at specified index.

append: it will add the record at the end of the internal table.Till we encounter an append statement the data will be in the header area of the itab.

Regards,

Ravi

Hi all,

Can u plz explain me the diff between update and modify, insert and append.What exactly they will do on itab.

Also tell me if I use delete itab where <condition> it will delete each and every record which matches condition or only first matching condition or the entire table.

Plz experts explain me the concepts as I am new to ABAP programming.

With regards,

Abir.

8 REPLIES 8
Read only

Former Member
0 Likes
1,038

In the se38 editor's application toolbar, there will be a button for help on key words(BUtton will have and 'I' symbol).(CTRL+f8)

Press that button and type in the keyword that you want to know about. It will give you a detailed example and help on the key word.

If you want info about database updates,

then:

modify: modifies records if they exist .

If they are not there in the table, then creates a new entry.

insert: INserts a record .

update: UPdate the specified fields if match is found.

If you are talking about internal table:

then

Modify, Modifies the record which matches the where cond or index number specified.

Insert inserts the record at specified index.

append: it will add the record at the end of the internal table.Till we encounter an append statement the data will be in the header area of the itab.

Regards,

Ravi

Read only

Former Member
0 Likes
1,037

Hi,

To insert lines into a database table regardless of whether there is already a line in the table with

the same primary key .. we use MODIFY..

If the database already contains a line with the same primary key as the line to be inserted,

MODIFY works like UPDATE, that is, the line is changed.

Use INSERT when you insert fields in the database.

MODIFY to change existing row or insert if not available.

THe insert will throw a short dump if you try to enter a row with same set of primry key field values..

For performance reasons, you should use MODIFY only if you cannot distinguish between these

two options in your ABAP program.

rgds,

latheesh

Message was edited by: Latheesh Kaduthara

Read only

Former Member
0 Likes
1,037

hi,

append :- appends data( line ) at the end of internal table

insert :- inserts the data sort order ( similar to append but inserts in sorted order)

modify :- modify record if present otherwise appends new record

update :- updates the value in the table only ; it use key

for further details

use transaction ABAPDOCU

or check this link

http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm

Mark Helpfull answers

Message was edited by: Manoj Gupta

Read only

Former Member
0 Likes
1,037

HI ABIR,

UPDATE

Updates values in a database table (see Relational Databases ). You can specify the name of the database table either directly in the form dbtabor at runtime as contents of the field dbtabname. In both cases, the table must be known to the ABAP Dictionary. Normally, lines are updated only in the current client. Data can only be updated using a view if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".

MODIFY

Inserts new lines or updates existing lines in a database table (s. relational database). If a line with the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed. You can specify the name of the database table either in the program itself in the form MODIFY dbtab ... or at runtime as the contents of the variable dbtabname in the form MODIFY (dbtabname) .... In both cases, the database table must be defined in the ABAP Dictionary. If the program contains the name of the database table, it must also have a corresponding TABLES statement. Normally, records are inserted or updated only in the current client. Data can only be inserted or updated using a view, if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".

MODIFY belongs to the Open SQL command set.

INSERT ITAB

Inserts a new line in the internal table itab using an explicit or implicit index specification. You can only use this variant with index tables (standard or sorted tables).

If you use "wa INTO" the contents of the work area wa are used as the new line. If the type of wa is not compatible with the line type of itab, then the contents of wa are copied across using MOVE logic.

If you use INITIAL LINE INTO a line is inserted in the table, filled with the initial values appropriate to the field types.

If you do not specify anything before itab, the new line is taken from the header line of the internal table itab.

You use INDEX idx to specify the table index before which the line is inserted into itab. If the table has idx - 1 entries, the line is appended to the end of the table.

If you are adding entries to an index table using a LOOP, you can leave out the INDEX idx specification. The source table is inserted before the current line in the LOOP (implicit index specification).

If you use the addition ASSIGNING <fs>, the field symbol <fs> is set to the line you have just inserted. If you use the addition REFERENCE INTO ref, the data reference dref is filled with the reference of the line you have just inserted. Both the field symbol and the reference are only set if the statement is executed sucessfully.

If the target table itab has the type SORTED TABLE, it must be correctly sorted after you have finished inserting lines, otherwise a runtime error is triggered.

If the target table is defined with a UNIQUE KEY, the uniqueness must be preserved when you insert new lines. If it is not, a runtime error is triggered.

The Return Code is set as follows:

When you specify the insertion point using INDEX idx:

SY-SUBRC = 0:

The line was inserted successfully

SY-SUBRC = 4:

The index specified was too large. The line was not inserted, since the table has less than idx - 1 entries. If you use the addition ASSIGNING or REFERENCE INTO, <wa> or ref remains unchanged.

If you do not specify the point of insertion, Return Code is set to 0.

APPEND

Appends a new line to the end of the internal table itab. You can only use this variant with index tables (standard or sorted table).

If you specify wa TO , the new line is taken from the contents of the explicitly specified work area wa.

If you use INITIAL LINE TO, a line filled with the correct initial value for the type is added.

If the part before itab is omitted, the new line is taken from the header line of the internal table itab.

If you use the ASSIGNING <fs> addition, the field symbol, <wa>, points to the line you have just appended. If you use the REFERENCE INTO ref addition, the data reference, dref, is filled with the reference of the line you have just appended.

If the target table itab is a SORTED TABLE, it must be sorted correctly after the append, otherwise a runtime error results.

After the statement has been executed, the system field SY-TABIX is filled with the index of the last line in the table.

DELETE ITAB...

DELETE itab WHERE logexp.

Extras:

1. ... FROM idx1

2. ... TO idx2

Effect

Deletes all of the entries from the internal table itab that satisfy the condition logexp. The condition logexp can be almost any logical expression. The only restriction is that the first field in each comparison must be a component of the line structure of the internal table itab.

The Return Code is set as follows:

SY-SUBRC = 0:

At least one entry deleted.

SY-SUBRC = 4:

No entries deleted.

When you use the WHERE condition with a STANDARD or HASHED table, a full table scan is always required.

If you are working with a SORTED TABLE, the partial sequential processing can be optimized so that only the entries that actually satisfy the WHERE condition are processed. This optimization requires that each sub-condition is linked with AND; that no parentheses are used; that at least one sub-condition is in the form k = v; and that the conditions in the form k1 = v1 ... kn = vn cover at least the first part of the table key.

The starting point for the loop is specified using a binary search with the sub-conditions that cover the table key (partially or completely). This optimization is similar to the optimization in the READ statement. The loop is only processed from the starting point to the point where these sub-conditions are still met. (See also Optimized Key Operations in Internal Tables).

Each operand in the WHERE condition that is not a component of the corresponding internal table itab can be replaced by a functional method call. Functional methods are methods in ABAP Objects with any number of IMPORTING parameters and a single RETURNING parameter.

If the line type of the internal table contains object reference variables, or the entire line type is itself a reference variable, you can use the attributes of the object to which the reference is pointing as comparison values in the WHERE condition (see Attributes of objects as the key of an internal table).

You can only use the additions ... FROM idx1 and ... TO idx2 with index tables (standard or sorted tables).

HOPE THIS HELPS,

PRIYA.

Read only

Former Member
0 Likes
1,037

Hi Abir,

APPEND will add data to end of itab. INSERT will place it at the right postition (--> sorted tables).

MODIFY is used to change data of internal tables, UPDATE is for database changes.

Documentation:

http://help.sap.com/saphelp_nw04/helpdata/en/start.htm

search for ITAB + statement

Kind Regards,

Silke

Read only

Former Member
0 Likes
1,037

Hi Abir,

UPDATE

Changes entries in database tables.

Syntax

UPDATE <dbtab> SET <si> = <f>

|<si> = <s i> + <f>

|<si> = <s i> - <f> [WHERE <cond>].

The value in the column <si> is set to the value <f>, increases it by <f>, or decreases it by <f> for all lines selected. The WHERE clause specifies the lines that are changed. If you omit the WHERE clause, all lines are changed.

Syntax

UPDATE <dbtab> FROM <wa>.

UPDATE <dbtab> FROM TABLE <itab>.

This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length and alignment as the lines of the database table.

MODIFY for Database Tables

Inserts or changes lines in database tables.

Syntax

MODIFY <dbtab> FROM <wa>.

MODIFY <dbtab> FROM TABLE <itab>.

Works like INSERT for database tables, if there is not yet a line in the table with the same primary key. Works like UPDATE if a line already exists with the same primary key.

MODIFY for any Internal Table

Changes the content of lines in internal tables of any type.

Syntax

MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2>...]

[ASSIGNING <FS> | REFERENCE INTO <dref>].

Copies the work area <wa> into the line of the internal table with the same table key as <wa>. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the modified line or the relevant data reference is stored in <dref> after the statement. You can use the TRANSPORTING addition to specify the exact components that you want to change.

MODIFY <itab> FROM <wa> TRANSPORTING <f1> <f 2>... WHERE <logexp>.

Copies the work area <wa> into the line of the internal table for which the logical expression is true. In each comparison of the logical expression, the first operand must be a component of the line structure.

INSERT for Database Tables

Inserts entries from database tables.

Syntax

INSERT <dbtab> FROM <wa>.

INSERT <dbtab> FROM TABLE <itab> [ACCEPTING DUPLICATE KEYS].

Inserts one line from the work area <wa> or several lines from the internal table <itab> into the database table <dbtab>. The ACCEPTING DUPLICATE KEYS addition prevents a runtime error from occurring if two entries have the same primary key. Instead, it merely discards the duplicate

INSERT for any Internal Table

Inserts lines from internal tables of any type.

Syntax

INSERT <line>|LINES OF <jtab> [FROM <n1>] [TO <n 2>]

INTO TABLE <itab>

[ASSIGNING <FS> | REFERENCE INTO <dref>].

Inserts a line <line> or a set of lines from the internal table <jtab> into the internal table <itab>. If <jtab> is an index table, you can use the FROM and TO additions to restrict the lines inserted. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the inserted line or the relevant data reference is stored in <dref> after the statement.

APPEND

Appends a line or multiple lines to the end of an index table.

Syntax

APPEND <line>|LINES OF <jtab> TO <itab>

[ASSIGNING <FS> | REFERENCE INTO <dref>].

A line <line> or multiple lines of an internal table <jtab> are appended to index table <itab>. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the appended line or the relevant data reference is stored in <dref> after the statement.

Syntax

DELETE FROM <dbtab> WHERE <cond>.

All of the lines in the database table that satisfy the conditions in the WHERE clause are deleted.

award if it helps.

regards,

keerthi.

Read only

rahulkavuri
Active Contributor
0 Likes
1,037

The bolded text explains ur second question in detail.. award points if found helpful

<b>Insert statement</b>

INSERT statement inserts a single record into the database table.

Syntax

Tables: sflight.

Sflight-carrid = ‘LH’.

Sflight-connid = ‘234’.

Insert sflight.

Table sflight is inserted with the record. The SY_SUBRC is returned for this statement. If the entry already exists then the SY_SUBRC is set to non-zero value and you can do processing for existing record by giving some error message.

<b>Update statement</b>

To update database table UPDATE statement is used. This allows you to change either a single record or several records.

You can use UPDATE when you know which record you want to change. But if you do not know whether the primary key of the line you want to insert already exists or not, you can use the MODIFY statement. The MODIFY statement changes existing lines and inserts lines which do not exist.

Sflight-carrid = ‘MN’.

Sflight-connid = ‘454’.

UPDATE SFLIGHT where CARRID = ‘LH’.

Or

TABLES SFLIGHT.

UPDATE SFLIGHT SET PRICE = 1100

WHERE CARRID = ‘LH’.

Here price of sflight will get updated with new price 1100.

<b>Delete statement</b>

To delete records from a database table, you use the DELETE statement.

<b>DELETE FROM SFLIGHT WHERE CARRID = ‘LH’ AND CONNID = ‘454’.

Will delete the single record where conditions are met from SFLIGHT.

You can delete the multiple records from database table by putting all the records, which you want to delete in internal table. For example

DELETE SFLIGHT FROM TABLE ITAB.

In this case whatever you have in internal table will be deleted from SFLIgHT.

</b>

Note: append internal table with all the entries, which you want to delete.

Message was edited by: Rahul Kavuri

Read only

Former Member
0 Likes
1,037

Hi Abir,

Inserting a Single Line

To insert a line into an index table, use the statement:

INSERT <line> INTO <itab> [INDEX <idx>].

<line> is either a work area that is convertible to the line type, or the expression INITIAL LINE. If you use <wa>, the system adds a new line to the internal table <itab> and fills it with the contents of the work area. INITIAL LINE inserts a blank line containing the correct initial value for each field of the structure.

If you use the INDEX option, the new line is inserted before the line which has the index <idx>. After the insertion, the new entry has the index <idx> and the index of the following lines is incremented by 1. If the table contains <idx> -1 lines, the new line is added at the end of the table. If the table has less than <idx> - 1 lines, the new line cannot be inserted, and SY-SUBRC is set to 4. When the system successfully adds a line to the table, SY-SUBRC is set to 0.

Without the INDEX addition, you can only use the above statement within a LOOP. Then, the new line is inserted before the current line (<idx> is implicitly set to SY-TABIX).

Appending lines to standard tables and sorted tables with a non-unique key works regardless of whether lines with the same key already exist in the table. Duplicate entries may occur. A runtime error occurs if you attempt to add a duplicate entry to a sorted table with a unique key. Equally, a runtime error occurs if you violate the sort order of a sorted table by appending to it.

Inserting Several Lines

To add several lines to an internal table, use the statement:

INSERT LINES OF <itab1> INTO <itab2> [INDEX <idx>].

The system inserts the lines of table <itab1> one by one into <itab2> using the same rules as for single lines. ITAB1 can be any type of table. The line type of ITAB1 must be convertible into the line type of ITAB2.

When you append an index table to another index table, you can specify the lines to be appended as follows:

INSERT LINES OF <itab1> [FROM <n1>] [TO <n 2>] INTO <itab2>

[INDEX <idx>].

<n 1 > and <n 2 > specify the indexes of the first and last lines of ITAB1 that you want to insert into ITAB2.

Depending on the size of the tables and where they are inserted, this method of inserting lines of one table into another can be up to 20 times faster than inserting them line by line in a loop.

To insert lines into a database table regardless of whether there is already a line in the table with the same primary key, use the following:

MODIFY <target> <lines>.

If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added.

If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed.

For performance reasons, you should use MODIFY only if you cannot distinguish between these two options in your ABAP program.

You can add or change one or more lines <lines> in a database table <target>. You can only insert or change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.

Specifying a Database Table

To specify the database table statically, enter the following for <target>:

MODIFY <dbtab> [CLIENT SPECIFIED] <lines>.

where <dbtab> is the name of a database table defined in the ABAP Dictionary.

To specify the database table dynamically, enter the following for <target>:

MODIFY (<name>) [CLIENT SPECIFIED] <lines>.

where the field <name> contains the name of a database table defined in the ABAP Dictionary.

You can use the CLIENT SPECIFIED addition to disable automatic client handling.

<b>Inserting or Changing Single Lines</b>

To insert or change a single line in a database table, use the following:

MODIFY <target> FROM <wa> .

The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.

If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.

A shortened form of the above statement is:

MODIFY <dbtab>.

In this case, the contents of the table work area <dbtab> are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.

Inserting or Changing Several Lines

To insert or change several lines in a database table, use the following:

MODIFY <target> FROM TABLE <itab> .

Those lines of the internal table <itab> for which there is not already a line in the database table with the same primary key are inserted into the table. Those lines of the internal table <itab> for which there is already a line in the database table with the same primary key overwrite the existing line in the database table. The same rules apply to the line type of <itab> as to the work area <wa> described above.

SY-SUBRC is always set to 0. SY-DBCNT is set to the number of lines in the internal table.

Changing Lines

The Open SQL statement for changing data in a database table is:

UPDATE <target> <lines>.

It allows you to change one or more lines in the database table <target>. You can only change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.

Specifying a Database Table

To specify the database table statically, enter the following for <target>:

UPDATE <dbtab> [CLIENT SPECIFIED] <lines>.

where <dbtab> is the name of a database table defined in the ABAP Dictionary.

To specify the database table dynamically, enter the following for <target>:

UPDATE (<name>) [CLIENT SPECIFIED] <lines>.

where the field <name> contains the name of a database table defined in the ABAP Dictionary.

You can use the CLIENT SPECIFIED addition to disable automatic client handling.

Changing Lines Column by Column

To change certain columns in the database table, use the following:

UPDATE <target> SET <set1> <set 2> ... [WHERE <cond>].

The WHERE clause determines the lines that are changed. If you do not specify a WHERE clause, all lines are changed. The expressions <set i > are three different SET statements that determine the columns to be changed, and how they are to be changed:

<si> = <f>

The value in column <si> is set to the value <f> for all lines selected.

<si> = <s i> + <f>

The value in column <si> is increased by the value of <f> for all lines selected.

<si> = <s i> - <f>

The value in column <si> is decreased by the value of <f> for all lines selected.

<f> can be a data object or a column of the database table. You address the columns using their direct names.

If at least one line is changed, the system sets SY-SUBRC to 0, otherwise to 4. SY-DBCNT contains the number of lines changed.

If you use SET statements, you cannot specify the database table dynamically.

Overwriting Individual Lines From a Work Area

To overwrite a single line in a database table with the contents of a work area, use the following:

UPDATE <target> FROM <wa> .

The contents of the work area <wa> overwrite the line in the database table <dbtab> that has the same primary key. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.

If the database table contains a line with the same primary key as specified in the work area, the operation is completed successfully and SY-SUBRC is set to 0. Otherwise, the line is not inserted, and SY-SUBRC is set to 4.

A shortened form of the above statement is:

UPDATE <dbtab>.

In this case, the contents of the table work area <dbtab> are used to update the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.

Overwriting Several Lines Using an Internal Table

To overwrite several lines in a database table with the contents of an internal table, use the following:

UPDATE <target> FROM TABLE <itab> .

The contents of the internal table <itab> overwrite the lines in the database table <dbtab> that have the same primary keys. The same rules apply to the line type of <itab> as to the work area <wa> described above.

If the system cannot change a line because no line with the specified key exists, it does not terminate the entire operation, but continues processing the next line of the internal table.

If all lines from the internal table have been processed, SY-SUBRC is set to 0. Otherwise, it is set to 4. If not all lines are used, you can calculate the number of unused lines by subtracting the number of processed lines in SY-DBCNT from the total number of lines in the internal table. If the internal table is empty, SY-SUBRC and SY-DBCNT are set to 0.

Whenever you want to overwrite more than one line in a database table, it is more efficient to work with an internal table than to change the lines one by one.

There are several ways of adding lines to index tables. The following statements have no equivalent that applies to all internal tables.

Appending a Single Line

To add a line to an index table, use the statement:

APPEND <line> TO <itab>.

<line> is either a work area that is convertible to the line type, or the expression INITIAL LINE. If you use <wa>, the system adds a new line to the internal table <itab> and fills it with the contents of the work area. INITIAL LINE appends a blank line containing the correct initial value for each field of the structure. After each APPEND statement, the system field SY-TABIX contains the index of the appended line.

Appending lines to standard tables and sorted tables with a non-unique key works regardless of whether lines with the same key already exist in the table. Duplicate entries may occur. A runtime error occurs if you attempt to add a duplicate entry to a sorted table with a unique key. Equally, a runtime error occurs if you violate the sort order of a sorted table by appending to it.

Appending Several Lines

You can also append internal tables to index tables using the following statement:

APPEND LINES OF <itab1> TO <itab2>.

This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.

When you append an index table to another index table, you can specify the lines to be appended as follows:

APPEND LINES OF <itab1> [FROM <n1>] [TO <n 2>] TO <itab2>.

<n 1 > and <n 2 > specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.

This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.

Line Using the Table Key

To use the table key of table <itab> as a search key, use one of the following statements:

DELETE TABLE <itab> FROM <wa>.

or

DELETE TABLE <itab> WITH TABLE KEY <k1> = <f 1> ... <k n> = <f n>.

In the first case, <wa> must be a work area compatible with the line type of <itab>. The values of the key fields are taken from the corresponding components of the work area.

In the second case, you have to supply the values of each key field explicitly. If you do not know the name of one of the key fields until runtime, you can specify it as the content of a field <n i > using the form (<n i >) = <f i >. If the data types of <f i > are not compatible with the key fields, the system converts them.

The system searches for the relevant lines as follows:

Standard tables

Linear search, where the runtime is in linear relation to the number of table entries.

Sorted tables

Binary search, where the runtime is in logarithmic relation to the number of table entries.

Hashed tables

The entry is found using the hash algorithm of the internal table. The runtime is independent of the number of table entries.

If the system finds a line, it deletes it from the table and sets SY-SUBRC to zero. Otherwise, SY-SUBRC is set to 4. If the table has a non-unique key and the system finds duplicate entries, it deletes the first entry.

Deleting Several Lines Using a Condition

To delete more than one line using a condition, use the following statement:

DELETE <itab> WHERE <cond>.

This processes all of the lines that meet the logical condition <cond>. The logical condition can consist of more than one comparison. In each comparison, the first operand must be a component of the line structure. If the table lines are not structured, the first operand can also be the expression TABLE LINE. The comparison then applies to the entire line. If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.

Deleting Adjacent Duplicate Entries

To delete adjacent duplicate entries use the following statement:

DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>

[COMPARING <f1> <f 2> ...

|ALL FIELDS].

The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are duplicate if they fulfill one of the following compare criteria:

Without the COMPARING addition, the contents of the key fields of the table must be identical in both lines.

If you use the addition COMPARING <f1> <f 2> ... the contents of the specified fields <f 1 > <f 2 > ... must be identical in both lines. You can also specify a field <f i > dynamically as the contents of a field <n i > in the form (<n i >). If <n i > is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.

If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines must be identical.

You can use this statement to delete all duplicate entries from an internal table if the table is sorted by the specified compare criterion.

If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.

Regards,

Laxmi