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 entries from table type any

Former Member
0 Likes
2,101

Hello,

I have table type any and I want to delete entries on it according to parameter ,for instance

if in the parameter I have 3 I need to delete all the entry on the table that are less equal to 3 etc.

What is the best way to do that ?

Regards

Joy

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,603

Please paste the written code...so that we can help you...Yes its possible

Hello,

I have table type any and I want to delete entries on it according to parameter ,for instance

if in the parameter I have 3 I need to delete all the entry on the table that are less equal to 3 etc.

What is the best way to do that ?

Regards

Joy

7 REPLIES 7
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,604

Please paste the written code...so that we can help you...Yes its possible

Read only

0 Likes
1,603

HI Keshav,

I have only table type any one parameter that are relevant ...:)

<lt_itab> and lv_skip

if its not was any table i can use

DELETE lt_itab WHERE xyz LE iv_skip.

Thanks

Joy

Read only

0 Likes
1,603

Hi,

You should use something like


LOOP AT <itab> ASSIGNING <rec>.
   ASSIGN COMPONENT 'XYZ' of STRUCTURE <rec> to <fs>.
   IF <fs> LE lv_skip.
      DELETE TABLE <itab> FROM <rec>.
   ENDIF.
 ENDLOOP.

Kr,

m.

Read only

0 Likes
1,603

Erratum: my bad, the above example is not correct. You should not deleting within the LOOP...

Here is a working alternative:


CREATE DATA lo_data LIKE <itab>.
ASSIGN lo_data->* TO <itab2>.
LOOP AT <itab> ASSIGNING <rec>.
   ASSIGN COMPONENT 'XYZ' OF STRUCTURE <rec> TO <fs>.
   IF <fs> GT lv_skip.
     INSERT <rec> INTO TABLE <itab2>.
   ENDIF.
ENDLOOP.
<itab>[] = <itab2>[].
FREE <itab2>.

Hope it helps,

m.

Read only

0 Likes
1,603

HI Manu

Thanks ,

the issue here is that i don't now what is 'XYZ' i.e. in any time I can get different table and

I dont know what to put as XYZ.

Best Regards

Joy

Read only

0 Likes
1,603

Hi,

So you need to check for all fields of a certain type ?

If so, you will have to deal with methods from classes such as CL_ABAP_TYPEDESCR to first know the type of your fields and be able to applly filtering...

added: Easier with a DESCRIBE statement actually...

Kr,

m.

Edited by: Manu D'Haeyer on Sep 27, 2011 12:15 PM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,603

Hi,

The solutions are already provided above by our friends. I would like to add one thought that instead of deleting move the satisfied entries to a new internal table. This type of technique has helped me in tuning the performance of program

Kesav