How cloud flows are developed and used
Microsoft Power Platform integrates with SAP through a portfolio of preconfigured cloud flows that orchestrate a series of transformations and use the SAP ERP (enterprise resource planning) connector.
Each SAP object managed from a canvas app is mapped to a series of search, create, read, and update flows. As an example, four cloud flows exist for vendor object:
- ReadVendor: Read a single vendor based upon vendor number and key related information.
- ReadVendorList: Search for a list of vendors based upon search criteria passed.
- CreateVendor: Create a new vendor object with key-related information.
- UpdateVendor: Update an existing vendor object and key-related information.
Extend cloud flows
You can extend cloud flows according to your local business requirements. With the help of your SAP business analyst, you can add and map new fields to the SAP ERP connector and go back and forth to the apps through the JSON payloads.
Creating a new purchase requisition offers a typical transaction scenario between canvas apps, cloud flows, and SAP:
The SAP Requisition Management app prepares JSON by using data from the input controls and stored items collections, substituting any null values for empty strings.
Set( varRequisitionJSON,//Build the requisition JSON "{Header: " & JSON(//Build the requisition header JSON { PurchaseRequisitionNumber: varRequisition, Vendor: Trim(txtRequisitionDetailsVendor.Text), PurchasingOrganization: cmbRequisitionDetailsPurchasingOrg.Selected.'Value Code', PurchasingGroup: cmbRequisitionDetailsPurchasingGroup.Selected.'Value Code', Currency: cmbRequisitionDetailsCurrency.Selected.'Value Code' }, JSONFormat.IndentFour ) & ", items: " & JSON(//Build the requisition items JSON from cached collection colRequisitionItems, JSONFormat.IndentFour ) & "}" ); Set( varRequisitionJSON, Substitute( varRequisitionJSON, "null", """""" ) );
The app invokes the embedded CreateRequisition flow using the Run function and passing in the previously constructed JSON string.
Set( varRequisitionReturn, CreateRequisition.Run(varRequisitionJSON) );
The CreateRequisition flow receives the JSON string from the app via the PowerApps(V2) trigger and uses a Parse JSON action to decompose it.
Variables are set using the JSON information to allow for easier mapping into the SAP ERP connector calls.
An SAP session is created using the SAP ERP connector and the business application programming interface (BAPI) calls are made using the parsed requisition JSON information stored in variables.
SAP-generated errors are assessed and either a successful or error HTTP Response is returned to the canvas app using a JSON payload.
The canvas app uses the response information, specifically the Status field, to notify the end user of success or failure and to determine the next processing steps.
Switch(
varRequisitionReturn.Status,
"Error",//Raise error messages leaving variables in existing state for user to try again
Notify(
Concat(
varRequisitionReturn.Messages,
Message,
" "
),
NotificationType.Error
),
"Success",//Raise success message
Notify(
Concat(
varRequisitionReturn.Messages,
Message,
" "
),
NotificationType.Success
);
More information:
Support multi-language deployments
By default, the SAP ERP connector invokes the user's browser language to interact with SAP so the corresponding SAP language pack must be installed.
However, if you need to support multi-language and global deployments, you can override the user's browser language and default to a certain language. For example, a Power Apps user in Spain who has their browser language set to Spanish may need to interact with an SAP system that only has the English (EN) language pack installed. In this case, pass the two letter EN ISO 639-1 code as part of the Language property within the SAP connection string to avoid errors.
Tip
Configure environment variables as part of your solution management and cloud flow extension strategy to centrally store a language value to pass into various SAP ERP connector actions.
More information: SAP System Property Guidance
Error handling
Each flow is designed with a Try/Catch pair of scope operations. Inside the Try operation are the main SAP connector calls. After each call, the flows check if the SAP ERP connector step had a catastrophic failure or what is also called an advanced business application programming (ABAP) core dump. If so, the flows capture the generated error message.
This error message is displayed in the ErrorTable step of the Catch operation, along with all errors generated during that run of the flow.
All erroneous flows are recorded in the SAP solution template error table. Each flow error shows the first error message generated by the flow along with other information.
Go to the SAP Administrator app as described in the Monitor errors article to see the errors displayed.
Next step
Extend model-driven apps and Dataverse