‎2007 Jul 23 11:45 AM
Hello Friends,
I have some problem with the where condition.
Within the method of my Class, I have written a select query.
select * from table TAB1 into table lt_TAB1 where FIELD1 = ls_STRUCTURE-FIELD1.
Here ls_STRUCTURE is getting filled in the method based on the screen fields. The User enters * in the screen field FIELD1, then this query doesnt work. How to modify the query so that this works?
Thanks & Regards,
Raju
‎2007 Jul 23 11:48 AM
id do a ranges table.
if you leave a value blank in a where condition you will always get zero records.
if you have 0 entires in a ranges table your select will get you ALL records.
if you are using ranges tables (same as Select options) you have to use the WHERE IN statement
‎2007 Jul 23 11:48 AM
id do a ranges table.
if you leave a value blank in a where condition you will always get zero records.
if you have 0 entires in a ranges table your select will get you ALL records.
if you are using ranges tables (same as Select options) you have to use the WHERE IN statement
‎2007 Jul 23 11:52 AM
Hi,
Is TAB1 is Internal table or Database table. If the TAB1 is internal table then you should not use Select * then you need to use either Read table or the Loop at TAB1 statements. And in where condition pass a variable instead of giving strucutre field. decalare a varialbl then assign the value of ls_STRUCTURE-FIELD1 to varaible & pass it. e.g.:
variable = ls_STRUCTURE-FIELD1.
Read table TAB1 into table lt_TAB1 where FIELD1 = varaible.
OR
Loop at TAB1 where FIELD1 = varaible.
endlloop.
Reward points if helpful answer.
Ashvender
‎2007 Jul 23 11:53 AM
if ls_STRUCTURE-FIELD1 eq '*'.
concatenate ls_STRUCTURE-FIELD1 '%' into ls_STRUCTURE-FIELD1.
select * from table TAB1 into table lt_TAB1 where FIELD1 <b>like</b> ls_STRUCTURE-FIELD1.
else.
select * from table TAB1 into table lt_TAB1 where FIELD1 = ls_STRUCTURE-FIELD1.
endif.
‎2007 Jul 23 11:56 AM
do like this..
ranges : rfield1 for ls_STRUCTURE-FIELD1.
rfield1-low = ls_STRUCTURE-FIELD1.
rfield1-sign = 'I'.
if ls_STRUCTURE-FIELD1 ca '*'.
rfield1-option = 'CP'.
else.
rfield1-option = 'EQ'.
endif.
select * from table TAB1 into table lt_TAB1 where FIELD1 in rfield1.
regards
shiba dutta
‎2007 Jul 23 11:58 AM
hi Narayana,
plz check the table with that entry (*). if it is existing then it will true.otherwise it is false.
-Pesi.
‎2007 Jul 23 12:41 PM
Hi Narayana,
view this code and use like instead of IN.
DATA: T_SFLIGHT LIKE SFLIGHT OCCURS 0 WITH HEADER LINE.
SELECT * FROM SFLIGHT INTO TABLE T_SFLIGHT WHERE CARRID = 'AZ' AND
CONNID IN ('0555', '0790') AND FLDATE LIKE '2004%'.
LOOP AT T_SFLIGHT.
WRITE: /,T_SFLIGHT-CARRID,T_SFLIGHT-CONNID.
ENDLOOP.
If useful rewrad me with points.
Thanks.
Sanket.
‎2007 Jul 24 5:18 AM
Hi Thanks all for the reply.
The problem is solved. I used the following code:
data: lt_search2 type
comt_prsearch_sel_option_tab,
ls_search2 type
comt_prsearch_sel_option.
ls_search2-low = ls_structure-FIELD1.
ls_search2-sign = 'I'.
if ls_structure-FIELD1 ca '*'.
ls_search2-option = 'CP'.
else.
ls_search2-option = 'EQ'.
endif.
append ls_search2 to lt_search2.
Thanks & regards,
Raju