on 07-14-2014 3:24 PM
Hi everyone,
I am trying to create a new Function Import in SEGW transaction (Netweaver Gateway Builder).
I have followed different blogs (For example: and managed to create one.
However I am having 2 small differences:
1. I am trying to make a Http POST Function Import which is a bit different in the way you call the service.
2. I have a parameter with type Edm.Guid.
I have not found any documentation about these 2 specific things.
Here is what I have...
My function and it`s parameters in SEGW:
My metadata:
The URI I am trying with it`s payload:
/sap/opu/odata/sap/MY_SERVICE/AddTransferProducts
with
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:DocGUID>guid’12345678-aaaa-bbbb-cccc-ddddeeeeffff’</d:DocGUID>
<d:Products>R100000</d:Products>
</m:properties>
</atom:content>
</atom:entry>
With this setup I get the following error when I call the service: 404 not found
Anyone understands why it is not working ? Anyone already got this issue ?
Thank you very much.
Natalie
Ok, got it working.
It was back to POST http method... bad transport from me side.
So it is ok with GET Http method. I used URI /sap/opu/odata/sap/MY_SERVICE/AddTransferProducts?DocGUID=guid'12345678-aaaa-bbbb-cccc-ddddeeeeffff'&Products='R100000||R100002'
And I get to my breakpoint in the code. But I have to clear the metadata cache every time on both hub and backend!
Thanks for your support!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Natalie,
Function Imports in SAP Gateway does not support request body.
You need to mention parameters in the URI.
Example:
/sap/opu/odata/sap/MY_SERVICE/AddTransferProducts?Products='R100000'&DocGUID=guid’12345678-aaaa-bbbb-cccc-ddddeeeeffff’
For Docu
Find URI Conventions here. Search for 'Service Operations'
URI Conventions | Open Data Protocol
regards
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using GET, you are supposed to model non-modifying operations. (Reservation availability? material in stock? etc)
Using POST you are supposed to model modifying operations. POST requests can be safeguarded using CSRF token protection. (Approve requests, lock user etc.)
Though there is no explicit control and no one is stopping you from doing modifying operation in GET, it is against recommendation.
Metadata is showing GET method and the cache was cleared.
Here is a snippet of my code
CLASS xxxxx_DPC_EXT, method
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION
IF iv_action_name EQ 'AddTransferProducts'.
IF it_parameter IS NOT INITIAL.
* Read Function import parameters values
READ TABLE it_parameter
INTO ls_parameter
WITH KEY name = 'DocGUID'.
IF sy-subrc = 0.
lv_docguid = ls_parameter-value.
ENDIF.
READ TABLE it_parameter
INTO ls_parameter
WITH KEY name = 'Products'.
IF sy-subrc = 0.
lv_concat_products = ls_parameter-value.
ENDIF.
SPLIT lv_concat_products AT '||' INTO TABLE lt_products.
* Save products in the staging table and get product information
LOOP AT lt_products
ASSIGNING <lfs_products>.
ls_transfer_details-matnr = <lfs_products>-matnr.
APPEND ls_transfer_details TO lt_transfer_details.
ENDLOOP.
* Build the Document Details entity set to return
LOOP AT lt_transfer_details
ASSIGNING <lfs_transfer_details>.
MOVE-CORRESPONDING <lfs_transfer_details> TO ls_entity.
APPEND ls_entity TO lt_entityset.
ENDLOOP.
* Call method copy_data_to_ref and export entity set data
copy_data_to_ref( EXPORTING is_data = lt_entityset
CHANGING cr_data = er_data ).
ENDIF.
ENDIF.
Hello Natalie,
When you are using Custom Action/Function Import , you need to send the ACTION name ( note : not entity set name ) and parameters required for your action to work ( READ / CREATE / DELETE / UPDATE ).
The URI convention has already been nicely described by Chandra for function import.
example :
/sap/opu/odata/sap/MY_SERVICE/<Your Custom Action Name>?Products='R100000'&DocGUID=guid’12345678-aaaa-bbbb-cccc-ddddeeeeffff’
Same way you can implement Custom Action/Function Import your Create, Delete,Read & Update operation with corresponding HTTP methods.
Regards,
Ashwin
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.