Execute ODATA POST Call in SAP Build Apps
source link: https://community.sap.com/t5/technology-blogs-by-members/execute-odata-post-call-in-sap-build-apps/ba-p/13574106
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.
10-03-2023 9:50 PM
Motivation:-
In this blog you will learn how to post data from SAP Build Apps web application to S/4 HANA System.
Business Scenario:- Design a SAP build app which will post data to SAP S/4 HANA Z Table using OADAT POST Call.
Create an ODATA with Create Entity Method and Create a Custom Z Table.
Now Create a new SAP Builds app
Click on create button
Click on Build an ApplicationSAP Build an application
Click on Web & Mobile ApplicationWeb and Mobile Application
Give the Project Name and DescriptionCreate an application
Build apps UI CanvasBuild apps UI Canvas
Now Its time to create a Destination in SAP BTP cockpit under Connectivity, give all the required details as given in below screen shot's and add the additional properties. In the URL give your ODATA URI and click on Save button then do the connection test.Create Destination
Connection testConnection Test
Go to SAP build app Auth tab and click on Enable AuthenticationAuth Tab in UI Canvas
Click on SAP BTP authenticationBTP authentication
Click on Save button AuthenticationClick on Data Tab and click on Add Integration button
Data Tab
Click on BTP DestinationBTP Destination
Select your created destination which has been created in destination under Connectivity in BTP cockpitSelect created Destination
Click on Install IntegrationInstall Integration
Click on Data EntityEnable Data Entity
Enabled Data Entity and SaveEnabled Data Entity
Open UI Canvas and Click on green arrow for switch to Variable modeUI Canvas
In the variable mode here we can define App and Data variableVariable mode
Click on App variable as MATNR , MAKTX , I have only 2 fields in my ODATA & Custom Table.Creation id App variable
Click on Data variable + sign and select the Data entityData Variable
Select the Data entitySelect Data Entity
Added Data variable and click on SaveAdded data variable
Switch to view mode from variable modeSwitch to view mode
In UI Canvas drag and drop the fieldsDrag and drop fields
Give Screen fields name as per your requirementScreen fields name
Assign screen fields with App variable, select the fields and click on value iconAssignment of app variable
After clicked on Value below popup will open, Select the Data and VariableData and Variable
click on App variableApp Variable
Select the App variable and click on Save , Please do the same activity to assign app variable for MAKTX fields and save.Bind field with MATNR
MATKX assignment with App variableMAKTX assign with App variable
Select the button and click on Show Logic for BUTTON 1Select the button
On the bottom of screen button logic will be openButton Logic window
as per our requirement, We need to perform the create operation so here in logic window drag and drop create record tool to logic canvas as shown below After Dragged the Create recordSelect item for drag and drop
Now its time to mapping so here you need to map button even to create record just drag the cursor from component tap to Create record ad shown below in yellow color and click on saveMapping
Assign App variables with Data entityAssign fields with App variable
Click on FormulaFormula
Map the Entity fields with App variable and Savecode -{Matnr: appVars.MATNR, Maktx: appVars.MAKTX}
Mapping of variables
Drag and drop the toast for user confirmation popup after data saved and right side you can give any custom message Now its time to run the AppLaunch the app
And then click on Preview on Web button select the AppSelect the App
Preview of AppApp Preview
Before enter the data , Showing S/4 Custom table entryTable entry
Now its time to fill data on the Build apps and click on Save buttonSaving Data to S4 System
Now its time to check table in the S/4 systemTable entry
Summary:This blog can help you to understand how SAP Build Apps perform any ODATA call for POST Method.
Since I am also new to writing blogs, Need Expert suggestions & feedbacks are much appreciated.
If you like this blog post you can follow me for more blogs I will try to make in coming future specifically related to SAP BTP Technologies & SAP Build Apps.
Thank You,
Dinesh Kumar
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK