I believe that many friends have seen these three similar HTTP request types when using SAP ABAP Gateway Client to test OData services: PUT, MERGE and PATCH.
What is the difference between these three types?
- PUT: Take the HTTP request (payload) as input, which will be passed to the UPDATE_ENTITY method of the DPC Class of the OData model.
For example, we pass in the following data through PUT:
{ “Vbkur” : “170” }
Then only Vbkur is visible in the update_entity method. In summary, if the OData model 属性子集(attribute subset)
is used as input to the PUT method, the same subset of attributes will be passed into the UPDATE_ENTITY method for processing.
- PATCH & MERGE: If a subset of attributes is passed in the payload (HTTP request), these two methods automatically fetch other attributes. Patch and Merge behave the same way, but the basic difference is that PATCH supports the OData 3.0 protocol, while MERGE supports the OData 1.0 and 2.0 protocols. So we should use PATCH in preference to MERGE.
As an example, the following is a collection of header attribute fields for an order:
{
"Vbeln" : "32346",
"Erdat" : "\/Date(1627171200000)\/",
"Erzet" : "PT19H29M37S",
"Ernam" : "FIORIUSER",
"Audat" : "\/Date(1627171200000)\/",
"Netwr" : "193.050",
"Waerk" : "USD",
"Vkorg" : "1710",
"Vtweg" : "10",
"Vkbur" : "180"
}
When we use the PATCH operation, we just pass a property to be modified:
But within the UPDATE_ENTITY method of the DPC, all fields of the order header are accessible:
Whenever the SAP ABAP OData framework triggers a PATCH or MERGE call, it will first trigger the corresponding GET_ENTITY(collect all properties) method and then execute the UPDATE_ENTITY method.
NOTE: Since MERGE is not one of the verbs defined in the HTTP specification [RFC2616], using the MERGE verb may not traverse the network as seamlessly as the method defined in the HTTP specification. The HTTP PATCH verb takes precedence over HTTP MERGE when dealing with data services that support the OData 3.0 protocol. Data services that support the OData 2.0 and OData 3.0 protocols can support verb tunneling to alleviate this limitation.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。