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: 

Internal table deletion

Former Member
0 Kudos

Hi,

I have an internal table with 1000 material and i want to delete the material from internal table which length is more than 15.

I do not want to use

loop .

delete

endloop.

Is there any other better way?

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Just a sample.


DATA lt_vbap TYPE TABLE OF vbap.

SELECT *
  FROM vbap
  INTO TABLE lt_vbap
 WHERE matnr NE space.

DELETE lt_vbap WHERE matnr+15(x) NE ' '.  "fill x with the remaining length of data variable

best regards,

John

12 REPLIES 12

former_member186741
Active Contributor
0 Kudos

Please clarify.

Are you saying that you only need the first 15 entries of the table or are you saying you want to remove any entries in the table which have a matnr field of greater length than 15? Or something else??

0 Kudos

Hi,

I want to delete the material length if greater than 15

for ex

material

123444 - do not delete

1234567890abcdefr - delete

1234567890abcdefty - delete

asdhgk - do not delete

0 Kudos

loop at itab.

find stlen for each material.

if stlen >15 .

delete itab using index.

endif.

endloop.

0 Kudos

Hi,

I dont want to use use loop .. endloop.

If i have 2 lacs material if i use loop .. endloop it will read 2 lacs times . i want to avoid this

I need someother way to do it.

0 Kudos

Have you taken a look at my example?

Best regards,

John

0 Kudos

Hi

try with jvanpelt solution

its work

Thanks

0 Kudos

Hi,

You can code like this:

DELETE <itab> WHERE matnr+15(3) NE space.

This statement will delete the record from <itab> where the MATNR is greater than 15 character.

Regards

DKS

Former Member
0 Kudos

Hi

What you can do is create a field symbol and then let this field symbol point to the header line of the internal table then check you query against the field-symol entry and if the entry is found then the remove the adress where the field symbol is pointing for that entry.

Thanks

Former Member
0 Kudos

Hi,

Just a sample.


DATA lt_vbap TYPE TABLE OF vbap.

SELECT *
  FROM vbap
  INTO TABLE lt_vbap
 WHERE matnr NE space.

DELETE lt_vbap WHERE matnr+15(x) NE ' '.  "fill x with the remaining length of data variable

best regards,

John

0 Kudos

Hi , check the following code..

data:begin of it_data occurs 0,

matnr(18),

end of it_data.

data: int type i.

it_data-matnr = '123444'.

append it_data.

it_data-matnr = '1234567890abcdefr'.

append it_data.

it_data-matnr = '1234567890abcdefty'.

append it_data.

it_data-matnr = 'asdhgk'.

append it_data.

loop at it_data.

clear int.

int = strlen( it_data-matnr ).

if int > 15.

delete it_data.

endif.

endloop.

Ram.

0 Kudos

Hi

use this code.

DELETE <your Internal Table> WHERE strlen(material) GT 15.

Hope this will work.

With Regards.

0 Kudos

Hi, check this one........becarefull remove leading zeros for material

data:begin of it_data occurs 0,

matnr(18),

end of it_data.

data: int type i.

it_data-matnr = '123444'.

append it_data.

it_data-matnr = '1234567890abcdefr'.

append it_data.

it_data-matnr = '1234567890abcdefty'.

append it_data.

it_data-matnr = 'asdhgk'.

append it_data.

DELETE it_data WHERE matnr+15(3) NE ' '.