Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to round off decimal places?

Hi friends,

I am in a situation where i need to pass a currency field value Type P decimals 8 to

a variable of type c length 12.

As I have to write the output on application server.

Example

Value to be converted of Type P decimals 8 i.e. 5678.65800341

Value Required in Chararcter 12 with decimals 2 i.e. (9.2) total 12 characters. required value 5678.65 or 5678.66

Kindly help.

Will reward points to correct answers.

Thanks,

Pradeep.

Tags:
Former Member
Former Member replied

Hello,

Check this sample:

DATA: WA_INPUT TYPE P DECIMALS 8,

WA_OUTPUT TYPE P DECIMALS 2.

WA_INPUT = '5678.65800341'.

*

CALL FUNCTION 'ROUND'

EXPORTING

INPUT = WA_INPUT

IMPORTING

OUTPUT = WA_OUTPUT

EXCEPTIONS

INPUT_INVALID = 1

OVERFLOW = 2

TYPE_INVALID = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

WRITE: WA_OUTPUT.

Regards,

Vasanth

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question