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 entries...

Former Member
0 Kudos
117

Hello everyone,

i have an internal table with fields

belnr,, ktosl, kunnr.

i want to delete the entries when

KTOSL NE 'VAT' OR KTOSL NE 'CST' OR KTOSL IS INITIAL.

tell me the syntax..

will be rewarded...

1 ACCEPTED SOLUTION

Former Member
0 Kudos
99

Hi,

Create a range :


ranges : gr_KTOSL for <tablename>-KTOSL.

gr_KTOSL-sign = 'I'.
gr_KTOSL-option = 'EQ'.
gr_KTOSL-low = 'VAT'.
append gr_KTOSL.

gr_KTOSL-sign = 'I'.
gr_KTOSL-option = 'EQ'.
gr_KTOSL-low = 'CST'.
append gr_KTOSL.

gr_KTOSL-sign = 'I'.
gr_KTOSL-option = 'EQ'.
gr_KTOSL-low = ''.
append gr_KTOSL.

delete itab where KTOSL not in gr_KTOSL.

Thanks,

Sriram Ponna.

7 REPLIES 7

Former Member
0 Kudos
99

Hi

delete itab[] where KTOSL NE 'VAT' OR KTOSL NE 'CST' OR KTOSL IS INITIAL.

Please check the syntax.

Regards

Shiva

Former Member
0 Kudos
99

loop at itab.

IF itab-KTOSL NE 'VAT'

OR itab-KTOSL NE 'CST'

OR itab-KTOSL IS INITIAL.

delete itab.

endif.

endloop.

Former Member
0 Kudos
100

Hi,

Create a range :


ranges : gr_KTOSL for <tablename>-KTOSL.

gr_KTOSL-sign = 'I'.
gr_KTOSL-option = 'EQ'.
gr_KTOSL-low = 'VAT'.
append gr_KTOSL.

gr_KTOSL-sign = 'I'.
gr_KTOSL-option = 'EQ'.
gr_KTOSL-low = 'CST'.
append gr_KTOSL.

gr_KTOSL-sign = 'I'.
gr_KTOSL-option = 'EQ'.
gr_KTOSL-low = ''.
append gr_KTOSL.

delete itab where KTOSL not in gr_KTOSL.

Thanks,

Sriram Ponna.

Former Member
0 Kudos
99

Hi,

The syntax is

DELETE itab WHERE cond.

regards.

Former Member
0 Kudos
99

Hi,

Data : idx type sy-tabix.

loop at itab.

idx = sy-tabix.

if itab-kostl ne 'VAT' OR itab-kostl ne 'CST'

OR ITAB-KOSTL = SPACE.

DELETE ITAB INDEX IDX.

ENDIF.

endloop.

REGARDS,

V.BALAJI

Former Member
0 Kudos
99

Hello Samala,

KTOSL NE 'VAT' OR KTOSL NE 'CST' OR KTOSL IS INITIAL.

The standard syntax is:

DELETE itab WHERE <cond>.

in your case you can use like:

DELETE itab WHERE ktosl NE 'VAT' OR
                                 ktosl NE 'CST' OR
                                 ktosl EQ ' '.

If you are yusing a loop, the best way is:

LOOP AT itab.

.....................

IF itab-kosl IS INITIAL.

DELETE itab WHERE ktosl NE 'VAT' OR
                                 ktosl NE 'CST'.

ENDIF.

.....................

ENDLOOP.

former_member194797
Active Contributor
0 Kudos
99

I think that the logical expression "KTOSL NE 'VAT' OR KTOSL NE 'CST' OR KTOSL IS INITIAL." is always true. So you will delete all entries in the table.