on 03-22-2016 7:21 PM
Hi,
I have a POST service and I am trying to send some some data to the webservice using JSON format. In my input, only the decimal fields are not getting passed to the service. The Edm type of those fields is Decimal (13,3).
My JSON input is as follows:
"Item":[{"Field1":"xxxxx", "Field2":"yyyy", "DecimalField1":"1.000", "DecimalField2":"2.000", "DecimalField3":"3.000"}]
Please tell me whether I need to change the format of the decimal fields in the input.
Anson,
In such cases, I would simply implement Read/Query (just hard code values in DPC_EXT) and see how property value appears in json response body.
Regards
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishna,
I have followed your instructions and I am able to get the desired output when I hard-coded the values in DPC_EXT. But the problem happens when I use the CREATE_DEEP_ENTITY method. Inside this method, the decimal field values present in the input JSON strucutre are not passed from the front end. I have an association defined in my service to connect the headerset and itemset and I am calling the service in below format.
/sap/opu/odata/sap/servicename/HeaderSet/
Whether the webservice call pattern have any issue ?
You can try using like below:
"Item":[{"Field1":"xxxxx", "Field2":"yyyy", "DecimalField1":"1.000", "DecimalField2":"2.000M", "DecimalField3":"3.000M"}]
Regards,
Vishal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anson,
As mentioned by Krishna it is always good practice to implement read in case of dilemma.
Coming on your question there is no need to change the format of input fields, it looks fine passing the values in this way.
One thing to be noted is if your precision is 13 and scale is 3, and you are passing values in below format, gateway framework will automatically change them according to scale.
Input Gateway
"2" "2.000"
"2.16" "2.160"
"2.1665" "2.167"
Overflow will happen if value is exceeding from 13 digit before decimal.
Try keeping breakpoints in create method and check where the values are truncated.
Regards,
Tarun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Anson,
The format which you are sending is correct.
In my service i have a similar property Price with Edm.Decimal where Precision is 13 & Scale is 2.
In payload i send it as below which works fine for me during POST operation.
{
....
"Price":"1.00",
.....
}
If at all you have defined a local structure in DPC_EXT class to read the payload, then check if the field names and their order is same as the one defined in MPC/MPC_EXT class.
If ABAP filed names differ then values come initial.
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.