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

delete itab contents.,

naveen_inuganti2
Active Contributor
0 Likes
1,014

Hi.,

I am having one internal table with more than 50 Records.

FIELD1 is one of the field in that internal table,

It may contains contents like AAA, BBB, CCC, DDD or EEE.

So here I want to delete Internal table entries where that FILED1 eq BBB and FIELD1 eq CCC.

So we can write this as:

delete itab where FIELD1 = 'BBB'.
delete itab where FIELD1 = 'CCC'.

How can I solve this with one statement?

---Naveen Inuganti.

Hi.,

I am having one internal table with more than 50 Records.

FIELD1 is one of the field in that internal table,

It may contains contents like AAA, BBB, CCC, DDD or EEE.

So here I want to delete Internal table entries where that FILED1 eq BBB and FIELD1 eq CCC.

So we can write this as:

delete itab where FIELD1 = 'BBB'.
delete itab where FIELD1 = 'CCC'.

How can I solve this with one statement?

---Naveen Inuganti.

6 REPLIES 6
Read only

Former Member
0 Likes
993

HI,

You can write

delete itab where FIELD1 in ( 'BBB' ,'CCC' ). .

regards,

Lokesh.

Read only

0 Likes
993

Are you sure? Its not working Lokesh!

Read only

Former Member
0 Likes
993

delete itab where FIELD1 = 'BBB' or FIELD1 = 'CCC'

Read only

naveen_inuganti2
Active Contributor
0 Likes
993

Answer:

delete itab where fld2 eq 'AAA' or fld2 eq 'CCC'.

Thanks,

Naveen.I

Read only

Former Member
0 Likes
993

Hi Naveen,

Do it this way:

delete itab where FIELD1 = 'BBB' or FIELD1 = 'CCC'.

With luck,

Pritam.

Read only

Former Member
0 Likes
993

Hi,

You can specify DELETE seats_tab where CARRID = 'AZ' or CARRID = 'DL'.

You cna check in same line.

tables: sflight.

select-options: p_carrid for sflight-carrid,

p_connid for sflight-connid.

DATA: BEGIN OF seats,

carrid TYPE sflight-carrid,

connid TYPE sflight-connid,

fldate TYPE sflight-fldate,

seatsocc TYPE sflight-seatsocc,

seatsmax TYPE sflight-seatsmax,

seatsfree TYPE sflight-seatsocc,

END OF seats.

DATA seats_tab LIKE STANDARD TABLE OF seats.

SELECT carrid connid fldate seatsocc seatsmax

FROM sflight

INTO TABLE seats_tab

WHERE carrid in p_carrid AND

connid in p_connid.

LOOP AT seats_tab INTO seats.

seats-seatsfree = seats-seatsmax - seats-seatsocc.

MODIFY seats_tab INDEX sy-tabix FROM seats.

ENDLOOP.

SORT seats_tab BY carrid.

DELETE seats_tab where CARRID = 'AZ' or CARRID = 'DL'.

if sy-subrc = 0.

endif.

Regards,

Sunil