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

decimal round off!!

former_member224405
Participant
0 Likes
985

Hi

i m trying to create an invoice by using the invoice Bapi_incoming_invoice

where i am trying to upload two files header,account and tax...

in my header file i m giving the gross_amt as 700 and i have three item in which i have individual items as 246.3256,243.5222,200.1522. which sums up to 699.9999 where ther

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
940

Hi,

Here is the code to round off

DATA: number TYPE decfloat34,

rounded TYPE decfloat34,

off TYPE i.

get_modes( ).

SKIP TO LINE 1.

LOOP AT modes INTO mode.

off = sy-tabix * 18 + 2.

WRITE AT off mode-name LEFT-JUSTIFIED.

ENDLOOP.

SKIP TO LINE 3.

DO 21 TIMES.

number = - ( sy-index - 11 ) / 10.

WRITE /(4) number.

LOOP AT modes INTO mode.

rounded = round( val = number dec = 0 mode = mode-value ).

off = sy-tabix * 18.

WRITE AT off(4) rounded.

ENDLOOP.

ENDDO.

Thanks

Sudheer

Hi

i m trying to create an invoice by using the invoice Bapi_incoming_invoice

where i am trying to upload two files header,account and tax...

in my header file i m giving the gross_amt as 700 and i have three item in which i have individual items as 246.3256,243.5222,200.1522. which sums up to 699.9999 where ther

5 REPLIES 5
Read only

Former Member
0 Likes
941

Hi,

Here is the code to round off

DATA: number TYPE decfloat34,

rounded TYPE decfloat34,

off TYPE i.

get_modes( ).

SKIP TO LINE 1.

LOOP AT modes INTO mode.

off = sy-tabix * 18 + 2.

WRITE AT off mode-name LEFT-JUSTIFIED.

ENDLOOP.

SKIP TO LINE 3.

DO 21 TIMES.

number = - ( sy-index - 11 ) / 10.

WRITE /(4) number.

LOOP AT modes INTO mode.

rounded = round( val = number dec = 0 mode = mode-value ).

off = sy-tabix * 18.

WRITE AT off(4) rounded.

ENDLOOP.

ENDDO.

Thanks

Sudheer

Read only

Former Member
0 Likes
940

Try this function module,may be it helps you....

HR_NZ_ROUNDING_DECIMALS - Round decimals places

Read only

Former Member
0 Likes
940

hi,

try this.

DATA: SAL_AMOUNT TYPE CHAR20.
DATA: L_DEC TYPE CHAR2.

SAL_AMOUNT = '699.9999'.

SPLIT SAL_AMOUNT AT '.' INTO SAL_AMOUNT L_DEC.
IF L_DEC+0(1) GE 5.
  SAL_AMOUNT = SAL_AMOUNT + 1.
ENDIF.
CONDENSE SAL_AMOUNT.

Read only

Former Member
0 Likes
940

Hi,

Move the amount into an integer before you are filling it in the header

data:
  w_i type i,
  w_p type p decimals 4 value '699.9999'.

move w_p to w_i.

write: w_i.

this will solve the problem

Thanks&Regards

Sarves

Read only

Former Member
0 Likes
940

Hi,

How about using Statements CEIL and FLOOR ?

For your scenario you need to use as;

Data : gross_amt TYPE P DECIMALS 3.
gross_amt = '699.9999'.
gross_amt = CEIL( gross_amt ).

This will solve your problem.

Regards

Karthik D