cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a negative value in selection criteria of query report?

joseph_antony
Explorer
0 Kudos
89

Hello,

Is it possible to get a negative value in the selection criteria of a query report?

Please see the sample below:

DECLARE @dayfrom AS INT
DECLARE @dayto AS INT
Select @dayfrom = T0.NumOfDays FROM CDC1 T0 Where T0.NumOfDays = '[%0]' Select @dayfrom = '[%0]'
Select @dayto = T0.NumOfDays FROM CDC1 T0 Where T0.NumOfDays = '[%1]' Select @dayto = '[%1]'

While executing this, we can add a negative sign and the report would should data as per selection criteria.

Ex. -10 & -20

Is it possible to make changes in the report so that the user enters a positive value but the query checks it for negative value, ex: in selection criteria user enters 10 and 20 but the result should display it based on  -10 and -20?

Regards,

Joseph

 

Accepted Solutions (0)

Answers (2)

Answers (2)

inga_babco2
Explorer
0 Kudos

Hello Joseph,

You can multiply the value by -1:

DECLARE @dayfrom AS INT
DECLARE @dayto AS INT
Select @dayfrom = T0.NumOfDays FROM CDC1 T0 Where T0.NumOfDays = '[%0]' Select @dayfrom = '[%0]' * -1
Select @dayto = T0.NumOfDays FROM CDC1 T0 Where T0.NumOfDays = '[%1]' Select @dayto = '[%1]' * -1
Select @dayfrom, @dayto

inga_babco2_0-1747033237515.png

Best regards

Inga

LoHa
Active Contributor
0 Kudos

Hi Joseph,

in my opinion you have 2 ways.

First
When using a date field you are able to insert -10 and the date will already be calculated with the right date, when pressing tab. You need to train your users to do so for your query.

Second
Use a quantity field, here it is possible to insert a negativ value (or find sonething similar)

2025-05-12 07_15_23-How to get a negative value in selection criteria ... - SAP Community.png2025-05-12 07_14_46-How to get a negative value in selection criteria ... - SAP Community.png

/*Buchungsdatum*/
/**SELECT FROM [OFPR] T0 **/
DECLARE @DocDateFrom AS Date
/* WHERE */
SET @DocDateFrom = /* T0.F_RefDate */ '[%0]'

/**SELECT FROM [OFPR] T1 **/
DECLARE @DocDateTo AS Date
/* WHERE */
SET @DocDateTo = /* T1.T_RefDate */ '[%1]'

regards Lothar