cancel
Showing results for 
Search instead for 
Did you mean: 

Meaning of Variables in Query Generator?

Former Member
0 Kudos

Dear Experts,

Can any one tell me what is meaning of Variable (%0,%1,%2.....%19) in Query Generator.

if give one example or related link will more appropriated.

Thanks & regards,

Santosh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

@Nagararajan sir and

@Johan: other variable's menace the remaining variables. I.e %4,%5,%6...%19.

In what conditions I can use this remaining variable's.

Please give one example.

Regards, 

Santosh

former_member186712
Active Contributor
0 Kudos

Hi,

It's just the name of the variable.

The following query works

SELECT T0.DocNum, T0.CardName, T0.DocTotal FROM OINV T0 WHERE T0.DocDate Between [%15] and [%25]

Regards,

Johan_H
Active Contributor
0 Kudos

Hi Santosh,

SAP simply provides a number of variables in the Query Generator. You can use as many or as few of them as you like.

It is like Augusto said, they are just names. However, there is a  restriction: the order in which you put them in your query. When you use more than one parameter, always use the smallest number first.

So using Augusto's example:

SELECT T0.DocNum, T0.CardName, T0.DocTotal FROM OINV T0 WHERE T0.DocDate Between [%15] and [%25]

First [%15] is used, and then the larger number [%25].

If necessary you can even use the same parameter multiple times.

Regards,

Johan

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear Experts,

Thanks a lot for reply.

Regards,

Santosh

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Variable is used to select  values from given table. If there is no variable, then the query will retrieve data from database.

Thanks & Regards,

Nagarajan

Former Member
0 Kudos

Hi experts,

Thanks a lot for reply.

But I want to know when i can use this variables?

normally %0,%1 and %2 i got but where can i get other variables info?

any links or document will appreciated.

Thanks,

Santosh

Johan_H
Active Contributor
0 Kudos

Hi Santosh,

What do you mean with "other variables" ?

Regards,

Johan

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

What you mean by other variable?

Are you looking for system variable or PLD variable?

Thanks & Regards,

Nagarajan

Former Member
0 Kudos

Hi,

Variables in query generator is use to provide value for parameter at run time for given condition.

i.e. you can provide selection criteria to query report using this variables

Eg:-

SELECT T0.DocNum, T0.CardName, T0.DocTotal FROM OPOR T0 WHERE T0.Status = [%0] and T0.DocDate Between [%1] and [%2]


regards,

Raviraj

Johan_H
Active Contributor
0 Kudos

Hi Santosh,

A variable can be used to make a query "dynamic".

For example:

SELECT T0.CardName FROM OCRD T0 WHERE T0.CardCode = 'C00001'

This query is static. That means it will always return the same answer: the name of the customer with code C00001

You can use the variable to make this query "dynamic":

SELECT T0.CardName FROM OCRD T0 WHERE T0.CardCode = [%0]

Now when you run this query, B1 will ask you to fill in a customer code, and the query result will be the name of the customer that you just gave.

You can use more than one variable, and in that case you need to use your variables in the correct order. So the first one will be [%0], the second one will be [%1], the third one will be [%2], etcetera.

For example:

SELECT T0.DocNum, T0.CardName, T0.DocTotal FROM OINV T0 WHERE T0.DocDate >= [%0] AND T0.DocDate <= [%1]

This query would show you all invoices between the given dates.

Regards,

Johan