
In the previous blog post, we have demonstrated how to execute complex OData queries against a mobile destination of SAP Mobile Services using Mobile Backend Tools in a Visual Studio Code Environment. As a mobile developer, one of the major responsibilities of coding the mobile app is to code the OData access using programming languages like swift, kotlin and Java, etc. In this blog post, we will demonstrate how to generate OData client code directly from OData queries.
In SAP Mobile Backend Tools, open the mobile destination metadata document using OData CSDL Modeler, and then click the "Generate Test Client" toolbar button like below:
Choose a directory to hold the test client:
Click "Generate" button in the dialog, Mobile Backend Tools will generate the test client for this OData services:
After the generation has been complete, click "Open" button to open the test client in the specified directory:
You can open a test client called "PurchaseOrderFindByQuery" like below, you will be able to see the generate client code:
Inside Mobile Backend Tools environment, you can directly execute the test client. You can do that by clicking the "Execute" button:
And you will see the response from the backend system in the console after execution of the test client is complete:
You can also create a test client by supplying an OData query. In order to do that, click the "Add" button in the top right corner:
For example In the popup dialog, we can use below OData query as the input.
"PurchaseOrder?$filter=CreatedByUser eq 'CB9980000026' and PurchasingOrganization eq '1710' and Supplier eq '17300001' and PricingDocument eq '1000000340'&$expand=_PurchaseOrderItem($expand=_DeliveryAddress,_PurchaseOrderInvoicingPlan,_PurchaseOrderItemNote),_PurchaseOrderNote".
In case you want to generate mobile client code for the above OData query, copy the OData URL and paste it to the Visual Studio information window:
Press enter key to accept the test case name, Mobile Backend Tools will generate the test client for this OData query in swift, kotlin and Java:
Click the "Execute" button to execute the test case, and you will be able to see the response from the backend system:
In summary, as a mobile developer, if you need to code a mobile app that needs to access the backend system through SAP Mobile Services using OData queries, you can generate the client code directly using SAP Mobile Services Mobile Backend Tools as well as OData CSDL Tools and test the generated code directly in the Visual Studio Code environment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
6 | |
6 | |
6 |