Low code-platforms like SAP Low-Code SolutionsPower Platform  or Neptune DXP promise customers to speed up the creation of urgently needed apps. In a lot of companies there is a shortage of developers, but the speed of change in businesses puts a lot of pressure on IT to deliver.

Introducing a well governed and managed low-code platform can empower every employee to create apps with the skillset that they have.

  • An ABAP developer will probably be extremely happy to leverage Neptune DXP to create apps – building on her expertise in ABAP.
  • An SAP architect will most likely jump on the chance to use SAP AppGyver to continue his work on the SAP Business Technology Platform and use the deeply integrated connections in the SAP world.
  • And an Office user will just click on the Power Automate action in her Office application and start automating and creating processes in her environment.

Fusion of Teams & Tools

However, we more and more see successful customers building “fusion teams” where colleagues from different backgrounds leverage their skills to create even better apps together. Collaboration is becoming  more critical and the Microsoft Power Platform is empowering users to benefit from cross teams collaboration.

There is not only a fusion of users, but also a fusion of tools and services. Why wouldn’t you use an Neptune DXP Connector to connect to SAP and then expose a Power App in Microsoft Office. Or use one of the pre-build content scenarios from the SAP Process Automation to build a chatbot using Power Virtual Agent.

SAP BTP Document Information Extraction

Another topic is the usage of services. Microsoft Power Platform comes with 700+ connectors and even a built in AI Builder which allows you to process any documents. This is built in and very easy to use. However, when you come from the SAP world, you might also be familiar with the Document Information Extraction Service from the SAP Business Technology Platform. SAP has build and trained a quite impressive service that allows you to extract information from e.g. Invoices (I will leave it up to you to decide which one is better 😊).

Since Microsoft is all about choice, it obviously does make sense to leverage the best tools for the job. So in this example I want to show how you can actually use the SAP Document Information Extraction Service directly from Power Automate. Once you have the information there, you can benefit from the native integration of the Power Platform into the Office world. Creating standalone Apps, building Teams Chatbots, triggering events from incoming Emails, documents stored on an Azure File store or OneDrive are just a few clicks away.

So let’s get started! – Sign up for Trials

Document Information Extraction

Luckily SAP provides a Trial version of the Document Information Extraction services. I have tested it both in the Trial, and also in a “real” BTP instance. For this documentation I am focusing on the Trial since then you can really get started for free.

The first step you need to do is enable Document Information Extraction on BTP. I followed this Getting Started with Document Information Extraction Trial Service | SAP Blogs from Joni Liu   tutorial to get this done (this was also helpful, Use Machine Learning to Extract Information from Documents with Swagger UI | Tutorials for SAP Developers). If you want, you can test the service via the URL mentioned in the service key, e.g. https://aiservices-trial-dox.cfapps.us10.hana.ondemand.com/document-information-extraction/v1/

Power Platform

For the Power Platform, just go to https://docs.microsoft.com/en-us/power-apps/maker/signup-for-powerapps. I would actually recommend that you sign-up for the Microsoft Developer Program so that you get access not only to Power Platform, but to all Microsoft Office 365 products.

Start Creating a Power Automate Flow

Once that is done, go to https://make.powerautomate.com  to start Power Automate. Here we will model all the steps to connect to BTP, retrieve the Access Token and then Post a document to the Document Information Extraction service. We will then parse the results (e.g. Invoice number, Tax amount, …) which could then be used in a Chat, Excel, Outlook or simply in an App.

We will start with a Instance Cloud flow / Manual Trigger (in other scenarios this could be an Email that you are receiving, a document that is uploaded to OneDrive, …).

As a starting point we are fetching a document from OneDrive (I have uploaded one of SAPs sample invoices to my OneDriver folder, https://raw.githubusercontent.com/SAPDocuments/Tutorials/master/tutorials/cp-aibus-dox-swagger-ui/data/sample-invoice-1.pdf)

In order to authenticate against the service, we first need to create a Service Key on BTP for the Document Information Extraction services. Head over to BTP and create the key.

Since I wanted to be fairly flexible I put the key in a variable in my Power Automate Flow and parse the content. Now I have access to all the attributes in the key (in a productive environment I would probably store the key in an Azure KeyVault and only fetch the required information from the Power Automate flow).

With this information I can now fetch the Access Token from BTP. I use the HTTP Connector to call the URL <URL from Service Key>/oauth/token?grant_type=client_credentials

 

With this access token, I can now POST the actual document to the Document Information Extraction service. This can be a little tricky since the services expects the file to be submitted as a Form. Power Automate does not have a ready made UI for this, so I need to create a “multipart/form-data” myself. This might look complicated, but if you take a closer look you will see that it is actually pretty easy.

{
    "$content-type": "multipart/form-data; boundary=----MyFormBoundary",
    "$multipart": [
        {
            "body": "18",
            "headers": {
                "Content-Disposition": "form-data; name="category""
            }
        },
        {
            "body": "@{variables('Filename')}",
            "headers": {
                "Content-Disposition": "form-data; name="fileName""
            }
        },
        {
            "body": "yes",
            "headers": {
                "Content-Disposition": "form-data; name="share""
            }
        },
        {
            "body": "        {"extraction": {            "headerFields": [              "documentNumber",              "taxId",              "taxName",              "purchaseOrderNumber",              "shippingAmount",              "netAmount",              "grossAmount",              "currencyCode",              "receiverContact",              "documentDate",              "taxAmount",              "taxRate",              "receiverName",              "receiverAddress",              "receiverTaxId",              "deliveryDate",              "paymentTerms",              "deliveryNoteNumber",              "senderBankAccount",              "senderAddress",              "senderName",              "dueDate",              "discount",              "barcode"            ],            "lineItemFields": [              "description",              "netAmount",              "quantity",              "unitPrice",              "materialNumber",              "unitOfMeasure"            ]          },          "clientId": "default",          "documentType": "invoice",          "receivedDate": "2020-02-17",          "enrichment": {            "sender": {              "top": 5,              "type": "businessEntity",              "subtype": "supplier"            },            "employee": {              "type": "employee"            }          }        }       ",
            "headers": {
                "Content-Disposition": "form-data; name="options""
            }
        },
        {
            "body": {
                "$content": "@{variables('FileBody')}",
                "$content-type": "application/pdf"
            },
            "headers": {
                "Content-Disposition": "form-data; name="file"; filename="@{variables('Filename')}""
            }
        }
    ]
}

With this the document is being evaluated and posted on the SAP side.

Since this can take a few seconds we will loop over the status (and wait a litte in between). When we finally get a status “DONE” we look and parse the results.

That’s it.

So let’s give it a try:

In this screenshot you can see the results of the processed document.  (e.g. the Tax Amount). All the information is now available with the parsed JSON file and can be used in Power Apps, Office, Teams, …  Stay tuned for more and give it a try!

You can find the Power Automate Flow on GitHub. All you need to do is put your service key in the variable “Service Key” (in step “Set Service Key”) and update / put an invoice in your OneDrive location.

 

 

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x