abap - 运行时生成程序转储 ID 期间发生内部错误:BCD_OVERFLOW
问题描述
程序运行时生成期间发生内部错误(转储 ID:BCD_OVERFLOW)
检查期间没有错误,但激活会出现此错误。
解决方案
如果您尝试将值分配给“超出范围”的数值属性或变量(因此会导致溢出),则会在任何 ABAP 代码中出现此问题。在这里查看数字类型的所有可能值范围:
Type Value Range
---------- ------------------------------------------------------------------------------
b 0 to 255
s -32,768 to +32,767
i -2,147,483,648 to +2,147,483,647
int8 -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
p The valid length for packed numbers is between 1 and 16 bytes. Two places are
packed into one byte, where the last byte contains only one place and the sign,
which is the number of places or places calculated from 2 * len1. After the
decimal separator, up to 14 decimal places are allowed ( the number of decimal
places should not exceed the number of places). Depending on the field length
len and the number of decimal places dec, the value range is: (-10^(2len-1)
+1) / (10^(+dec)) to (+10^(2len-1) -1) /(10^(+dec)) in increments of 10^(-dec).
Any intermediate values are rounded decimally. Invalid content produces undefined
behavior.
decfloat16 Decimal floating point numbers of this type are represented internally with 16
places in accordance with the IEEE-754-2008 standard. Valid values are numbers
between 1E385(1E-16 - 1) and -1E-383 for the negative range, 0 and +1E-383 to
1E385(1 - 1E-16) for the positive range. Values between the ranges form the
subnormal range and are rounded. Outside of the subnormal range, each 16-digit
decimal number can be represented exactly with a decimal floating point number
of this type.
decfloat34 Decimal floating point numbers of this type are represented internally with 34
places in accordance with the IEEE-754-2008 standard. Valid values are numbers
between 1E6145(1E-34 - 1) and -1E-6143 for the negative range, 0 to +1E-6143
and 1E6145(1 - 1E-34) for the positive range. Values between the ranges form
the subnormal range and are rounded. Outside of the subnormal range, each
34-digit decimal number can be represented exactly using a decimal floating
point number.
f Binary floating point numbers are represented internally according to the
IEEE-754 standard (double precision). In ABAP, 17 places are represented (one
integer digit and 16 decimal places). Valid values are numbers between
-1.7976931348623157E+308 and -2.2250738585072014E-308 for the negative range
and between +2.2250738585072014E-308 and +1.7976931348623157E+308 for the
positive range, plus 0. Both validity intervals are extended to the value zero
by subnormal numbers according to IEEE-754. Not every sixteen-digit number can
be represented exactly by a binary floating point number.
最小的可重现示例:
REPORT ztest.
DATA num TYPE int1.
num = 1000. " <=== run time error
解决方案是使用更大的数据类型,例如int2
(最多 32767)或I
(4 个字节的整数):
REPORT ztest.
DATA num TYPE int2. " <=== larger type
num = 1000. " <=== no more error
注意:decfloat34
可能是更大的数字数据类型,它几乎可以处理任何值。
推荐阅读
- java - Jsoup - 自定义元素避免格式化
- ruby - 我在使用 Parser gem 在 Ruby 中创建静态代码分析器时无法封装代码
- c# - EF Core 实体上 DDD 上的业务请求实现
- vue.js - [Vue 警告]:未知的自定义元素:
- 您是否正确注册了组件?对于递归组件, - excel - 如何粘贴来自不同工作簿的范围?
- c# - ASP NET 5 - 使用身份时忽略自定义身份验证方案处理程序
- ios - 使用 MAC 终端上传 .dsym 文件时出现问题
- python - Python 等高线图中的最大值
- firebase - 错误:hosting:channel:deploy 不是 Firebase 命令
- python - 将 PyInstaller 用于带有 Matplotlib 的脚本后出错