4

Create automation process with SAP Intelligent Robotic Process Automation

 1 year ago
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%201%3A%20SAP%20Desktop%20Agent%20and%20SAP%20Desktop%20Studio%20are%20installed

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%202%3A%20Install%20SAP%20Process%20Automation%20extension

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%203%3A%20Create%20new%20project

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%204%3A%20Capture%20SAP%20Help%20Portal

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%205%3A%20Scan%20and%20Capture%20search%20page

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%206%3A%20Add%20URL%20to%20Criteria%20of%20SearchPage

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%207%3A%20Identify%20search%20input

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%208%3A%20Search%20Button%20and%20Search%20Input%20are%20identified

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%209%3A%20Capture%20SearchResult%20page

Figure 9: Capture SearchResult page

Click on Search Result | SAP Help Portal and click on Scan And Capture.

Figure%2010%3A%20Scan%20and%20Capture%20SearchResult%20page

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%2011%3A%20Add%20TITLE%20to%20Criteria%20of%20SearchResult

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%2012%3A%20Add%20TITLE%20to%20Cretiria%20of%20pSearchResultsSAP

Figure 12: Add TITLE to Cretiria of pSearchResultsSAP

Click the first search result LI tag, right click and select Associate to New Item.

Figure%2013%3A%20Identify%20search%20result%20LI

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%2014%3A%20Identify%20search%20result%20as%20a%20list

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%2015%3A%20Identify%20title%20for%20each%20search%20result%20in%20LI%20tag

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%2016%3A%20Identify%20last%20updated%20date%20for%20each%20search%20result

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%2017%3A%20Identify%20Search%20Result%20title

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%2018%3A%20Capture%20EmailHome

Figure 18: Capture EmailHome

Select email app and change name to pEmailHome. Click Scan And Capture.

Figure%2019%3A%20Scan%20And%20Capture%20EmailHome

Figure 19: Scan And Capture EmailHome

Click EmalHome. Double URL under Captured Data to add URL to Criteria of EmailHome

Figure%2020%3A%20Add%20URL%20to%20EmailHome%20Critaria

Figure 20: Add URL to EmailHome Critaria

Click pEmailHome. Double click URL under Captured Data to add URL to Criteria of pEmailHome.

Figure%2021%3A%20Add%20URL%20to%20pEmailHome%20Criteria

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%2022%3A%20Identify%20New%20Mail%20button

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%2023%3A%20Save%20And%20Capture%20NewMail%20page

Figure 23: Save And Capture NewMail page

Click new mail page. Change the name to pNewMail and click Scan And Capture.

Figure%2024%3A%20Scan%20and%20Capture%20new%20mail%20page

Figure 24: Scan and Capture new mail page

Click NewMail. Double click TITLE under Captured Date to add TITLE to Criteria of NewMail.

Figure%2025%3A%20Add%20TITLE%20to%20NewMail%20Criteria

Figure 25: Add TITLE to NewMail Criteria

Click pNewMail. Double click TITLE update Captured Data to add TITLE to Criteria of pNewMail.

Figure%2026%3A%20Add%20TITLE%20to%20pNewMail%20Criteria

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%2027%3A%20Identify%20body%20in%20pNewMail

Figure 27: Identify body in pNewMail

Create Workflow

Click Workflow icon in SAP Desktop Studio to come to Workflow view.

Figure%2028%3A%20Change%20to%20Workflow%20view

Figure 28: Change to Workflow view

Right click GLOBAL and select New Workflow… Input Workflow Name and click Save button.

Figure%2029%3A%20Create%20new%20workflow

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%2030%3A%20Add%20Start%20application%20to%20flowchart

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%2031%3A%20Drag%20SearchPage%20to%20flowchart

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%2032%3A%20Set%20input%20value%20to%20search%20input%20text%20box

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%2033%3A%20Click%20Search%20button

Figure 33: Click Search button

Click SearchAndEmail to come back to the flowchart.

Figure%2034%3A%20Comeback%20to%20Flowchart

Figure 34: Comeback to Flowchart

Click Save button and click Debug button to run our automation process.

Figure%2035%3A%20Save%20and%20Debug%20our%20automation%20process

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%2036%3A%20Run%20SearchAndEmail%20workflow

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%2037%3A%20Change%20generated%20code%20to%20open%20SearchPage%20by%20Chrome

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%2038%3A%20Workflow%20after%20adding%20EmailHome%20to%20open%20EmailHome%20page%20after%20finishing%20search

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%2039%3A%20Modify%20generated%20code%20to%20open%20EmailHome%20page%20by%20Chrome

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%2040%3A%20Add%20click%20New%20mail%20button%20to%20come%20to%20NewMail%20page

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%2041%3A%20Workflow%20after%20adding%20NewMail%20page%20and%20searchResult

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%2042%3A%20Add%20loop%20to%20Workflow

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%2043%3A%20Store%20the%20value%20of%20title%20and%20last%20updated%20date%20to%20searchResult.title%20and%20searchResult.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%2044%3A%20Create%20isNew%20item

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%2045%3A%20Finish%20the%20FlowChart

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%2046%3A%20Add%20If%20to%20NewMail%20page%20activities

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%2047%3A%20Set%20all%20titles%20that%20satisfy%20the%20condition%20to%20the%20body%20of%20NewMail%20page.

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%2048%3A%20Add%20new%20line%20after%20titles

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%2049%3A%20Finish%20activities%20for%20NewMail%20page

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%2050%3A%20Modify%20the%20generated%20script%20to%20determine%20what%20records%20will%20be%20put%20to%20NewMail%20body

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK