Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Latest commit

 

History

History

1_CreateAppGyverProject

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Table of Contents

Overview

In this exercise, you will build your app in SAP Build Apps to upload invoices.

Scenario

Create a Build Apps Project

  1. From SAP Build Lobby, click on Create and then select Build Apps Project.

    Username Password
    AD160_XXX
    where XXX is the user number
    like AD160_000, AD160_001 etc.
    Acce$$teched22


Create the project
Create the project

  1. Under Project Name, enter "Invoice AD160-XXX", replace XXX with your user ID. For example, "Invoice AD160-087".
    Click on Create to start building your application.

    Name the project

Create UI

  1. You will be redirected to Build Apps Composer, which is like an IDE for SAP Build Apps. On the canvas, you can already see a Title and a Text component.

    home page

  2. Click on “Headline” on the canvas to select the Title component. Now, the PROPERTIES tab on the right-hand side will show the properties of the Title component where you can modify it.
    Under Content, enter “Invoice Approval.

    Title component

  3. Select the Text component, modify the Content under the PROPERTIES tab on the right-hand side to "Enter your name and upload your invoice".

    text component

  4. Drag and drop an Input field from the UI Component library into the canvas.

    input component

  5. Under the PROPERTIES tab of the Input field, clear the Label and change the Placeholder text to "Enter your name".

    input properties

  6. Drag and drop a Button component from the component library on the left-hand side into the canvas.
    Change the Label on the button in the PROPERTIES tab of the button component to “Upload your Invoice”.

    Button

  7. Drag and drop an Image component into the canvas.

    Image

  8. Switch to VARIABLES view.

    In Variables view, you can create variables which can store information temporarily.

    Variables

  9. Create an App variable by clicking on ADD APP VARIABLE and rename it to "name".

    create variable

  10. Add another App variable and rename it to "Invoicescan".

    create another variable

  11. Change the Variable value type of Invoicescan to Local filesystem path.

    variable type

  12. Add another App variable and rename it to filename.

    variable type

  13. Switch back to VIEW.

    View

  14. Under the PROPERTIES tab of the Input field component, open the binding menu for Value by clicking on the "X" icon.

    bind menu

  15. The binding menu will pop-up. Select Data and Variables.

    binding menu

  16. Select App variable.

    app variable inbind menu

  17. Select name in the list of App variable available.

    name of app vairble

  18. Click on the SAVE button to save the binding to the component value.

    SAVE button

  19. A variable can be binded to this image component. Open the binding menu of the Image component under PROPERTIES on the right-hand side.

    bind menu

  20. The binding menu will pop-up. Select Data and Variables.

    bind image

  21. Select App variable.

    app variables

  22. Select Invoicescan under the list of available app variables and click on SAVE to save the binding to the Image component.

    variable

  23. Drag and drop another Button component from the component library into the canvas and rename the Label to Submit.

    Submit

  24. The Submit button should be visible only after the invoice is selected. Click on ADVANCED PROPERTIES to change the visibility properties of the button. Open the binding menu for the visibility properties.

  25. Select Formula.

  26. In the formula bar enter the following formula:

    IF(IS_EMPTY(appVars.Invoicescan),false,true)

    This formula checks if the InvoiceScan page variable is empty, then the output will be false and component will be disabled. If the InvoiceScan page variable has some value, the output will change to true, and the component will be displayed.

    Click on SAVE.

  27. Click on SAVE.

  28. Click on SAVE on the top right corner to save the UI created so far.

Data Connection

Now, your application will be connected to Document Management System and SAP Process Automation. First, you should enable BTP authentication to connect your app to SAP Process Automation via Destinations.

  1. Choose AUTH tab on the top of the screen.

  2. Select ENABLE AUTHENTICATION.

  3. Select SAP BTP authentication.

  4. Click on the OK button to enable the BTP authentication to your application.

  5. Click on DATA tab.

  6. Under SAP AppGyver classic data entities, click on CREATE DATA ENTITY and select SAP BTP destination REST API integration.

  7. As the BTP destination name, select AppGyver_SPA.

  8. Under Data resource name, a name can be given to this data connection, like "SendtoSPA".

  9. Under Resource schema, click on + ADD NEW to create a schema. Name the new schema to "filename" and select the Field type as Text. Choose ADD.

    Schema is structure of the data. A schema is created which is similar to the Data base. In this scenario the data base is Document Management System (DMS), and schema should be created matching the schema in DMS.



  10. Similarly, add three other schema with the following names:

  • "foldername"

  • "employeename"

  • "employeemail"

    Select the Field type for all of them as Text.

  1. Select the create tab, and enable it.

  2. Open the binding menu for Request headers by clicking on the X icon.

  3. In the binding menu, select List of values.

  4. Click on Add value, and enter the following values:

    • Header name: Content-Type
    • Header value: application/json

    Click on SAVE.

  5. Request body mapper value will be binded after creating the process using SAP BUILD PROCESS AUTOMATION.

    Click on SAVE DATA RESOURCE. The connection between your Application and Process is created using Destinations.

  6. Add another data entity to store the invoice in Document Management Service.

    For this data connection, Destinations are not used because, the response from Document Management Service is in XML format. AppGyver can only read JSON responses.
    Because of this reason Document Management Service is connected using DIRECT REST API.

    Click on CREATE DATA ENTITY and now select REST API direct integration.



  7. In the BASE tab of the API configuration enter the following values:

  1. Select the CREATE RECORD tab and enable it.

  2. Switch to the SCHEMA tab.
    Under Create record (POST) request schema use the drop down list and select Custom schema.

  3. Click on ADD PROPERTY. Rename the Key in PROPERTIES to “base64”.

  4. Add another property and rename it to “fileName” and click on SAVE DATA ENTITY.

  5. Click on SAVE on the top right corner of the screen.

