ABAP 数学函数
ABS -Absolute value of the argument arg
SIGN - +/- sign of the argument arg:
-1, if the value of arg is negative;
0, if the value of arg is 0;
1, if the value of arg is positive.
CEIL - Smallest integer number that is not smaller than the value of the argument arg.
FLOOR - Largest integer number that is not larger than the value of the argument arg.
TRUNC - Value of the integer part of the argument arg
FRAC - Value of the decimal places of the argument arg
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
P = ABS( M ). " 3,5
I = P. " 4 - business rounding
I = M. " -4
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
I = TRUNC( P ). " 3 - integer part
I = TRUNC( M ). " -3
D = FRAC( P ). " 0.5 - decimal part
D = FRAC( M ). " -0.5
FM: ROUND 进行四舍五入
DATA: x TYPE p DECIMALS 4 VALUE '1.2345',
y TYPE p DECIMALS 2,
z TYPE p DECIMALS 3.
WRITE:/ 'Original: ', x.
z = x.
WRITE:/ 'Direct Assign:', z.
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 3
input = x
sign = '+' "sign = +/-/space.
IMPORTING
output = y.
WRITE:/ 'FM Round:', y.
WRITE 语句控制小数点位置, -n表示小数点向右移n位后再自动四舍五入.
DATA: X TYPE P DECIMALS 2 VALUE '12493.97'.
WRITE: /X ROUND -2, "output: 1,249,397.00
/X ROUND 0, "output: 12,493,97
/X ROUND 2, "output: 124.94
/X ROUND 5, "output: 0.12
ALV 货币输出, 指定参照货币,小数点位列以及 Round和Sign
NOTE: currency, decimal, round三个作用在同一个字段上时要注意运算顺序, 具体我现在也记不得了
lr_column ?= lr_columns->get_column( 'DMBTR').
lr_column->set_medium_text( 'Amt in Loc Curr'(448) ).
lr_column->set_long_text( 'Amount in Local Curr'(449) ).
lr_column->set_output_length( '13' ).
lr_column->set_currency_column( 'L_WAERS' ). "/set_currency( 'USD' )
lr_column->set_decimals_column( 'LOC_DEC' ). "/set_decimals( 2 )
lr_column->set_round( lv_round ).
lr_column->set_sign( abap_true ).
lr_column->set_zero( abap_false ).
QUAN DEC类型 与 P类型 转换
转换公式 (n+1)/2
比如QUAN DEC定义为13位,其中3位小数
则ABAP的对应P型应该定义为 (13+1)/2 = 7
data: p(7) type p decimals 3.
分享到:
相关推荐
ABAP流程处理的命令说明(stop,exit,return,check,reject)
ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。ABAP_OLE相关文档。...
ABAP资料ABAP资料ABAP资料ABAP资料ABAP资料
ABAP 调用ABAP PROXY
abap tips abap tips abap tips abap tips abap tips
SAP ABAP数字金额转中文大写源代码
abap 函数大全 abap function abap function
ABAP - Keyword Documentation This documentation describes the syntax and meaning of the keywords of the ABAP language and its object-oriented part ABAP Objects. Alongside this, language frameworks ...
abap逻辑数据库ABAP数据库操作,abap过程中的小积累。用处多多哦
ABAP_Excel_处理总结
ABAP流程处理命令祥解主要讲的是ABP中的数据类型和数据库的知识。
讲解了ABAP SQL Functions for Strings的使用
abap处理字符串[借鉴].pdf
ABAP 编程: ABAP ALV取消整数小数点后面的0
abap处理字符串[参考].pdf
SAP ABAP 开发手册,对SAP上ABAP开发有很大的帮助,希望对在SAP上开发者能够提供帮助
学习ABAP并不难,有人说SAP系统重在管理思想,不在技术,通常对有编程经验的读者不用任何培训参考一些相关资料就可立即上手. 简单介绍下ABAP/4的一些特征: 1.和SAP紧密结合,尤其在开发报表方面,坦率地讲,除了和SAP集成...
ABAP数据字典,适合初学者了解ABAP Dictionary中包含的对象,ABAP Dictionary是ABAP中极其重要的一部分,希望对您能有所帮助
资源名称:sap abap开发从入门到精通 内容简介: 《SAP ABAP开发从入门到精通》以应用实例的形式,讲解了SAPABAP开发的相关知识点,详细介绍了SAPABAP开发者必须掌握的包与变更传输系统(CTS)、数据类型、数据库...
abap学习资料 3月通学习资料abap学习资料 3月通学习资料