cancel
Showing results for 
Search instead for 
Did you mean: 

How to use [%0] , [%1] , ..... etc perfectly

marour
Participant
0 Kudos

Good Morning SAP Experts,

i really have a very important Issue ( to me ) and i tried every possible way to solve it but still have no result.

select t.a , t.b , t.c from myTable where t.d = [%0]

this is going to work very well and the user has to input the value of "d".

why doesnt it work like this :

declare @aa varchar(20)

SET @aa = [%0]

select t.a , t.b , t.c from myTable where t.d = @aa

??

my problem is simply that i need sometimes to use this input in two different positions in the same Qurey.

i need to let the user input the value that i store as a variable and use this variable wherever i need it in my Query... as simple as this.

Can anyone help me or make me understand why it doesnt work like this?

Thanks in Advance

Accepted Solutions (0)

Answers (1)

Answers (1)

anand_singh
Explorer
0 Kudos

Hi ,

Use Below logic:-

declare @aa varchar(20)

SET @aa = (select x.d from mytable x where x.d = [%0])

select t.a , t.b , t.c from myTable t where t.d = @aa

from this way you can use @aa variable more than one time.

Regards,

Anand