Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

rounding a currency field

rnb86
Participant
0 Kudos

Hi experts,

data: field1 type [currency field of size 15, decimals 2].

field1 = 25.87.

I want the value of field1 to be always rounded to 25.

Please suggest a way.

Pts will be rewaurded.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

USE LIKE THIS

data: field1 type currency field of size 15, decimals 2.

field1 = floor ( field1 )

Thanks & Regards,

Ramana

5 REPLIES 5

former_member386202
Active Contributor
0 Kudos

Hi,

Do like this

DATA pack TYPE p VALUE '12345678'.

WRITE pack NO-GROUPING ROUND 2 DECIMALS 4.

Regards,

Prashant

Former Member
0 Kudos

Hi,

Define the variable as Integer

Reward if usefull

Former Member
0 Kudos

Hi,

Use ceil( ) function.

Ex. a = ceil ( 398.98).

wreite:/ a.

or

Call 'ROUND' Method as below

DATA: WA_INPUT TYPE P DECIMALS 8,

WA_OUTPUT TYPE P DECIMALS 2.

WA_INPUT = '123.6581'.

*

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.

Hope it helps you.

ak_upadhyay
Contributor

Hi,

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.

Reward points if useful....

Regards

AK

Former Member
0 Kudos

Hi,

USE LIKE THIS

data: field1 type currency field of size 15, decimals 2.

field1 = floor ( field1 )

Thanks & Regards,

Ramana