Rounding and decimal Truncation

Source: Internet
Author: User

Original post address: http://blog.chinaunix.net/u1/40527/showart.php? Id = 336723

 

As we all know, SAP data is basically rounded up, but sometimes it is necessary not to rounding up or directly truncation. What should I do? Report z_barry_test_round. Data: PP1 type P decimals 3,
PP2 type P decimals 2,
PP3 type P decimals 2,
II1 type I.
PP1 = '1970. 100 '.
PP3 = PP1.
II1 = 2.
Perform noround using PP1 II1
Changing PP2.
Write: PP2, pp3 .*&--------------------------------------------------------------------*
* & Form noround
*&--------------------------------------------------------------------*
Form noround using P1 I1
Changing P2.
Data: tmpn1 (20) type N,
Tmpn2 (20) type N,
Tmpc1 (20) type C.
Tmpc1 = P1.
Split tmpc1 at '.' into tmpn1 tmpn2.
Concatenate tmpn1 '. 'tmpn2 + 0 (I1) into tmpc1.
P2 = tmpc1.
Endform. "noround or: Report
Z_barry_test.

Data
: P1 type
P Decimals
4
.

P1 = '3. 456'
.

Call
Function
'Round'

Exporting

Decimals
= 2

Input
= P1
Sign
= '-'

Importing

Output
= P1
Exceptions

Input_invalid = 1

Overflow = 2

Type_invalid = 3

Others
= 4
.

Write
P1. sign:

Space
: No rounding (input = output)
'+' : Round Up
'-' : Round down
'X' : Commercial rounding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.