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 records which or "not equal to" from the internal table

Former Member
0 Kudos

hi experts

i want to delete the records which or "not equal to" from the internal table.

ex: i have an intaernal table i_materials, this internal table have 50 records, now i want to delete the matetials which or not equal to " pick' and 'copick' .

pls ehelp me write the logic for this

with regards

aaryaa

Edited by: Alvaro Tejada Galindo on Jan 23, 2008 11:00 AM

7 REPLIES 7

former_member583013
Active Contributor
0 Kudos

LOOP AT T_MATERIAL ASSIGNING <FS_MATERIAL>.
W_TABIX = SY-TABIX.
IF <FS_MATERIAL>-CODE NE 'PICK' 
AND <FS_MATERIAL>-CODE NE 'COPICK' .
DELETE T_MATERIAL INDEX W_TABIX.
ENDIF.
ENDLOOP.

Greetings,

Blag.

Edited by: Alvaro Tejada Galindo on Jan 23, 2008 10:58 AM (Thanks Rob Burbank)

0 Kudos

Blag - do you mean "AND"?

Rob

0 Kudos

Yep, thanks Rob, a little TYPE error...Now it's fixed -;)

Greetings,

Blag.

0 Kudos

hi Alvaro Tejada Galindo

plse tell me what is FS_MATERIAL

cheers

aaryaa

0 Kudos

Its field symbol

declare like this way


field-symbols : <FS_MATERIAL> type any.

former_member194669
Active Contributor
0 Kudos


ranges: r_matnr for mara-matnr.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
r_matnr-low = 'PICK.'. 
append r_matnr.
r_matnr-low = 'COPICK.'. 
append r_matnr.

delete i_tab where not matnr in r_matnr.

JozsefSzikszai
Active Contributor

hi Madhu,

you can even do it without LOOP:

DELETE itab WHERE ( field NE 'PICK' AND field NE 'COPICK' ) .

hope this helps