Issue converting decimals in SAP Odata call

0
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://forum.mendix.com/#/questions/11540474045279135 Is there any way around this? How can we get the oData integration to work?
asked
1 answers
0

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