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.
Showing results for 
Search instead for 
Did you mean: 

Hi everyone,

Thanks for tuning in this H2G.

The idea of this "Crash Course" is making preparation steps for the subsequent H2G series about the best practice OData implementation for the Offline store with SAP Gateway. You don't have to be an ABAP expert - this content is intended for novice ABAP programmers - it should be easy to follow, if you have general understanding & experience in other programming languages.

We'll build basic OData CRUD services with well-known TravelAgency database table in ABAP system. The OData services will be extended in other H2Gs so that you will be able to gain understanding and experience to build the best designed services for Offline store.

It is easy and - fun 🙂

Applicable Releases

SAP Mobile Platform 3.0 SP5+

SAP HANA Cloud Platform Mobile Services (HCPms)

SAP Gateway SP4+

Step-by-Step Procedure

- Creating a project in Gateway Service Builder

1. Let’s create the project file. Open SAP transaction SEGW. You’ll navigate to SAP Gateway Service Builder. Click on the icon for “Create Project”.

2. Name your project (this example is “Z_TravelAgency”) and save it.

3. You’ll see those folders generated.

4. Right click on “Data Model” and select Import > DDIC Structure.

5. We’ll generate an entity with “stravelag” structure. Name it “TravelAgency” and enter the ABAP Structure name.

6. Next screen you’ll choose which columns in the structure you want to generate as OData properties. Select all except MANDT field (In this case, it doesn't really matter if you keep it or not)

7. And the next screen let you choose the “Key”. These keys will be used to read/update/delete entity. In this example we just select “AGENCYNUM”.

8. Now that you’ll confirm those “TravelAgency”, “TravelAgencySet”, and CRUD + Query Implementation are generated – Note that these are still empty. We’ll implement them later steps.

9. Right click on the project name and choose “Generate Runtime”. This will generate actual OData runtime service code.

10. Accept all the default values and save it.

11. After you have done the step above, you’ll confirm the “Method Name” fields are filled out – the template methods are generated.

12. Find the folder node “Service Maintenance”. In order to run the current OData service we just have generated, we need to configure here. Click it and you’ll see the config pane on the right.

13. (This might not the same with your screen – this depends on how your Gateway system are deployed) In this screenshot, click on “GW_HUB” and click “Register” button.

14. You’ll see a popup asking you the alias name.  (Ex. – “LOCAL” - but the value should vary in your system) Once you enter the correct alias name, you’ll see this popup and select your Package Assignment ($tmp).

15. You should be able to confirm green light

16. If you see the green light, press “Gateway Client” button.

17. You’ll see the REST client starts. Just click “Execute” and the response should come back.

18. In the response payload, you’ll confirm the generated Collection name “TravelAgencySet” and entity name “TravelAgency”. These are all generated out of the ABAP structure.

19. Now let’s experiment. Add the “TravelAgencySet” in the URL and see what happens.

20. Yes – as expected, you’ll see the error message. The Query is not yet implemented. We’ll do it in the other chapter.

What's next? You can choose either of:

- Query operation

- Create operation

- Read operation

- Update operation

- Delete operation

List of H2Gs