‎2015 Aug 19 9:31 AM
Hi All,
I have a field with type sting in my database table, i need to get the records from database table where this string field is empty. I tried to use this string field in here condition and check if it is NULL or not. But it is not working because "Long string or text cannot be used in WHERE condition".
My Idea is to Copy this DB table into an Internal table, Loop through the internal table with where condition that string field is empty and append those records to another internal table.
Its working but i would like to know if there is any other way to do it.
My Code:
DATA: itab1 TYPE STANDARD TABLE OF DBtable,
itab2 TYPE STANDARD TABLE OF DBtable,
wa TYPE DBtable.
SELECT * FROM DBtable INTO CORRESPONDING FIELDS OF TABLE itab1.
LOOP AT itab1 INTO wa WHERE strfld is NOT INITIAL. "strfld is string field.
APPEND wa to itab2.
ENDLOOP.
Thanks & regards,
NarsiReddy.
‎2015 Aug 19 10:07 AM
Dear NarsiReddy,
Greetings!
I feel using of 'Loop' on the itab might be at the cost of performance. So, better use 'DELETE' statement after 'SELECT' statement.
SELECT * FROM <dbtable> INTO TABLE <itab1>.
DELETE TABLE <itab1> WHERE strfld is initial.
with this statement execution, <itab1> will have the entries for which String Field is not blank.
Regards,
Shankar
‎2015 Aug 19 10:07 AM
Dear NarsiReddy,
Greetings!
I feel using of 'Loop' on the itab might be at the cost of performance. So, better use 'DELETE' statement after 'SELECT' statement.
SELECT * FROM <dbtable> INTO TABLE <itab1>.
DELETE TABLE <itab1> WHERE strfld is initial.
with this statement execution, <itab1> will have the entries for which String Field is not blank.
Regards,
Shankar
‎2015 Aug 19 10:38 AM
Hi Shankar,
Thank you, Perfect!
But a small correction, syntax is:
DELETE itab1 WHERE strfld IS INITIAL.
Kind regards,
NarsiReddy.
‎2015 Aug 19 10:07 AM
Dear NarsiReddy,
Greetings!
I feel using of 'Loop' on the itab might be at the cost of performance. So, better use 'DELETE' statement after 'SELECT' statement.
SELECT * FROM <dbtable> INTO TABLE <itab1>.
DELETE TABLE <itab1> WHERE strfld is initial.
with this statement execution, <itab1> will have the entries for which String Field is not blank.
Regards,
Shankar
‎2015 Aug 19 11:48 AM
Hi Naris,
Hope the below condition is helpful,
LOOP AT itab1 INTO wa WHERE strfld = ' '.
Regards,
Karthik