Skip to Content

ABAP CDS: Sum=> value out of range

I have written simple CDS view with below code.

@AbapCatalog.sqlViewName: 'ZA_HOURS'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@ClientDependent: true
@EndUserText.label: 'Employee hours reported'
define view Z_Hours
as select from catsdb 
 {
  key pernr,
  sum(catshours) as totalHours
} 
group by pernr

I get below error in ST22.

Database error text: "SQL message: numeric value out of range: not enough space for packed decimal at function __copy_trex_field_Fixed8_check__() (at pos 54) "

I think the problem is with totaling and value exceeding the allowed range. Any help please?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 17, 2016 at 09:28 AM

    Hi,

    I guess the problem is that the sum expressions uses the data type of catshours as a return value. This is a P 3. Therefore you get the value out of range when calculating the sum.

    Try to cast the casthours to an other data type (e.g.abap.dec(len,decimals))using the CAST operator (https://help.sap.com/abapdocu_750/en/abencds_f1_cast_expression.htm) before calculating the sum. That way you should be able to get rid of the exception .

    Christian

    Add comment
    10|10000 characters needed characters exceeded