Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

#1 - OData CRUD Crash Course - Getting ready with offline store

$
0
0

1.pngHi 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”.

1.png

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

2.png

3. You’ll see those folders generated.

3.png

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

4.png

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

5.png

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)

6.png

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”.

7.png

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.

8.png

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

9.png

10. Accept all the default values and save it.

10.png

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

12.png

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.png

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.png

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.png

15. You should be able to confirm green light

16.png

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

17.png

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

18.png

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.png

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

20.png

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

21.png

 

What's next? You can choose either of:

 

- Query operation

- Create operation

- Read operation

- Update operation

- Delete operation








Viewing all articles
Browse latest Browse all 2823

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>