SAP Gateway – OData implementation

Posted on Posted in ABAP, ABAP OO, Gateway

A little roadmap to create an OData service in SAP.

ODATA Examples for understanding:

https://viacep.com.br/

https://www.odata.org/
https://www.odata.org/odata-services/

If the version of the Netwearver is greater than 7.3, the component is already installed:

When the version is less than 7.4, you need to install these two components:

GW_CORE
IW_FND

Transactions separated by Front End and Back End systems:

Go to SEGW (in the Back End System), and create a new project:

Result:

Explanation:

Entity Type: Is the Structure, define the types, etc.
Entity Set: Is the “Internal Table”.

Creating the data Model, based on SAP Table.

Choose the fields:

Needed to define a key:

Proprieties: are like the FIELDS.


Every Service Implementation Entity Set will have its own Operations (Create, GetEntity, Update, Delete etc).

Generate:

Technical Service Name: Name which the external system needs to call.

Add Service to Service Catalog (Register the Service to Gateway Hub)

 


Font:http://www.sapyard.com/odata-and-sap-netweaver-gateway-part-ii-create-your-first-odata-service/

Go to your Gateway Hub (Front-end system) and execute t-code /n/IWFND/MAINT_SERVICE.

System Alias is the Back End System. Search for your External Service Name.

Click on it, and specify a package:

Go back:


Search your service in the list, and check if it is activate (green.), if not, activate it.

Ok. We can test it, still in the front end, click in “SAP Gateway Client” or enter in the transaction /IWFND/GW_CLIENT.

Execute:

Return OK.

Implementing the method POHEADERSET_GET_ENTITYSET to get return of Values.

Go to change mode in the DPC Extension class. Always edit the extension class, because we are enhancing the class.

Change like below, save and activate:

Now, we can test with the method:

Implementing the method to return a determine PO

same thing before, but now, redefine POHEADERSET_GET_ENTITY method, and change to code below.

 

  method POHEADERSET_GET_ENTITY.

DATA : ls_key_tab LIKE LINE OF it_key_tab,
lv_ebeln TYPE ekko-ebeln.

*     IT_KEY_TAB has key name and value
READ TABLE it_key_tab INTO ls_key_tab
WITH KEY name = ‘Ebeln’. ” Case sensitive

IF sy-subrc EQ 0.
lv_ebeln = ls_key_tab-value.
ENDIF.

*   Select one PO entry
SELECT SINGLE * FROM ekko INTO CORRESPONDING FIELDS OF er_entity
WHERE ebeln = lv_ebeln.

endmethod.

it is going to looks like this:

And in the GW client, we can search for one PO:

Total Views: 329 ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.