cancel
Showing results for 
Search instead for 
Did you mean: 

[ 6944 ] Attribute engine: overflow in numeric calculation

04-18-2023 9:57 AM
Alexia Explorer
10017 views 6 comments
0 Likes
SAP Managed Tags
Subscribe

Dear Community,

I have an issue which is not reproduceable in the Development and Quality systems, only in Production.

I have created a custom CDS virtual data model, based on ACDOCA. I get the following dump, and I found that it is most likely related to the code below, which carries out some conversions.

@Semantics.currencyCode:true
SecuredAmountTMPCurrency as SecuredAmountCurrency,

@Semantics.amount.currencyCode: 'SecuredAmountCurrency'
@DefaultAggregation: #MAX
cast( currency_conversion(
amount => SecuredAmountTMP,
source_currency => SecuredAmountTMPCurrency,
target_currency => :P_DisplayCurrency,
exchange_rate_date => :P_KeyDate,
exchange_rate_type => :P_ExchangeRateType,
// error_handling => 'FAIL_ON_ERROR',
round => #CDSBoolean.true,
decimal_shift => #CDSBoolean.true,
decimal_shift_back => #CDSBoolean.true
) as farp_total_amount_display_crcy ) as SecuredAmount,

@DefaultAggregation: #SUM
cast(Ratio as abap.dec(3,2)) as Ratio,

When I run the view containing above code in Eclipse, I get the following error:

I thought that maybe this is happening if the amount to be converted will ever be set to 'null', and hence tried to mitigate this in the underlying CDS:

@DefaultAggregation: #MAX
@Semantics.amount.currencyCode: 'SecuredAmountTMPCurrency'
case when _BPAdditionalData.Amount is null then cast(0 as farp_total_amount_display_crcy) else
_BPAdditionalData.Amount end as SecuredAmountTMP,
@Semantics.currencyCode:true
case when _BPAdditionalData.Currency is null then cast('' as vdm_v_display_currency )
else _BPAdditionalData.Currency end as SecuredAmountTMPCurrency,

However, this did not solve anything. The Amount is already typed with decimal value with 2 decimal places.

Could you please advise on how to fix this issue? Is there any way to indentify exactly where the issue is happening, based on the info of the dump from AttributeEngine? I couldn't find any useful info in order to identify the issue precisely.

Many thanks!

Alexandra

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor

I can find interesting answers in the forum by searching numeric overflow: the precision of the decimal value is larger than the target precision.

Don't they help?


It will also be helpful if you tell us the data types (including precision) you use.


Pasting the text could help to find other same questions or if your question will contain an interesting answer:

Category ABAP programming error

Runtime Errors DBSQL_SQL_ERROR

Except. CX_SY_OPEN_SQL_DB

SQL error "SQL code: 314" occurred while accessing table "ZIFI C DOUBTFULDEBTS".

Database error text: "SQL message: numeric overflow: search table error: [6944] AttributeEngine: overflow in numeric calculation;exception 70006944: AttributeEngine: overflow in numeric calculation ; [here]checkdigits(fixed(fixed("SAPHANADB.#_SYS_QO_COL_L:20904_7eab9171ebd0:401"

Database returned the SQL code 314. Error text: numeric overflow: the precision of the decimal value is larger than the target precision: 3

Alexia
Explorer
0 Likes

If I would have found anything useful, I wouldn't be asking.

The Data type is visible in the code, and it's the same as for most currency amounts used in CDS views.

Sandra_Rossi
Active Contributor
0 Likes

I was not clear probably: you searched in the forum, so please tell us what you tried? (so that people don't need to ask you again)

You didn't mention the data types which are VERY important in your question. The name farp_total_amount_display_crcy is useless because we don't know its data type, you only said "2 decimal places", but what about the rest of the data type? (total number of digits, etc.) Could you share the screenshot of the data type please? What about Ratio column? (Ratio from the source of course)

Alexia
Explorer
0 Likes

Thanks for clarifying, Sandra! I didn't find anything suitable for my context, used in CDS views.

This is the data type:

And this is the Ratio amount which will be cast in the code above.

Sandra_Rossi
Active Contributor
0 Likes

I guess that "precision 3" concerns the "3" in "abap.dec(3,2)" (cast of ratio). 3 is the total number of digits, including the 2 decimal digits, so the integer part can store only 1 digit.

When applying CAST on numbers, "If the value range is exceeded, an exception is raised that can be caught in ABAP using CX_SY_OPEN_SQL_DB." (doc)

So probably a value is bigger than 9.99

What if you cast to abap.dec(31,2)?

Alexia
Explorer
0 Likes

Thanks for your reply!

The result of the operation should always be a subunit number (0,xx), therefore I would not think that the result is exceeded.

I used a reduced number for the integer part, because I use this value in another view in a multiplication operation, which would then overflow due to the type. It could be related to the precision, the number of decimals.

If the result of a division operation (Ratio) would be something like 0,3333(3), would the CAST dump due to its precision being larger then the 2 digits defined by me? As per my understanding it should be truncated, but maybe I am wrong.

I am also concerned about the conversion above. My impression was that it's coming from there.