Create automation process with SAP Intelligent Robotic Process Automation
source link: https://blogs.sap.com/2022/12/28/create-automation-process-with-sap-intelligent-robotic-process-automation/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Create automation process with SAP Intelligent Robotic Process Automation
Create an automation process that perform a search on SAP HELP Portal and extract the search results based on last updated date. We will copy all the search result that have last updated date within a month to new email.
Download SAP Desktop Studio and SAP Desktop Agent
SAP Desktop Studio help to design and develop automation process. SAP Desktop Agent help to run and test automation process.
Go to this link https://tools.hana.ondemand.com/#cloud and search “SAP Intelligent Robotic Process Automation” to download the tool named sap-intelligent-rpa-.*.msi.
Install this file we will have SAP Desktop Studio and SAP Desktop Agent.
Figure 1: SAP Desktop Agent and SAP Desktop Studio are installed
Beside that for running the automation process with Desktop Studio, we also need Remote Tools for Visual Studio.
Go to this link https://visualstudio.microsoft.com/downloads/ scroll down to the end of the page and select Tools for Visual Studio. Select the system and download Remote Tools for Visual Studio.
Install this file to the computer.
Install SAP Process Automation Extension
We need SAP Process Automation Extension for running automation process in Chrome. Open Chrome browser and click extension and select Manage extension. Search “SAP Process Automation extension” and install to chrome.
Figure 2: Install SAP Process Automation extension
Create Automation Process with SAP Desktop Studio
Open SAP Desktop Studio select File > New Project…
Input these values to create new project
Project Name: SearchAndExtract
Title: SearchAndExtract
Client Name: SAP
Figure 3: Create new project
Click Save to create new project.
Capture application
To do automation processes we need to capture applications that we want to run and perform automation processes. For our case, we need to capture Search page, Search Result page, EmailHome, and NewEmail page to store the extracted result.
Capture Search Page
Use this link https://help.sap.com/docs/ to open SAP Help Portal in Chrome browser.
Click Add Application in SAP Desktop Studio to capture SAP Help Portal.
Figure 4: Capture SAP Help Portal
Name to SearchPage and click Save And Capture Page.
Select SAP Help Portal and click Scan And Capture.
Figure 5: Scan and Capture search page
Click on SearchPage and double click URL under Captured Data to add URL to Criteria of SearchPage.
Figure 6: Add URL to Criteria of SearchPage
Click pSAPHelpPortal and double click URL under the Captured Data to add URL to Criteria of pSAPHelpPortal.
Right click the Search input and select Associate to New Item.
Figure 7: Identify search input
Right Click the Search Button and select Association to New Item. We have finished for identification Search Input and Search Button for SearchPage.
Figure 8: Search Button and Search Input are identified
Capture SearchResult page
Input “PRA” to the Search Input and hit Search button. Click Add Application in SAP Desktop Studio to capture new application. Select Search Results | SAP Help portal. Change the name to SearchResult and click Save And Capture Page.
Figure 9: Capture SearchResult page
Click on Search Result | SAP Help Portal and click on Scan And Capture.
Figure 10: Scan and Capture SearchResult page
Click SearchResult. Double click TITLE under the Captured Data to add TITLE to the Criteria of SearchResult
Figure 11: Add TITLE to Criteria of SearchResult
Click pSearchResultSAP and double click TITLE under Captured Data to add TITLE to Criteria of pSearchResultSAP.
Figure 12: Add TITLE to Cretiria of pSearchResultsSAP
Click the first search result LI tag, right click and select Associate to New Item.
Figure 13: Identify search result LI
Change the name of New Item from oLI to oSearchResult. Double click searchresult = true under Captured Data to add to Criteria of oSearchResult. Click Occurs checkbox to identify oSearchResult as a list of items.
Figure 14: Identify search result as a list
Right click the title in the first LI tag and select Associate to New Item. Change the name to oTitle. Select oSearchResult for Ancestor. Now, we can identify all the title in the search result.
Figure 15: Identify title for each search result in LI tag
Right click Last updated in the first LI tag and select Associate to New Item. Change the name to oLastUpdated. Select oSearchResult for Ancestor. Double click class = last-updated under Captured Date to add class = last-updated to Criteria of oLastUpdated. Similarly, this is the way we identify for all last updated date in the search result.
Figure 16: Identify last updated date for each search result
Right click the Search Results title and select Associate to New Item. Change the name to oSearchResultLable. Check the checkbox Must Exist. SearchResult is ready when oSearchResultTitle is available.
Figure 17: Identify Search Result title
Capture EmailHome page
Open this url https://outlook.office.com/mail/ in Chrome browser. Click Add Application in SAP Desktop Studio to capture new application. Select the email page. Change the name to EmailHome and click Save And Capture Page.
Figure 18: Capture EmailHome
Select email app and change name to pEmailHome. Click Scan And Capture.
Figure 19: Scan And Capture EmailHome
Click EmalHome. Double URL under Captured Data to add URL to Criteria of EmailHome
Figure 20: Add URL to EmailHome Critaria
Click pEmailHome. Double click URL under Captured Data to add URL to Criteria of pEmailHome.
Figure 21: Add URL to pEmailHome Criteria
Right click on New Mail button and select Associate to New Item. Check the checkbox Must Exit.
Figure 22: Identify New Mail button
Click New Mail button on Chrome browser to navigate to new mail page. Click Add Application in SAP Desktop Studio to capture new mail page. Click on new mail page. Change the name to NewMail and click Save And Capture Page.
Figure 23: Save And Capture NewMail page
Click new mail page. Change the name to pNewMail and click Scan And Capture.
Figure 24: Scan and Capture new mail page
Click NewMail. Double click TITLE under Captured Date to add TITLE to Criteria of NewMail.
Figure 25: Add TITLE to NewMail Criteria
Click pNewMail. Double click TITLE update Captured Data to add TITLE to Criteria of pNewMail.
Figure 26: Add TITLE to pNewMail Criteria
Right click the body of pNewMail page and select Associate to New Item. Change the name to oBody. Double click aria-label under Captured Data to add aria-lable to Criteria.
Figure 27: Identify body in pNewMail
Create Workflow
Click Workflow icon in SAP Desktop Studio to come to Workflow view.
Figure 28: Change to Workflow view
Right click GLOBAL and select New Workflow… Input Workflow Name and click Save button.
Figure 29: Create new workflow
Click the Activities tab under Activities to see all the available Activities. Click “>” before Application to expand all the Activities under Application. Drag Start to the SearchAndEmail flowcart. Select Properties tab under Properties. Select the application that we want to start in Application section. Select SearchPage to start SAP Help Portal. Connect Start and Start ‘SearchPage’.
Figure 30: Add Start application to flowchart
Click on Pages tab under Activities to see all the available pages. Select SearchPage and drag to the flowchart. Connect Start ’SearchPage’ and SearchPage on the Flowchart.
Figure 31: Drag SearchPage to flowchart
Double click the SearchPage in the Flowchart. Click on the “>” before Item Set to expand all the Activities under Item – Set. Drag Keystroke to the Input search textbox. Change the value of Source data in Properties tab to ‘PRA’.
Figure 32: Set input value to search input text box
Right click Search button and select Click on ‘the Item’ for performing the search after input the search value.
Figure 33: Click Search button
Click SearchAndEmail to come back to the flowchart.
Figure 34: Comeback to Flowchart
Click Save button and click Debug button to run our automation process.
Figure 35: Save and Debug our automation process
Click SAP Desktop Agent in the System Tray and select Test SearchAndEmail to test our workflow.
Figure 36: Run SearchAndEmail workflow
We want to use Chrome browser for our automation processes. Click Script icon in SAP Desktop Studio to switch to Script view. Double click SearchAndEmail to open the generated code of our workflow SearchAndEmail. Insert SearchPage.navigator = e.navigator.Chrome; before SearchPage.start();. Now, run our workflow again. We will have the SearchPage opened in Chrome browser.
Figure 37: Change generated code to open SearchPage by Chrome
Comeback to SearchAndEmail workflow. Click Pages tab under Activities. Drag SearchResult page to workflow. Connect SearchPage and SearchResult page in workflow. Click Activities tab under Activities. Drag another Start Application to workflow. Connect SearchResult page and Start Application. Click Start Application. Click Properties tab select EmailHome for Application property to start EmailHome page. Click Pages tab under Activities. Drag EmailHome page to workflow. Connect Start ‘EmailHome with EmailHome page in the workflow.
Figure 38: Workflow after adding EmailHome to open EmailHome page after finishing search
Modify the generated code to open EmailHome page by Chrome browser. Click Debug to run and check the process.
Figure 39: Modify generated code to open EmailHome page by Chrome
Comeback to workflow. Double click EmailHome. Right click New mail button and select Click on ‘the Item’ to come to NewMail page.
Figure 40: Add click New mail button to come to NewMail page
Click SearchAndEmail page to come back to workflow. Click Pages tab under Activities. Drag NewMail to the workflow. Connect EmailHome and NewMail. Click Context tab. Right click the Context section and select Create Folder to create searchResult folder. Check the checkbox Is Array. Right click searchResult and select Create Item to create title and lastUpdated. These items are used to store the value of title and last updated in the SearchResult page.
Figure 41: Workflow after adding NewMail page and searchResult
Click Activities tab under Activities. Click “>” before Flow – Loop to expand all activities under Flow – Loop. Drag Start under Flow – Loop to the Flowchart. Connect NewMail to Start loop in the flowchart. Drag Exit under Flow – Loop to flowchart. Connect Start loop to Exit loop in flowchart. Click Exit loop. Click Properties tab. In Exit condition select SearchResult>pSearchResultsSAP>oSearchResult. Click Pages tabs under Activities. Drag SearchResult page to flowchart. Connect Exit loop to SearchResult.
Figure 42: Add loop to Workflow
Double click the last SearchResult page in workflow. Click “>” before Item – Get to expand all activities under Item – Get. Drag Get under Item – Get to the first title of the search result. Click Propertiest tab. Change the value of Where to store result to searchResult.title. Drag another Get under Item – Get to the first last updated date of the search result. Change the value of Where to store result to searchResult.lastUpdated.
Figure 43: Store the value of title and last updated date to searchResult.title and searchResult.lastUpdated
Click SearchAndEmail to go back to workflow. Click Context tab. Right click searchResult. Select Create Item to create isNew item inside seachResult. This item is used to determine what will be copied to new email body.
Figure 44: Create isNew item
Click Activities tab under Activities. Click “>” before Flow to expand all activities under Flow. Drag Custom to flowchart. Connect SearchResult page to Custom in flowchart. Click Pages tab under Activities. Drag NewMail page to the Flowchart. Connect Custom to NewMail page in the flowchart. Click Activities tab under Activities. Click “>” before Flow – Loop to expand all activities under Flow – Loop. Drag Loop to flowchart. Connect NewMail page to Loops to the start block.
Figure 45: Finish the FlowChart
Double click the last NewMail page in the flowchart to edit activities for NewMail page. Click “>” before Flow – If to expand all activities under Flow – If. Drag If(start) to the Activities. Click If (true) in Activities. Click Properties tab. Change the first row of Condition to $data$ === true. Change the second row of Condition to searchResult.isNew.
Figure 46: Add If to NewMail page activities
Click “>” before Item – Set to expand all activities under Item – Set. Drag Keystroke to body of NewMail page. Drag this block to make it level smaller than If block. Click Keystroke. Click Properties tab. Change the value of Source data to searchResult.title. All the titles that satisfy the If condition will be put to the body of NewMail page.
Figure 47: Set all titles that satisfy the condition to the body of NewMail page.
We need to put a new line to the body. Drag another Keystroke to the body. Change the Source data to e.key.Enter. Make sure that it has the same level with the Keystroke for title.
Figure 48: Add new line after titles
Now we can add another Keystroke for lastUpdated and new line. We will have all the titles and last updated date that satisfy the condition in the body of NewMail page.
Figure 49: Finish activities for NewMail page
Click Save button (Ctrl + S). Click Build button (Ctrl + B). Click Script icon. Double click SearchAndEmail to open the generated script. Find Custom step and add this code below to the body of Custom step.
var dateString = rootData.searchResult[sc.localData.Startloop].lastUpdated;
dateString = dateString.substring(14);
var date = Date.parse(dateString);
var diffInSecond = new Date().getTime() - date;
var diffInDay = diffInSecond / (1000 * 3600 * 24);
ctx.log('Diff in day ' + diffInDay);
if (diffInDay <= 30) {
ctx.log('is new');
rootData.searchResult[sc.localData.Startloop].isNew = true;
}
else{
ctx.log('is Old');
rootData.searchResult[sc.localData.Startloop].isNew = false;
}
This code is used to set the value of isNew to true when last updated date within 30 days. This value is used to determine what records will be put to NewMail body.
Figure 50: Modify the generated script to determine what records will be put to NewMail body
Conclusion
We have just finished the automation process for search ‘PRA’ in SAP Help Portal and copy all the records that satisfy the condition to NewMail body.
Please let me know your feedback, questions in the comments. I would be happy to get back to you.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK