1. The import script below (which is intended to round amounts to 0 decimal places) is being used in an import format for a file based load and is not correctly rounding amounts with more than 12 digits before the decimal place:
2. To give a specific example, if you had the amount 2416602525799.16 in your source file and it was processed by the import script above it would be rounded to 2416602525800 rather than to 2416602525799 as would be expected if you are seeing this issue.
3. The same figures can be rounded without any problems at all when trying the same process in an interactive Jython session (which can often be a useful debugging tool with simple Jython scripts). You can start an interactive Jython session to try this by running:
java -jar C:\Oracle\Middleware\odi\oracledi.sdk\lib\jython.jar
Then create the same function contained in your import script before calling it with a test value:
>>> def rounding(strField,strRecord):
… return strField
>>> rounding(2416602525799.16, ‘randomStuff’)
this is due to Precision is being lost when converting the Jython float data type into a Java data type before inserting into the TDATASEG table.
to fix this –
1. Create an import script named rounding as below (please note that the function name must be the same as the script name) which uses the Java BigDecimal data type:
import java.math.BigDecimal as BigDecimal
strField = BigDecimal(strField).setScale(0,BigDecimal.ROUND_HALF_UP)
2. Update the file based import format to use this script on the amount column where the rounding is being done.