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: 

Conditional delete on an internal table

Former Member
0 Kudos

Hi,

How to do Conditional delete on an internal table using a negative clause

Thanks,

Manjula.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Assume an internal table TAB1 with the following definition. TAB1 is built from the database table DBTAB and contains many possible values for the table column FLAG (except the initial value). The functionality covered in this example is the case where all the internal table values with the value of FLAG not equal to ‘D’ have to be deleted. The table contains 100,000 rows.

LOOP AT TAB1

IF TAB1-FLAG <> ‘D’.

TAB1-FLAG = SPACE.

MODIFY TAB1 INDEX SY-TABIX

TRANSPORTING FLAG.

ENDIF.

ENDLOOP.

DELETE TAB1 WHERE FLAG = SPACE

Reward points if found helpfull...

Cheers,

Chandra Sekhar.

4 REPLIES 4

former_member156446
Active Contributor
0 Kudos

You wanted to delete all entires with f1 LE 7.

delete itab where itab-f1 GR 7.

reward points if helpful.

Former Member
0 Kudos

Hi,

Use the code..

delete <itab> where <itab-fieldname> NE ''value'.

eg.

delete itab where matnr NE 10.

Former Member
0 Kudos

Hi,

if certain action has done on the internal table then delete the record,

for example,

if it_tab-fname ne 'X'.

delete it_tab with index sy-tabix.

endif.

Plzz reward points if it helps.

Former Member
0 Kudos

Hi,

Assume an internal table TAB1 with the following definition. TAB1 is built from the database table DBTAB and contains many possible values for the table column FLAG (except the initial value). The functionality covered in this example is the case where all the internal table values with the value of FLAG not equal to ‘D’ have to be deleted. The table contains 100,000 rows.

LOOP AT TAB1

IF TAB1-FLAG <> ‘D’.

TAB1-FLAG = SPACE.

MODIFY TAB1 INDEX SY-TABIX

TRANSPORTING FLAG.

ENDIF.

ENDLOOP.

DELETE TAB1 WHERE FLAG = SPACE

Reward points if found helpfull...

Cheers,

Chandra Sekhar.