‎2006 Sep 29 11:43 AM
Hi Group,
I have Internal table(having 50 records) in which I need to find table field which is equal to 'A'(I have 10 such records) records and have to write those records
in a log and after that I have delete those records.
Any body give me some idea how to do that.
‎2006 Sep 29 11:45 AM
loop at it_table where yor field = 'A'.
write:/ .......
delete it_table.
continue.
endloop.
something like that.
BR< Jacek
‎2006 Sep 29 1:28 PM
hi,
chk this.
refresh itab2.
loop at itab1 where field = 'X'.
append itab2 from itab1.
delete itab1.
endloop.
in itab2 u will get the required.
rgds
anver
pls mark all helpful answers
‎2006 Sep 29 11:47 AM
Hi,
loop at itab where field = 'a'
append itab to itab2.
endloop.
‎2006 Sep 29 11:55 AM
Hi
Check out the below code. I gave an example.
Tables lfa1.
data: itab like lfa1 occurs 0 with header line,
itab1 like itab occurs 0 with header line.
select * from lfa1 into table itab.
loop at itab where land1 = 'IN'.
if sy-subrc = 0.
move-corresponding itab to itab1.
append itab1.
endif.
endloop.
loop at itab1.
write:/ itab1-land1,itab1-name1.
endloop.
Regards
Haritha
Message was edited by: Haritha Ramayanam
‎2006 Sep 29 12:33 PM
Hi,
use below logic
data itab1 like itab occurs 0 with header line.
loop at itab where field1 = 'A'.
itab1 = itab.
append itab1.
endloop.
loop at itab1.
write itab1 with value A to log.
endloop.
or use
itab1[] = itab[].
delete itab1 where field1 <> 'A'.
loop at itab1.
write itab1 with value A to log.
endloop.
Regards
amole
‎2006 Sep 29 3:33 PM
Hello,
Deleting a row while looping the internal table is not adviced.
Create a temporary internal table of same type and do liek this,
ITAB2[] = ITAB[].
DELETE FROM ITAB2[] where F1 <> 'A'.
I hope this helps.
Regs,
Venkat
‎2006 Sep 29 5:19 PM
Hi guys,
this approach is probably the fastest, but has a syntax error:
DELETE FROM tabname WHERE is used for database tables. For internal tables use
DELETE <itab> WHERE <cond>
regards,
Clemens
‎2006 Sep 29 4:16 PM
Hi,
You can use the following code:
supposing your internal table name is itab,and that particular field is F1.
Loop at itab where F1 = 'A'.
write / itab-F1.
endloop.
delete itab where F1 = 'A'.
Regards,
Divya