03-31-2006 5:16 AM
Hi Experts,
I have one internal table itab.
Itab contains the values:
Field X Field Y
10 A
10 B
10 K
20 A
20 C
30 A
i want to delete the internal table records
where Field X = 'K' and also i dont want the records field X values if any one of field Y contains 'K'.
i want output like this.
Field X Field Y
20 A
20 C
30 A
here field Y contains value 'K' in field X value 10. so i want to delete field X which are contains value "10'.( i want to delete records if any one the field Y contains "K').
please how to code for this. help me..
03-31-2006 5:20 AM
hi Silviya,
you can do like this..
data : x1 like itab-x.
....
read table itab with key Y ='K'.
x1 = itab-x.
delete itab where X = x1.
delete itab where X = 'K'.
regards
satesh
03-31-2006 5:20 AM
LOOP AT itab WHERE Y = 'K'..
DELETE itab WHERE X = itab-x.
ENDLOOP.
03-31-2006 5:20 AM
hi Silviya,
you can do like this..
data : x1 like itab-x.
....
read table itab with key Y ='K'.
x1 = itab-x.
delete itab where X = x1.
delete itab where X = 'K'.
regards
satesh
03-31-2006 5:27 AM
Hi,
Try this.
DATA: BEGIN OF ITAB1 OCCURS 0,
X TYPE ANY,
Y TYPE ANY,
END OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 0,
X TYPE ANY,
END OF ITAB2.
LOOP AT ITAB1 WHERE Y = 'K'.
ITAB2-X = ITAB1-X.
APPEND ITAB2.
ENDLOOP.
SORT ITAB2.
DELETE ADJACENT DULTICATE FROM ITAB2.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY X = ITAB1-X.
IF SY-SUBRC = 0.
DELETE ITAB1.
ENDIF.
ENDLOOP.
I hope this will work for you.
Thanks,
Pal
03-31-2006 7:43 AM
you can simply do this.
read table itab into wa with key field2 = 'K'.
delete itab where field2 = 'K'
or field1 = wa-field1.
regards,
Kinshuk Saxena
03-31-2006 8:08 AM
---- This will delete all the record of field1 for coreesponding value of field2 with value 'K'.----
loop at itab where field2 = 'K'.
delete itab where field1 = itab-field1.
endloop.
---- This will delete all the record for value field2 ='K'.------
delete itab where field2 = 'K'.
hope solve your problem