cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to round up to 6 decimal values

nikhyre
Discoverer
0 Kudos
335

Hi,

I am looking for a way to round up currently by default is 7 decimal to 6 decimal.

Currently using below code but not successful as i am using ABAP calculation engine instead of JAVA calculation engine.

*XDIM_MEMBERSET CATEGORY = ACTUAL_DEC_YE

*XDIM_MEMBERSET R_ENTITY = GLOBAL

*XDIM_MEMBERSET MEASURES = PERIODIC

*XDIM_MEMBERSET R_ACCT = HYTD

*XDIM_MEMBERSET TIME = 2021.JAN

*WHEN R_ACCT

*IS "HYTD"

*REC(EXPRESSION=(1*(%VALUE%).toFixed(6)))

//*REC(EXPRESSION=Math.round(%VALUE%*100)/100) -> not possible due to ABAP calculation engine.

*ENDWHEN

*COMMIT

I got error produce by the LOG as below. Not sure what else should i do.

#dim_memberset=5

CATEGORY:ACTUAL_DEC_YE,1 in total.

R_ENTITY:GLOBAL,1 in total.

MEASURES:PERIODIC,1 in total.

R_ACCT:HYTD,1 in total.

TIME:2021.JAN,1 in total.

REC :(1*(%VALUE%).toFixed(6))

------------ ABAP Code Generation Error:4 -------------

MESSAGEGZGIncomplete arithmetic expression: ")" missing at end of statement.

Line12 WordCOMPUTE

-------- Code ---------

program.

class main definition.

public section. methods

METH1 importing

P1 type decfloat34

exporting RET type decfloat34

raising CX_SY_ZERODIVIDE.

endclass.

class main implementation.
method METH1.

"(1*(%VALUE%).toFixed(6))

RET = ( 1 * ( P1 ) .toFixed ( 6 ) ).

endmethod.

endclass.

-------- Input formulas ---------

(1*(%VALUE%).toFixed(6))

------------ ABAP Code Generation Error Ends ------------

UJK_VALIDATION_EXCEPTION:Incomplete arithmetic expression: ")" missing at end of statement.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

nikhyre
Discoverer
0 Kudos

Hi Vadim,

Currently the BADI is rounding to 0 decimal. Was looking at any other alternative via script.

former_member186338
Active Contributor
0 Kudos

Sorry, but badi will round to whatever you need. Just use correct code (for specific model, for specific members...).

There is no way to perform rounding in the script when you are using ABAP calculation engine.

former_member186338
Active Contributor
0 Kudos

If you are using ABAP calculation engine, then use write back badi and perform rounding in this badi.