‎2006 Dec 20 10:19 AM
Hi Guys,
I got a problem with select query...could you polease help me out...plz check the second select query statement
when i open tstcp table i gave Ztable and then when I exceute i am able to get the list when i do it programatically it is not working .....
any suggestions...points will be rewarded..
select tabname
from dd02l into table i_dd02l where tabname like 'Z%' and
( tabclass = 'VIEW'
or
tabclass = 'TRANSP' ) and
( mainflag = 'X'
or
mainflag = '' ).
if not i_dd02l[] is initial.
loop at i_dd02l.
v_tabna = i_dd02l-tabname.
select single tcode
param into (v_tcode , v_param)
from tstcp where param like '%v_tabna%'.
i_tstcp-tcode = v_tcode.
i_tstcp-param = v_param.
append i_tstcp.
clear i_tstcp.
endloop.
endif.
Regards,
Ravi Ganji
‎2006 Dec 20 10:24 AM
Hi Ravi,
You cannot give variable names in quotes, try the below if it works , copy the select and checkout
v_tabna = i_dd02l-tabname.
select single tcode
param into (v_tcode , v_param)
from tstcp where param like '%'v_tabna'%'.
‎2006 Dec 20 10:24 AM
data: g_str(10).
.......
.
....
.
v_tabna = i_dd02l-tabname.
concatenate '%' v_tabna '%' into g_str.
select single tcode
param into (v_tcode , v_param)
"from tstcp where param like '%v_tabna%'.
from tstcp where param like g_str.
the statement this as a string so you are not getting a hit.
try this.
Message was edited by:
Kaluvala Santhosh
‎2006 Dec 20 10:24 AM
Hi,
v_tabna = i_dd02l-tabname.
concatenate '%' v_tabna '%' into v_tabna.
select single tcode
param into (v_tcode , v_param)
from tstcp where param like v_tabna.
‎2006 Dec 20 10:26 AM
Hi,
The problem lies with the where condition.. it does not take the value but
takes the v_tabna as the value.
select single tcode
param into (v_tcode , v_param)
from tstcp where param like '%v_tabna%'.
Say if U have v_tabna = 'MARA' it will not consider MARA but it will consider v_tabna as it is inside the quotes.
Regards,
GSR.
‎2006 Dec 20 10:26 AM
HAVE YOU TRIED BY
select single tcode
param into (v_tcode , v_param)
from tstcp where param like '%V_TABNA%'.
AND ONE THING _ (UNDER SCORE ) IN LIKE STATEMENT IS ASSUME FOR ANY ONE CHARACTER WILL BE THERE.
I.E.
V_TABNA IN LIKE MEANS V(ANYCHAR)TABNA.
SOP BE CAREFUL OF THAT
REGARDS
SHIBA DUTTA
‎2006 Dec 20 10:31 AM
Hi ,
The statement will not work because it will try to find all records which has v_tabna in its field.
So what you need to do is concatenate % before and after the value of the varaible v_tabna and store it in some varaible say v_value and use it in the where clause.
so your code will look like this
*v_tabna = i_dd02l-tabname.
concatenate '%' i_dd02l-tabname '%' into v_tabna
select single tcode
param into (v_tcode , v_param)
from tstcp where param like tabna.Regards
Arun