Purpose
Using a Microsoft Azure web service, an image of an expense receipt is automatically processed and the data is read.

Example
The user selects an image file of an expense receipt on his PC. The image is analyzed by the service and the recognized field contents are entered on the SAP screen. These can be used from there or also processed in a further step with GuiXT.

Solution
In this example, we use the service from Microsoft: Azure Form Recognize. "The AI-powered document extraction service that understands your forms."

This service can be called via REST API. We can do this in GuiXT either with callJS or with an embedded HTML page in which we call a corresponding JavaScript function.

We use the 2nd way here for the following reason:
We want to give the interface a local file directly. For security reasons we need to use an input element on the HTML page so that the user can select a file. JavaScript cannot automatically access the local file system.
Requirements
Microsoft Azure Form Recognizer is a service that is free with moderate usage. However, you need to initiate this service yourself in the Azure Portal to get an API key. You can find more information directly at Microsoft e.g. at Azure Form Recognizer
Implementation

GuiXT Script "sapmp56t.e1350.txt"
(we extend transaction PR05 - Travel Expense Manager)

GuiXT
Box   (0,85)   (6,134)   "Analyze Document"
 
InputField   (3,86)   "Merchant Name"   (3,101)  _ 
   size= 25  name= "merchantname"    -readOnly
 
Pushbutton   (3,129)   "clear"   "?"   size= (3,5)  _ 
   process= "azure_reset.txt"
 
InputField   (4,86)   "Invoice Total"   (4,101)  _ 
   size= 25  name= "invoicetotal"   -readOnly  
 
InputField   (5,86)   "Invoice Date"   (5,101)  _ 
   size= 25  name= "invoicedate"    -readOnly
 
Control   (0.6,85.4)   (2.4,127.8)  _
   progID= "file:///C:/guixt/scripts/azure_test.html"  _
   name= "azurecontrol"   -closeOnHide
 
// Important so GuiXT JavaScript object is initialized
connecthtml   name= "azurecontrol"


The HTML file "azure_test.html"
We only need an INPUT element that starts the process: HTML

JavaScript Function "guixt_initialize()"
It is important to define this function in the embedded HTML file and use the GuiXT keyword "connnectHTML" so the GuiXT JavaScript object is available in the following functions. We use this object to change GuiXT variables and call InputScripts via JavaScript.

JavaScript

JavaScript Function "analyzeDocument()"
JavaScript
JavaScript Function "getResult()"
JavaScript
Downloads
You can find all files in this .zip archieve:
azure_formrecognizer.zip

Components
InputAssistant + Controls