Create Logic for Upload button

  1. Go to the UI CANVAS. Select the Upload your Invoice button and click on the grey bar on the bottom to open the logic composer.

  2. By default, the trigger event will be Component tap.
    Now you will download a new component from the MARKETPLACE.

    MARKETPLACE contains hundreds of pre-built visual and logic components, which can be installed and used with minimum or no customization. Find more information on MARKETPLACE here.

  3. Click on the MARKETPLACE search bar. You may search for “pick image”. Select the Pick image from library component.

  4. Click on INSTALL to install the logic component in the library.

  5. Drag and drop the Pick image from library under the INSTALLED tab into the logic canvas. Connect output node of the Component tap logic component with the Pick image from library component.

    To do so, click on the node of the Pick image from library component. Now pull the node, creating a line that you can link to the node of the Component tap logic component.

  6. From the CORE tab of the component library drag and drop the Set app variable component into the canvas. In the same way, connect the node of the Pick image from library component to the Set app variable component.

  7. In the PROPERTIES tab of the Set app variable, select the variable Invoicescan.

  8. Open the binding menu for Assigned value.

  9. Select Output value of another node.

  10. You can see the available nodes in the canvas. Select Pick image from library node. A list of outputs from node will appear. Select path.

  11. Click on SAVE.

Create Logic for Submit button

  1. Select the Submit button and click on the grey bar on the bottom to open the logic composer.

  2. You will download a new component from the MARKETPLACE.

  3. In the search bar, search for “base64” and select Convert file to base64 and install it.

  4. Drag and drop Convert file to base64 into the logic canvas.

    Submit

  5. Connect the nodes of Component tap and Convert file to base64. Open the binding menu for Source file URL of the Convert file to base64 logic component.

    Submit

  6. In the binding menu select Data and Variables and select App variable.

    Submit

  7. Select Invoicescan and click on SAVE.

    Submit

  8. From the CORE tab, drag and drop Set app variable component from the component library and connect the node with Convert file to base64.
    In the PROPERTIES tab, make sure the variable is filename, and now open the binding menu for the Assigned value.

    Submit

  9. Select Formula in the binding menu.

    Submit

  10. Open the formula editor. Select App variables and double click on appVars.name to use the function.

    Submit

  11. Add the following values.

    +TIMESTAMP()+".png"
    The overall formula will look like the following:

    appVars.name+TIMESTAMP()+".png"
    Click on SAVE.

    Submit

  12. Drag and drop Create record logic component into the logic canvas and connect the nodes with Set app variable component. In the PROPERTIES tab of the logic component check if the Resource name is Documentupload. Open the binding menu of Record properties.

    Submit

  13. In the binding menu, select Object with properties.

    Submit

  14. Open the binding menu for base64.

    Submit

  15. In the binding menu select Formula and open the formula editor. In the formula editor, enter the following formula:

    REPLACE_ALL(outputs["Convert file to base64"].base64,"data:image/png;base64,","")
    Click on SAVE button.

    Submit

  16. Open the binding menu for fileName.

    Submit

  17. In the binding menu, select Data and Variables and select App variable. Select the variable filename and click on SAVE.

    Submit

  18. Save the bindings.

    Submit

  19. Drag and drop another Create record logic component into the logic canvas and connect the nodes with Create record component. Change the Resource name to SendtoSPA. Open the binding menu for Record properties.

    Submit

  20. In the binding menu, select Object with properties.

    Submit

  21. Open the binding menu for filename.

    Submit

  22. In the binding menu, select Data and Variables, then choose App variable and finally the variable filename.
    Click on SAVE.

    Submit

  23. The folder name will be static, enter the value “Invoices”.

    Submit

  24. Open the binding menu for the employeename.

    Submit

  25. In the binding menu, select Data and Variables. Select App variables and then choose name.

    Submit

  26. The employeemail will be static, enter the email provided to you "[email protected]". For example: "[email protected]"

    Submit

  27. Save the bindings.

    Submit

  28. Drag and drop a Toast component.

    This component displays a message.

    Connect the nodes of the Create record component to the Toast component. Under the properties of the Toast component, enter "Your Invoice has been submitted" as the Toast message.

    Submit

  29. Save your work.

Summary

You have build an app and completed the below steps.

Summary

Continue to - Exercise 2 - Install and configure Desktop Agent 3 and get started with SAP Build Process Automation.