It is sometimes required to delete an existing Document in SAP from backend based upon http request from SAP Netweaver Gateway and return success or failure message.
DELETE operation in SAP Netweaver Gateway doesn’t have provision to return message in body unlike READ.
Therefore the success or failure message after deletion will be returned through header of HTTP response of the URL.
Go to Tcode: SEGW and execute the following steps,
Create Entity Z_XYZ importing RFC ZFMDEMO developed in ECC to delete document from SAP Backend.
Enable DELETE operation in Service Implementation part for Entity Set Z_XYZSET using parameters of RFC ZFMDEMO
Generate the Service with runtime artifacts and Redefine the Delete_Entity method as,
Add the below custom code in the above method to return messages in the header of http response invoked by DELETE operation,
Test the Service,
Execute the URI in gateway client as,
The highlighted box in the above figure shows a new entry with name ‘message‘ into the response header and the corresponding message content is displayed.