06-14-2010 8:39 PM
Hello experts,
I have an internal table that contains too many unwanted entries. I need to delete the entries when it's value field doesn't equal to
CAD, EUR, GBP, or USD. I am implementing IF_EX_TRIP_WEB_CUSTOMIZING~USER_EXIT_CUSTOMIZING.
Can I use cond_syntax to delete them? and how I can use cond_syntax?
Thanks so much for your help.
AS.
06-15-2010 3:30 PM
if that is not a primary key.. better fetch it to internal table.. and then delete by using:
DELETE itab WHERE f1 NE CAD and f1 NE EUR and f1 NE GBP and f1 NE USD.
06-14-2010 8:44 PM
06-15-2010 2:53 PM
Hi Rob,
The cond_syntax is a syntax: sql_cond - (cond_syntax)
You can find it by clicking the following link.
http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_DYNAMIC.htm
Thanks,
AS.
06-15-2010 3:01 PM
Then I think the answer is "no".
Dynamic WHEREs cannot be used to remove entries from internal tables.
Rob
06-15-2010 3:11 PM
This sounds pretty basic.
You can use or or * not in* with a if condition
06-15-2010 3:22 PM
This seems to be available from 7.0 Enhancement Package 2:
http://help.sap.com/abapdocu_70/en/ABAPDELETE_ITAB_LINES.htm#!ABAP_ADDITION_4@4@
There is an example for (cond_syntax) given.
cond_syntax is a string that must contain a valid logical expression for ABAP statements.
I would also look into not filling unwanted entries into the internal table in the first place, maybe during selection from the database.
Thomas
06-15-2010 3:30 PM
if that is not a primary key.. better fetch it to internal table.. and then delete by using:
DELETE itab WHERE f1 NE CAD and f1 NE EUR and f1 NE GBP and f1 NE USD.
06-17-2010 2:56 PM
Thanks for your help.
These 4 values are from an imported table which is dynamic. I have to use the values in this table to check again another internal table to delete anything not equal to the 4 values.
I have no problems to used 2 loops to delete the unwanted entries, but I am looking for an easy way. That's why I am thinking if I can use cond_syntax.
If anyone knows how to use cond_syntax, could you please provide me an example???
Thanks so much,
AS
06-17-2010 3:26 PM
As I said, your system needs to be on SAP_ABA 702 to have cond_syntax available for internal table handling.
http://help.sap.com/abapdocu_70/en/ABENNEWS-71-ITAB.htm#!ABAP_MODIFICATION_1@1@
Then, cond_syntax is a string that must contain a logical expression, such as
FIELD1 = 'X' OR FIELD1 = 'Y' OR FIELD1 = 'Z'
You must build it dynamically in your code before you can use it:
DELETE itab WHERE (cond_syntax).
If you search around a little bit, you should find good examples.
Thomas
06-17-2010 3:38 PM
Hi Anna,
If you know , Which are all the entries you want. You move them to Range ITAB ( I mean the vaules of CAD, EUR, GBP, or USD to Range ITAB).
Then You can simply write a delete statement which will delete the values are not in the Range as below.
delete ITAB where matnr not in l_r_matnr. " Here I have take an example of MATNR
Given below is the sample code Which serves your need.
DATA : l_r_matnr type RANGE OF matnr,
l_s_matnr LIKE LINE OF l_r_matnr.
" ITAB and ITAB2 two internal table with matnr Values
" ITAB has some matnr record which should not be present in ITAB2
ITAB2-matnr = '100'.
APPEND ITAB2.
ITAB2-matnr = '200'.
APPEND ITAB2.
ITAB2-matnr = '100'.
APPEND ITAB2.
ITAB2-matnr = '300'.
APPEND ITAB2.
"Here we are going to delete other than 100 and 200 ( As per your Example Valid values )
" Here For example purpose i am populating ITAB , in your Case you can populate the Range table by looping your ITAB
ITAB-matnr = '100'.
APPEND ITAB.
ITAB-matnr = '200'.
APPEND ITAB.
" Making Range table from Dynamic table ( Say suppose it is the dynamic table generated )
LOOP at ITAB.
l_s_matnr-sign = 'I'.
l_s_matnr-option = 'EQ'.
l_s_matnr-low = ITAB-matnr.
APPEND l_s_matnr to l_r_matnr.
clear l_s_matnr.
ENDLOOP.
" Deleting the records which are not required
delete ITAB2 where matnr not in l_r_matnr.
Edited by: Prasath Arivazhagan on Jun 18, 2010 3:24 AM
06-17-2010 3:50 PM
Instead of deleting the entries, i prefer moving the required( matched entries) to another internal table which avoids rebuilding of the internal table index.
06-22-2010 5:59 PM