‎2009 Feb 20 8:17 PM
Hi I have an internal table Itab and it has the following :
Field1 Field2
-
A1 B1
A2 B2
A3 B3
A4 B2
Now I want to retain only the records which have B2 or B3 in the internal table and delete all other records.
I am trying to do this:
Delete Itab where Field2 <> 'B2' or Field2 <> 'B3'.
This statement is not working and it deletes all the contents of the internal table.
Can someone tell me how I can acheieve the delete .
Thanks in advance.
‎2009 Feb 20 8:23 PM
Delete Itab where Field2 NE 'B2' and Field2 NE 'B3'.
Try this
‎2009 Feb 20 8:26 PM
Total Questions: 88 (71 unresolved)Why not follow up on your old posts?
Rob
‎2009 Feb 20 8:29 PM
Loop at itab.
If itab-field2 NE 'B2' and itab-field2 NE 'B3'.
Delete Itab index sy-tabix.
Endif.
Endloop.
Hope this resolves the issue.
Regards,
Gurpreet
‎2009 Feb 20 8:32 PM
Try this
delete it_tab where not ( f2 = 'B2' or f2 = 'B3').
Thanks.
‎2009 Feb 20 11:24 PM
Hi Kiran,
Try using DELETE itab where ( field2 ne 'B2' and field2 ne 'B3' ).
Hope this should solve the problem.
Regards
Sravan
‎2009 Feb 21 4:50 AM
Hi, Kiran
Please Mark your All Question as answered if solved
Test the following Sample Code it will solve out your problem,
DATA: BEGIN OF it OCCURS 10,
c1(3),
c2(3),
END OF it.
RANGES: r_rec FOR it.
r_rec-sign = 'I'.
r_rec-option = 'EQ'.
r_rec-low = 'B2'.
APPEND r_rec TO r_rec.
r_rec-low = 'B3'.
APPEND r_rec TO r_rec.
it-c1 = 'A1'.
it-c2 = 'B1'.
DO 5 TIMES.
APPEND it TO it.
ADD 1 TO : it-c1+1(1),
it-c2+1(1).
ENDDO.
DELETE it WHERE c2 IN r_rec.Kind Regards,
Faisal
‎2009 Feb 21 6:37 AM
Hi try usingdelete itab where field2 <> b1 or field2 <> b2.
Thanks
‎2009 Feb 21 6:38 AM