首页 > 解决方案 > 运行时生成程序转储 ID 期间发生内部错误:BCD_OVERFLOW

问题描述

程序运行时生成期间发生内部错误(转储 ID:BCD_OVERFLOW)

检查期间没有错误,但激活会出现此错误。

标签: abap

解决方案


如果您尝试将值分配给“超出范围”的数值属性或变量(因此会导致溢出),则会在任何 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可能是更大的数字数据类型,它几乎可以处理任何值。


推荐阅读