Skip to Content

Create an Automation to Extract Invoice Details

Extract invoice document using Document Extraction Template to send the invoice details to the process
You will learn
  • How to extract data using Document Extraction Template
  • How to bind parameters between process and automation
Created by
aviral-agarwal-sap
March 6, 2023
Contributors
aviral-agarwal-sap

Prerequisites

  • Step 1
    1. In the process Get Invoice Details:

      • Choose +,
      • Select Automation, New Automation.
      Automation
    2. A pop up will appear to configure the Desktop Agent version. Do the following in the pop up:

      • From the dropdown, select the version of the Desktop Agent installed on your machine.
      • Choose Confirm.

      It would be with suffix as Registered.

      Automation
    3. A new pop-up will appear to create the automation. Do the following in the pop-up:

      • Enter Name of the automation: Extract Invoice Data,
      • Enter Description of your choice,
      • Choose Create.
      Automation

      An automation Extract Invoice Data will be created successfully.

      Automation
    Log in to complete tutorial
  • Step 2
    1. Go to the Overview Tab. Choose the Create button. Create an artifact of the type Data Type.

      Automation
    2. A new pop-up will appear:

      • Enter Name of the data type: Invoice,
      • Enter Description of your choice,
      • Choose Create.
      Automation
    3. In the Data Type Invoice add new fields as following:

      Field Name Type
      DocumentNumberString
      GrossAmount Number
      SenderName String
      Automation
    4. Choose Save.

      Automation
    Log in to complete tutorial
  • Step 3

    Input and output parameters allow you to exchange data in the workflow of your automation between activities, screens, and scripts.

    1. Go to the Overview tab. Open Extract Invoice Data Automation.

      Automation
    2. In Automation Details, select the Input/Output section.

      Automation
    3. Add Input and Output parameters.

      Automation
    4. Edit Input and Output parameters as follows:

      Parameter Name Data type Parameter Type Description
      FilePath String Input Please provide the full qualified path to the PDF file containing the invoice
      InvoiceDetails InvoiceOutput Extracted Invoice Details
      Automation
    5. Choose Save.

    Log in to complete tutorial
  • Step 4
    1. Go the Overview Tab. Choose Create and Document Template.

      Automation
    2. In the Create Document Template window, under Details:

      • Choose Create a new template,
      • Enter the Name of the template,
      • Upload the invoice document which you have downloaded from prerequisites,
      • Choose Next.
      Automation
    3. Select Invoice as the document type of your template and choose Next.

      Automation
    4. Under Choose Schema:

      • Choose Create New,
      • Enter the Name of the schema,
      • Choose the Header fields that you would extract the data from the Invoice document. In this scenario you would select documentNumber, grossAmount, senderName.
      • Choose Add.
      Automation
    5. Document Information Extraction SDK would be added as dependency to your project. The schema and template are created successfully.

    6. Once Upload will be completed, choose Open in a new tab.

      Automation
    Log in to complete tutorial
  • Step 5
    1. You are now navigated to Document Information Extractor. It allows you to edit and annotate the template. To work on Document Information Extractor, please check if you have been assigned to Document_Information_Extraction_UI_Templates_Admin role in SAP BTP Cockpit. Otherwise, add the role manually. You would get an error if you do not have DOX roles.

      Automation
    2. Select the Document Name.

      Automation
    3. Choose Annotate.

      Automation
    4. Choose Edit.

      Automation
    5. Select the data in your invoice document which you would like to extract the information. In this scenario, you will read the Document Number, Gross Amount and Sender Name.

      • Select the value 174221 in the document and map to the field documentNumber. Choose Apply.

        Automation
      • Select the value ABC Communication in the document and map to the field senderName. Choose Apply.

        Automation
      • Select the value 220 in the document and map to the field grossAmount. Choose Apply.

        Automation
    6. Once mapping is done. Choose Save and Activate the template.

      Automation
    Log in to complete tutorial
  • Step 6
    1. Navigate back to Build Process Automation and select Extract Invoice Data automation tab.

      Automation
    2. In Automation Details, under Tools, in search field, search for Extract data (Template) activity.

      You can extract data with Document Information Extraction using the chosen document template and given PDF file.

      Automation
    3. Drag and drop the activity Extract Data (Template) into the automation flow.

      Automation
    4. Select the activity. Maintain the parameters for the activity as follows:

      • Under Document Schema: select your Schema
      • Under Document Template: select your Template
      • Under documentPath: choose FilePath
      Automation
    5. You have already created the data type Invoice in Step 2. Now, you will create a variable of type Invoice.

    6. Click on the canvas. Search for the datatype Invoice, located under the Data Types section.

      Automation
    7. Drag and drop the data type Invoice into the automation flow.

      Automation
    8. Select Create Invoice variable. In the Input Parameters, under value, choose Create Custom Data.

      Automation
    9. Choose the Edit button to map the parameters:

      • DocumentNumber to the extracted invoice data from the activity Extract Data (template),
      • Repeat the same for GrossAmount and SenderName and map it to the corresponding fields of extractedData.
      Automation
    10. Rename the output parameter to myInvoiceData.

    11. The final input and output parameters of Create Invoice Variable looks as below.

      Automation
    12. Print the invoice data using the activity Log message.

      With this activity you generate a log message within the tester and the trace file, which is useful for setting up an automation. By default, a log will be “Information”.

    13. Click on canvas, search for Log Message activity and drag and drop it into the automation flow.

      Automation
    14. Select Log Message activity. In Input Parameters under message add myInvoiceData value.

      Automation
    15. Select Save.

    Log in to complete tutorial
  • Step 7
    1. Select the End. Pass the variable myInvoiceData to the output parameter InvoiceDetails, which you have created in Step 2.

      Automation
    2. Save the automation.

    Log in to complete tutorial
  • Step 8
    1. Navigate to the Get Invoice Details process and select the automation Extract Invoice Data. Map the input parameter of the automation to the form parameter FilePath.

      Mapping
    2. Select Save.

    Log in to complete tutorial
  • Step 9
    1. Select Test button and enter the Filepath where the invoice document is stored locally on your machine.

      Test
    2. The automation opens the Invoice Document, extracts data and prints the details i.e Document number, Gross amount and Sender name.

      Test
    3. Your automation is built successfully.

    4. Once this tutorial is completed, the process will look like this:

      Mapping

    Log in to complete tutorial
Back to top