ABAP [div '/'] 的区别与妙用
div: 除了之后取整數, 需要注意的事,如果結果是負數,那么結果會有一個看起來是四舍五入的結果
/:除了之后保留小數部分
話不多說,舉例如下:
DATA:
??? A TYPE HSLXX12 VALUE '10272112273',
??? B TYPE HSLXX12 VALUE '-10272112273',
???C TYPE HSLXX12 VALUE '2667',
??? D TYPE HSLXX12 VALUE '-2667',
??? DIVA1 TYPE HSLXX12,
??? DIVA2 TYPE HSLXX12,
??? DIVB1 TYPE HSLXX12,
??? DIVB2 TYPE HSLXX12,
??? DIVC1 TYPE HSLXX12,
??? DIVC2 TYPE HSLXX12,
??? DIVD1 TYPE HSLXX12,
??? DIVD2 TYPE HSLXX12.
??? DIVA1 = A DIV 1000.
??? DIVA2 = A / 1000.
??? DIVB1 = B DIV 1000.
??? DIVB2 = B / 1000.
??? DIVC1 = C DIV 1000.
??? DIVC2 = C / 1000.
??? DIVD1 = D DIV 1000.
??? DIVD2 = D / 1000.
???WRITE: / A, 'DIV 1000 = ', DIVA1.
???WRITE: / A, '/ 1000 = ', DIVA2.
???WRITE: / B, 'DIV 1000 = ', DIVB1.
???WRITE: / B, '/ 1000 = ', DIVB2.
???WRITE: / C, 'DIV 1000 = ', DIVC1.
???WRITE: / C, '/ 1000 = ', DIVC2.
???WRITE: / D, 'DIV 1000 = ', DIVD1.
???WRITE: / D, '/ 1000 = ', DIVD2.
結果如下:
10,272,112,273.00?? DIV 1000?????? =?????? 10,272,112.00
10,272,112,273.00??? / 1000?????????? =?????? 10,272,112.27
10,272,112,273.00-?? DIV 1000????? =?????? 10,272,113.00-
10,272,112,273.00-??? / 1000???????? =?????? 10,272,112.27-
??????????????????? 2,667.00?? DIV 1000????? =??????? 2.00
??????????????????? 2,667.00??? / 1000????????? =??????? 2.67
?????????????????? 2,667.00-?? DIV 1000???? =??????? 3.00-
?????????????????? 2,667.00-??? / 1000??????? =??????? 2.67-
從上面的結果,大家注意紅色的部分。估計就了解了吧。不說了!
總結
以上是生活随笔為你收集整理的ABAP [div '/'] 的区别与妙用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SAP_常用业务数据表设计
- 下一篇: abap 中的语法 div / mod