Application Development and Automation 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: 
Read only

round the decimal value

Former Member
0 Likes
1,287

Hi,

i am using the decimal value with data type and length is : dec 6,

i want to round this value, if .5 above then add +1 integer

i check the ROUND keyword and function module also it is showing the same input value as output

can any one give me suggestion

Hi,

i am using the decimal value with data type and length is : dec 6,

i want to round this value, if .5 above then add +1 integer

i check the ROUND keyword and function module also it is showing the same input value as output

can any one give me suggestion

8 REPLIES 8
Read only

Former Member
0 Likes
1,171

Hi,

Use the FM  J_1I6_ROUND_TO_NEAREST_AMT

Pass the value to Amount field.

Regards

Ram

Read only

0 Likes
1,171

my field is decimal value, can i use this FM, i hope this is related to amount field 

Read only

0 Likes
1,171

Any How u want if ur value is .5 it had to become 1...

So declare a variable of type J_1ITAXVAR-J_1ITAXAM1

And pass the Value to this Variable..

and pass this variable to the FM... thats it.

Regards

Ram

Read only

Former Member
0 Likes
1,171

Hi,

You can use round function itself.

Dont test it at SE37.

Your variable should be of data type F , P or I even dec is accepted.

Test the below sample code

DATA: test TYPE p VALUE '0.5'.

CALL FUNCTION 'ROUND'
  EXPORTING
    decimals      = 0
    input         = test
    sign          = '-'
  IMPORTING
    output        = test
  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:/ test.

If my understanding was wrong. Please clarify.

Regards,

Akhil

Read only

0 Likes
1,171

Hi ,

is there any data type only for numaric values, it wont allow the character values ex : mobile number , here it must accept only digits but not characters

for this i use numc data type but when i gave numbers it is showing error

can u plz suggest me is there any data type for that

Read only

0 Likes
1,171

Hi ,

is there any data type only for numaric values, it wont allow the character values ex : mobile number , here it must accept only digits but not characters

for this i use numc data type but when i gave numbers it is showing error

can u plz suggest me is there any data type for that

Read only

0 Likes
1,171

Hi,

Yes the input values can only be of the type floating point , packed or integer.

It wont work for other types like character.

You can use packed number (P).

This will work for your requirement i guess.

Regards,

Akhil

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,171

Have a look into statements like FRAC, CEIL, FLOOR. It can be done with these functions.