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

delete from itab

Former Member
0 Likes
1,241

i have a itab in which i have follow records

mblnr menge bwart smbln

0021 8 131

0024 5 131

0028 8 132 0021

i want to delete row with mblnr = 21 and 28.

can anyboby help. points will awarded surely.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,174

Hi Sarabjit,

For deleting the records with a specific Movement Type, you need to code just one line.

DELETE itab WHERE bwart = 'Movement type you want to exclude'.

For ex.: DELETE itab WHERE bwart = '132'.

For deleting the records, where the mblnr values is contained by any other record in smbln:

Here you will need to use a loop.

Fill a range for smbln first. RANGES : r_smbln FOR smbln.

LOOP AT itab.

IF NOT itab-smbln IS INITIAL.

MOVE : 'I' to r_smbln-sign,

'EQ' to r_smbln-option,

itab-smbln to r_smbln-low.

APPEND r_smbln.

ENDIF.

ENDLOOP.

Now delete the records.

DELETE itab WHERE mblnr IN r_smbln.

Thanks and Best Regards,

Vikas Bittera.

**Points for useful answers**

Hi Sarabjit,

For deleting the records with a specific Movement Type, you need to code just one line.

DELETE itab WHERE bwart = 'Movement type you want to exclude'.

For ex.: DELETE itab WHERE bwart = '132'.

For deleting the records, where the mblnr values is contained by any other record in smbln:

Here you will need to use a loop.

Fill a range for smbln first. RANGES : r_smbln FOR smbln.

LOOP AT itab.

IF NOT itab-smbln IS INITIAL.

MOVE : 'I' to r_smbln-sign,

'EQ' to r_smbln-option,

itab-smbln to r_smbln-low.

APPEND r_smbln.

ENDIF.

ENDLOOP.

Now delete the records.

DELETE itab WHERE mblnr IN r_smbln.

Thanks and Best Regards,

Vikas Bittera.

**Points for useful answers**

7 REPLIES 7
Read only

Former Member
0 Likes
1,174

hi kaur,

delete itab where mblnr = 0021 and mblnr = 0028.

Thanks & regards,

S.Suresh.

Reward Point if useful...

Read only

Former Member
0 Likes
1,174

Hi Kaur,

Use DELETE statement to delete the internal table entries

DELETE itab WHERE MBLNR = '0021' OR MBLNR = '0028'.

Check this link for DELETE statement

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/delete_i.htm

Thanks,

Vinay

Read only

Former Member
0 Likes
1,174

hi,

You have to use the below code :

delete itab where mblnr = '0021' or

mblnr = '0028'.

Thanks,

Sriram Ponna.

Message was edited by:

Sriram Ponna

Read only

0 Likes
1,174

but i want to delete records based on movement type and smbln such as delete those records which have movement type = 132 or smbln = mblnr, in my case thsese records are 0028 and 0021

Read only

Former Member
0 Likes
1,174

Hi,

I want to add some more points to mr.vinay's reply.

ranges : r_mblnr for table-mblnr.

r_mblnr-low = '0021'.

append r_mblnr.

r_mblnr-low = '0028'.

append r_mblnr.

now.. use the delete statement as below....

DELETE itab WHERE MBLNR in r_mblnr.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/delete_i.htm

Please reward points if it is useful.....

Please feel free to contact....

Regards

Sreenivasa sharma

Read only

Former Member
0 Likes
1,175

Hi Sarabjit,

For deleting the records with a specific Movement Type, you need to code just one line.

DELETE itab WHERE bwart = 'Movement type you want to exclude'.

For ex.: DELETE itab WHERE bwart = '132'.

For deleting the records, where the mblnr values is contained by any other record in smbln:

Here you will need to use a loop.

Fill a range for smbln first. RANGES : r_smbln FOR smbln.

LOOP AT itab.

IF NOT itab-smbln IS INITIAL.

MOVE : 'I' to r_smbln-sign,

'EQ' to r_smbln-option,

itab-smbln to r_smbln-low.

APPEND r_smbln.

ENDIF.

ENDLOOP.

Now delete the records.

DELETE itab WHERE mblnr IN r_smbln.

Thanks and Best Regards,

Vikas Bittera.

**Points for useful answers**

Read only

0 Likes
1,174

thanx vikas you told me a new thing.thanx alot awarded you full points.