Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
Today I got a question from a developer whether it is possible to create a function import with the following functionality:
















 Return Type Kind  Entity Type
 Return Cardinality  1..n
 HTTP method Type  POST


As the KBA article 2597368 states this is not supported but there is a workaround.

The idea was to confirm several sales orders using only one http call. The function import should return the list of affected sales orders and the resulting status.

But when you create a function import ConfirmSalesOrderES using the above settings you will get a HTTP response with the status code 405 that contains the following the error message:
<message xml:lang="en">The specified HTTP method is not allowed for the resource identified by the Data Service Request URI</message>

Since the error message is raised by the SAP Gateway framework it is hard to find the root cause for this error message via debugging.

A workaround for this specific use case was to create a function import ConfirmSalesOrderCO that uses a complex type as the return type which allows a to use a return cardinality 1..n when using the http method type POST.



The corresponding Service Builder Project looks as follows.



Here an excerpt from the $metadata document.
<FunctionImport Name="ConfirmSalesOrderES" sap:action-for="ZTEST_FI_SRV.SalesOrder" m:HttpMethod="POST" EntitySet="SalesOrderSet" ReturnType="Collection(ZTEST_FI_SRV.SalesOrder)">
<Parameter Name="SoId" MaxLength="10" Type="Edm.String" Mode="In"/>
</FunctionImport>

<FunctionImport Name="ConfirmSalesOrderCO" sap:action-for="ZTEST_FI_SRV.SalesOrder" m:HttpMethod="POST" ReturnType="Collection(ZTEST_FI_SRV.ConfirmedSalesOrders)">
<Parameter Name="SoId" MaxLength="10" Type="Edm.String" Mode="In"/>
</FunctionImport>

Best Regards,

Andre

 
3 Comments