2011 Sep 27 9:38 AM
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
2011 Sep 27 9:43 AM
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
2011 Sep 27 9:43 AM
Please paste the written code...so that we can help you...Yes its possible
2011 Sep 27 9:56 AM
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
2011 Sep 27 9:59 AM
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.
2011 Sep 27 10:41 AM
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.
2011 Sep 27 10:47 AM
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
2011 Sep 27 10:59 AM
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
2011 Sep 27 11:22 AM
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