Edit

How to develop and use cloud flows

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 that you manage from a canvas app maps to a series of search, create, read, and update flows. For example, the vendor object has four cloud flows:

  • ReadVendor: Reads a single vendor based on the vendor number and key related information.
  • ReadVendorList: Searches for a list of vendors based on search criteria you provide.
  • CreateVendor: Creates a new vendor object with key-related information.
  • UpdateVendor: Updates an existing vendor object and key-related information.

Extend cloud flows

You can extend cloud flows to meet 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:

  1. 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",
                """"""
            )
        );
    
  2. The app invokes the embedded CreateRequisition flow by using the Run function and passes in the previously constructed JSON string.

            Set(
                varRequisitionReturn,
                CreateRequisition.Run(varRequisitionJSON)
            );
    
  3. The CreateRequisition flow receives the JSON string from the app via the PowerApps(V2) trigger and uses a Parse JSON action to decompose it.

  4. Set Variables by using the JSON information to make it easier to map into the SAP ERP connector calls.

  5. Create an SAP session by using the SAP ERP connector and make the business application programming interface (BAPI) calls by using the parsed requisition JSON information stored in variables.

  6. Assess SAP-generated errors and return either a successful or error HTTP Response to the canvas app by using a JSON payload.

  7. 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 mult-language deployments

By default, the SAP ERP connector uses the user's browser language to interact with SAP, so you need to install the corresponding SAP language pack.

However, if you need to support mult-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 sets their browser language to Spanish might 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.

The SAP solution template error table records all erroneous flows. Each flow error shows the first error message generated by the flow along with other information.

To see the errors, go to the SAP Administrator app as described in the Monitor errors article.

Next step

Extend model-driven apps and Dataverse

See also

Get started with the SAP Procurement template