Issue converting decimals in SAP Odata call

1
Hi, I am using the standard OData action ‘create’ to perform a POST to the SAP system of a new object. The entity of the object is based on the autogenerated module based on the $metadata of the oData service.   We are currently getting errors in SAP while parsing the decimal values that are received from Mendix. In the console we can see the data that is sent. The decimal fields with value ‘0’ are sent as ‘0-E8’ instead of just ‘0’. "NetWeight": "0E-8"   It seems this same issue already existed 5 years ago in an odata-excel integration: https://community.mendix.com/#/questions/11540474045279135 Is there any way around this? How can we get the oData integration to work?
asked
2 answers
1

I was able to ‘solve’ it by adding an additional check in the sapodataconnector.utils.JsonSerializer

 

case "Decimal":
	if (value == null) {
		target.put(targetMemberName, "");
	} else if (value instanceof BigDecimal && ((BigDecimal) value).compareTo(BigDecimal.ZERO) == 0) {
		target.put(targetMemberName, "0");
	} else {
		target.put(targetMemberName, value.toString());
	}
	break;

 

This is however not the ideal way forward so it should be changed within the repo of the module

answered
0

This issue has not yet been resolved and seems a quite significant bug to me. It is very poorly developed that 0 values are automatically converted to “0E-8” in the OData output. 

Now we solve this in our application to have an after-commit event, with an if-then-else construction to convert 0 values into empty values.

Our application will have 500+ users and the OData connection we now use for reporting to transfer data to another Azure environment. The Azure transfer does not work with “0E-8” values in the database.

 

@Mendix development team: please try to fix this

answered