为什么变量没有采用所需的值
Why are the variables are not taking the desired values
我必须检查一个数字中有多少百,并将该数字转换为字母。例如数字 700。我已经完成了以下代码:
DATA(lv_dmbtr) = ZDS_FG-DMBTR. //Declared local variable of type DMBTR, thus DMBTR=700.
lv_dmbtr = ZDS_FG-DMBTR MOD 100. //Finding how many times 700 is in 100 via MOD and putting the value in lv_dmbtr.
IF lv_dmbtr LE 9. //The value is less or equal than 9(if larger means that the DMBTR is larger than hundreds,
e.g. 8000)
lv_hundred = lv_dmbtr / 100. // Divide the 700 with 100, taking the number 7.
lv_hundred_check = lv_hundred MOD 1. // Then taking the value of 7 into the new variable, done in case the
lv_hundred is a decimal value, e.g. 7.32.
IF lv_hundred_check > 0.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = lv_hundred_check
* CURRENCY = ' '
* FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
in_words = lv_hundred_string // the value is put in the new string
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
ENDIF.
现在当我调试代码时,所有变量的值为 0。因此,lv_dmbtr, lv_hundred, lv_hundred_check
都具有值 0。
有谁知道问题出在哪里吗?
提前致谢!
很抱歉在代码中写了很多,只是想尽可能多地澄清我所做的事情。
yes so I want to display the value of a specific number 700-> seven, 1400-> four.
因此,计算百位的基本公式如下:通过整数除法计算 100
完全适合您的数字的次数。
99 / 100 = 0
700 / 100 = 7
701 / 100 = 7
1400 / 100 = 14
1401 / 100 = 14
现在您可以简单地使用这个数字 MOD 10
来获得个人的数百个。
0 MOD 10 = 0
7 MOD 10 = 7
14 MOD 10 = 4
请记住,与许多其他编程语言相比,ABAP 会自动舍入。所以在代码中这将是:
CONSTANTS lc_hundred TYPE f VALUE '100.0'.
DATA(lv_number) = 1403.
DATA(lv_hundred_count) = CONV i( floor( ( abs( lv_number ) / lc_hundred ) ) MOD 10 ).
我必须检查一个数字中有多少百,并将该数字转换为字母。例如数字 700。我已经完成了以下代码:
DATA(lv_dmbtr) = ZDS_FG-DMBTR. //Declared local variable of type DMBTR, thus DMBTR=700.
lv_dmbtr = ZDS_FG-DMBTR MOD 100. //Finding how many times 700 is in 100 via MOD and putting the value in lv_dmbtr.
IF lv_dmbtr LE 9. //The value is less or equal than 9(if larger means that the DMBTR is larger than hundreds,
e.g. 8000)
lv_hundred = lv_dmbtr / 100. // Divide the 700 with 100, taking the number 7.
lv_hundred_check = lv_hundred MOD 1. // Then taking the value of 7 into the new variable, done in case the
lv_hundred is a decimal value, e.g. 7.32.
IF lv_hundred_check > 0.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = lv_hundred_check
* CURRENCY = ' '
* FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
in_words = lv_hundred_string // the value is put in the new string
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
ENDIF.
现在当我调试代码时,所有变量的值为 0。因此,lv_dmbtr, lv_hundred, lv_hundred_check
都具有值 0。
有谁知道问题出在哪里吗?
提前致谢!
很抱歉在代码中写了很多,只是想尽可能多地澄清我所做的事情。
yes so I want to display the value of a specific number 700-> seven, 1400-> four.
因此,计算百位的基本公式如下:通过整数除法计算 100
完全适合您的数字的次数。
99 / 100 = 0
700 / 100 = 7
701 / 100 = 7
1400 / 100 = 14
1401 / 100 = 14
现在您可以简单地使用这个数字 MOD 10
来获得个人的数百个。
0 MOD 10 = 0
7 MOD 10 = 7
14 MOD 10 = 4
请记住,与许多其他编程语言相比,ABAP 会自动舍入。所以在代码中这将是:
CONSTANTS lc_hundred TYPE f VALUE '100.0'.
DATA(lv_number) = 1403.
DATA(lv_hundred_count) = CONV i( floor( ( abs( lv_number ) / lc_hundred ) ) MOD 10 ).