Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reg select query

Former Member
0 Likes
688

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

6 REPLIES 6
Read only

Former Member
0 Likes
658

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'%'.

Read only

Former Member
0 Likes
658

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

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
658

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.

Read only

Former Member
0 Likes
658

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.

Read only

Former Member
0 Likes
658

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

Read only

Former Member
0 Likes
658

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