Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Aug 24, 2017 at 11:25 AM

    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

    Add comment
    10|10000 characters needed characters exceeded