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

Values to be passed for Function ROUND.....

Former Member
0 Likes
492

Hi freinds,plz tell me what are the values to be pass to the function round. suppose i want to round off 56.4456 to only 2 decimals, what value should i pass in,DECIMALS,INPUT,SIGN.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
393

hi,

no need fro any FM.

check this sample code.

data: a(16) type p decimals 4 .

data: b(16) type p decimals 2 .

data: c(30) .


a = '56.4456'.
write:/ a .

move: a to b .

write:/ b .

write a to c decimals 2 .

write:/ c .

the results will be

a = 56.4456
b = 56.44
c = 56.44

you can see automatic rounding of happenning as well

Regards

Anver

2 REPLIES 2
Read only

Former Member
0 Likes
393

execute the code .

u need to work this out like this.

tricky part is if u want to see this in the fm input will be character of 200 length .

so u will get an error as the fm will take data types P or F or I and not char .

DATA:
   L_MENGE_P5(16) TYPE P DECIMALS 5,
   L_MENGE_P3(16) TYPE P DECIMALS 3,
   L_ANDEC     like T006-ANDEC value 2.


  L_MENGE_P5 = '56.4456'.

  CALL FUNCTION 'ROUND'
    EXPORTING
     DECIMALS            = L_ANDEC
      input              = L_MENGE_P5     "over here u need to pass other than char
     SIGN                = '+'
   IMPORTING
     OUTPUT              = L_MENGE_P3
   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:/ L_MENGE_P3.

hope this helps ,

regards,

vijay

Read only

anversha_s
Active Contributor
0 Likes
394

hi,

no need fro any FM.

check this sample code.

data: a(16) type p decimals 4 .

data: b(16) type p decimals 2 .

data: c(30) .


a = '56.4456'.
write:/ a .

move: a to b .

write:/ b .

write a to c decimals 2 .

write:/ c .

the results will be

a = 56.4456
b = 56.44
c = 56.44

you can see automatic rounding of happenning as well

Regards

Anver