4

April (Citizen) Developer Challenge – SAP Build Ap... - SAP Community

 2 weeks ago
source link: https://community.sap.com/t5/sap-builders-discussions/april-citizen-developer-challenge-sap-build-apps-task-1-s-4hana-odata/td-p/13657249
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

April (Citizen) Developer Challenge – SAP Build Apps: Task 1 - S/4HANA OData

Dan_Wroblewski

Developer Advocate

2 weeks ago

- last edited

Wednesday

Always good to brush up on your OData access … I mean, we’re at SAP.

We started the challenge earlier this week with a preliminary task so you can have your SAP Build Apps set up. Now we'll start one challenge a week, on Wednesdays – today's about working with S/4HANA Cloud OData services.

The challenges so far:

2023-12-24_18-40-33.png

Getting data from SAP backends is one of the key capabilities of SAP Build Apps, and one of the things you’ll want to make sure is second nature for you. To get SAP backend data into your app, you’ll need to know a few things.

  • SAP Accelerator Hub: A set of demo SAP services – e.g., S/4HANA, SuccessFactors, Ariba – you can use for building your apps. 
  • Destinations: To access APIs, SAP BTP lets you define connections to backend data in the form of destinations – basically, a set of parameters including URL / authentication info.
  • Data Resources: This is an SAP Build Apps object that defines which data – e.g., which service, entity, filtering – we want for our app.
  • Data Variables: This is an SAP Build Apps object that actually makes the backend call and sets aside space for the retrieved data.

Within the data variable there is a way to filter, sort, and paginate the data that you retrieve from the backend. For more on these tasks, you can see this blog

Dan_Wroblewski_0-1712138849513.png

In this challenge, you will get demo sales order data, filter/sort/paginate the data, and display the data in your app.

👉Your Task

To do this task, you'll need an SAP Build Apps system and to import our skeleton app. To do all this, make sure you've done Task 0.

Part I

  • Create a destination to the Sales Order v4 OData service on the SAP Business Accelerator Hub. You will have to create an account on the SAP Business Accelerator Hub, and have access to an API key (free). To do all this, there is a 2-minute video:
Dan_Wroblewski_1-1712138849516.jpg

IMPORTANT: When you create your destination, the URL should be:

https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/API_SALES_ORDER_SRV

YOU'LL LIKE THIS: We have given you a file you can import to create the destination in a few seconds. You just have to add your API key.

Dan_Wroblewski_2-1712138849528.png
  • In your app project from the last challenge, make a data resource to this destination, and enable the A_SalesOrderItem entity.
  • Open the S/4HANA Sales Orders page in the app we gave you, and create a data variable based on the data resource you created.

    IMPORTANT: In the data variable, you MUST implement sorting/filtering/paging  as follows:

    • Only return records where IncoTermsLocation1 = Palo Alto.
    • Sort by the net amount, showing the largest amounts first.
    • Show only the first 10 records.
  • Now make the UI by dragging a List Item control onto the canvas, and show the following 2 fields:
    • SalesOrderItemText
    • Net Amount

To make it look nice, I changed the width and height for the list item component, using the Custom setting and setting the width to 90%. I also changed the shape. You can adjust the UI as you like.

Dan_Wroblewski_3-1712138849530.png
  • Run the app in the SAP Build Apps preview app or web preview, and navigate to the S/4HANA Sales Orders (use the custom menu at the bottom of the home page).

Take a screenshot, something like this (your values will differ and MUST reflect the filtering above).

20240327_043537463_iOS.png
 

Take note of the amount for the 10th entry – this is the value you must hash (remember, your values will be different than the one's above). The value should be with 2 decimal places, no commas and no currency sign, something like this: 123.99. 

  • Go to the Submit page by clicking the hash icon next to your community ID.
    • Make sure your Community ID is entered properly.
    • Enter the amount for the string to hash. 
    • Click Hash, and now enter the hash and your screenshot as a reply to this thread.

Your entry should look like this:

Dan_Wroblewski_5-1712138849568.png

Part II

Open your app in the mobile preview and tap somewhere on the S/4HANA Sales Order page reveal a 30-second video about an event the SAP Developer Advocates put on around the world (a second tap will hide the video). Type the name of the event in your reply. 

--------------
See all my blogs and connect with me on Twitter / LinkedIn

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK