SAP Netweaver Gateway Basics - Sap 4 All

Latest

Please enter your email and get the updates in your inbox.

Wednesday, 17 August 2016

SAP Netweaver Gateway Basics

SAP NetWeaver Gateway is a technology that provides a simple way to connect devices, environments and platforms to SAP software based on market standards. Completely flexible, SAP NetWeaver Gateway offers connectivity to SAP applications using any programming language or model without much need for SAP knowledge by leveraging REST services and OData/ATOM protocols.

Below are the generally used,

HTTP_METHODS:
GET        : Get Entityset or Entity
POST      : Create
PUT        : Update


DELETE   : Delete

Usual errors while testing the services:

400   Bad Request
1. When CSRF Token not added
2. Types of data sent are inconsistent

407   Method not allowed
1. URL/Request format and the selected HTTP Method are inconsistent.

500   Internal Server Error
1. If SQL Queries fail resulting in duplicate entries

These are the very common errors and will be updating the list going forward.

CSRF - Cross-Site Request Forgery: 
This is needed while sending create and update requests. Call the GET service to get the CSRF Token first and perform the create/update operation using the generated token.

*****************************************

Below are the methods implemented to get the service working for different purposes and explanation regarding the Method Parameters to be used while coding.

*_GET_ENTITYSET:


IV_ENTITY_NAME
Entity Name
IV_ENTITY_SET_NAME
Entity Set Name
IV_SOURCE_NAME
Entity Name
IT_FILTER_SELECT_OPTIONS
Values mentioned in FILTER Clause. But better to get it like given for IT_ORDER.
IS_PAGING
We do get TOP and SKIP values given in service URL and can be used to fetch data from database. This is for Paging of the data.
IT_KEY_TAB
This comes into picture when using Associations. Key value mentioned with Principal Entity.
IT_NAVIGATION_PATH
This comes into picture when using Associations
IT_ORDER
Fields mentioned for $orderby Clause. But better to get it fromIO_TECH_REQUEST_CONTEXT->GET_ORDERBY() method as this will give correct field mapping.
IV_FILTER_STRING
Gives the FILTER String given on URL by $filter
IV_SEARCH_STRING
Strings used with Clause search will be in this parameter
IO_TECH_REQUEST_CONTEXT
Mentioned Format, Request ID, orderby, User Name, Service Path, Filter Values (FILTER_SELECT_OPTIONS), GET_TOP, GET_SKIP and Navigation Path etc. will be available in this instance. Look for the methods in this interface.
ET_ENTITYSET
Fill this internal table to show the entries in output
ES_RESPONSE_CONTEXT
This is to fill HTTP Response Header parameters. Custom HTTP Header parameters can be set using below procedure. This can be used, when some kind of extra  message to be passed to the UI when the response is a success.

DATA:ls_header TYPE ihttpnvp.
ls_header
-name 'my-custom-message'.
ls_header
-value '{msg_typ:S, desc: Data Retrieved}'.
/iwbep/if_mgw_conv_srv_runtime
~set_headerls_header ).



*_GET_ENTITY:

IV_ENTITY_NAME
Entity Name
IV_ENTITY_SET_NAME
Entity Set Name
IV_SOURCE_NAME
Entity Name
IT_KEY_TAB
Red colored value will be captured into this table. Let’s say key fields declared at Gateway Level.
If the request url is the below,
/sap/opu/odata/sap/ZMA_EMPS_SRV/Emp_DataSet('00000001')

IO_TECH_REQUEST_CONTEXT
Mentioned Format, Request ID, orderby, User Name, Service Path, Filter Values (FILTER_SELECT_OPTIONS), GET_TOP, GET_SKIP and Navigation Path etc. will be available in this instance. Look for the methods in this interface.
IT_NAVIGATION_PATH               
This comes into picture when using Associations
ER_ENTITY
Output data will be populated into this
ES_RESPONSE_CONTEXT
This is to fill HTTP Response Header parameters. Custom HTTP Header parameters can be set using below procedure.

DATA:ls_header TYPE ihttpnvp.
ls_header
-name 'my-custom-message'.
ls_header
-value '{msg_typ:S, desc: Data Retrieved}'.
/iwbep/if_mgw_conv_srv_runtime
~set_headerls_header ).


*_CREATE_ENTITY:


IV_ENTITY_NAME
Entity Name
IV_ENTITY_SET_NAME
Entity Set Name
IV_SOURCE_NAME
Entity Name
IT_KEY_TAB
As Described Above
IO_TECH_REQUEST_CONTEXT
HTTP Method, Format of data, Operation etcAs Described Above

IT_NAVIGATION_PATH
As Described Above
IO_DATA_PROVIDER
Get the input data by the request can be retrieved using method READ_ENTRY_DATA.IO_DATA_PROVIDER-> READ_ENTRY_DATA( ).
ER_ENTITY
Fill this structure to show up the created entry in the Output Response.

*_UPDATE_ENTITY:

Same as *_CREATE_ENTITY

*_DELETE_ENTITY:

All Parameters                                  - As described above

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY



Build final table with exact deep structure ER_DEEP_ENTITY has. 

IO_EXPAND
IO_EXPAND-> MT_CHILDREN will contain below. Navigation property name should be appended toET_EXPANDED_TECH_CLAUSES


ER_ENTITY
This will be a Deep Structure to hold header as well as Item data.
ET_EXPANDED_CLAUSES
Obsolete. Below is the replacement.
ET_EXPANDED_TECH_CLAUSES
Navigation property name should be appended toET_EXPANDED_TECH_CLAUSES(This will be the name of child entityset). If this is not done, Method will be triggered number of times(as per number of records) though the data is filled in the first iteration.

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET:


All the parameters have been covered above.

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY:


All the parameters have been covered above.

Build final table with exact deep structure ER_DEEP_ENTITY has. 

Make sure the deep internal table named after child entityset. If not item data will not be populated.

CREATE _ENTITY and CREATE_DEEP_ENTITY will be called based on the input request given. If the request contains deep body then CREATE_DEEP_ENTITY will be called.

2 comments:

  1. Thanks for sharing this Information,

    Got to learn new things from your Blog on Sap abap.

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    Both online and classroom training is provided.

    Contact 8122241286

    ReplyDelete
  2. Thanks for sharing this Informative content. Well explained. Got to learn new things from your Blog sap-pp training

    ReplyDelete