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

Read ITAB

Former Member
0 Likes
718

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.

8 REPLIES 8
Read only

Former Member
0 Likes
688

loop at it_table where yor field = 'A'.

write:/ .......

delete it_table.

continue.

endloop.

something like that.

BR< Jacek

Read only

0 Likes
688

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

Read only

Former Member
0 Likes
688

Hi,

loop at itab where field = 'a'

append itab to itab2.

endloop.

Read only

Former Member
0 Likes
688

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

Read only

Former Member
0 Likes
688

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

Read only

Former Member
0 Likes
688

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

Read only

0 Likes
688

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

Read only

Former Member
0 Likes
688

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