cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDS negative FLTP in aggreggation MAX returns 0 in 7.5

eglehp
Explorer
0 Likes
712

Hello, 

I am using CDS to extract material classification data, transpose it to columns and expose to odata. It went well untill I discoverend that we have negative decimal values in the classification fields. Those values get zeroed in the cds conversion. 

I created 2 cds views.

1 cds. Selects material classification data.

Select OBJEK, ATFLV from AUSP

2  cds. Transposes classification row data to columns using function MAX to get only one value. 

max ( case cl_name when 'TOTAL' then
case when alt_value <> 0 then alt_value else 0
end else 0
end ) as total.

I used CDS function MAX to return decimals but it does not convert NEGATIVE floating quantity fields  AUSP-ATFLV = -0,0018 (-1.8000000000000000E-03).

MAX returns 0 if the value is negative. I am on version NW 7.5 but even the newer  FLTP_TO_DEC cannot use negative literal.

Function AVG returns floating type values but I do not need average calculation. 

Can anyone  help to find a solution?

Regards,

Egle

P.S. I found a solution by my self. Mark a new field when fltp value is negativ. Convert negativ to positiv befor aggregation MAX. Convert to negativ value in a following CDS after a CDS with MAX.

 

 

Accepted Solutions (0)

Answers (2)

Answers (2)

MKreitlein
Active Contributor
0 Likes

@eglehp 

I think you are confusing max() with abs()? Might it be?

BR, Martin

eglehp
Explorer
0 Likes
I use MAX to extract only one value from multiple rows to transpose it as a column in another CDS. It has nothing to do with abs().
junwu
SAP Champion
SAP Champion
0 Likes

do you understand what max do?

eglehp
Explorer
0 Likes
yes, I do.
junwu
SAP Champion
SAP Champion
0 Likes
are you sure? then tell me why it is max's fault?
eglehp
Explorer
0 Likes
The aggregation function MAX should return the type of an opperand and it does as far as the value of the floating type operand is positiv.
eglehp
Explorer
0 Likes
I found someone mention that MAX, MIN, SUM operate on decimal calculations. It can be explained that like fltp_to_dec, it can not be used with negative literals. AVG function does work with negativ fltp and returns negativ fltp as expected, but I can't use that.