Skip to Content
Technical Articles
Author's profile photo Peter Engel

SAP Intelligent Robotic Process Automation 2.0: File Handling

In this blog post you will learn how you can use the basic file activities in SAP Intelligent RPA 2.0 (version 2102). The overall Automation will execute the following steps:

  1. Create the folders ‘Start’, ‘End’ and ‘Copy’.
  2. Create 5 files using the ‘Repeat’ control and the ‘Create File’ activity.
  3. With ‘Get File Collection’ we get a list of files in a folder.
  4. Moving the created files into another folder controlled with the ‘For each’ control.
  5. Copy a complete folder.
  6. Remove the folder ‘Copy’.

 

Activity ‘Create Folder’

With the activity ‘Create Folder’ we can create folder in the file system of our local machine. The input parameter for this activity is the folder path.

For the automation above we use this activity three times to create three new folders:

Activity ‘Create Files’

The activity ‘Create Files’ works similar to the activity ‘Create Folder’.

To create five files with the name ‘Test1’ … ‘Test5’ we use the control ‘Repeat’.

This control is a loop which will be executed x-times from the ‘Starting value’ until the ‘Ending value’ is reached. The actual state is delivered in the ‘Loop Parameter’.

We create the five files dynamically using the form builder, adding the value of the ‘Loop Parameter’ to the name and the file path.

Activity ‘Get File Collection’

This activity is important to work with more than one file at the same time. This activity delivers a list of files in a folder in the output parameter ‘coll’.

With the parameter ‘full’ we can decide if the list contains only the file names (full = false) or also the path where the file is stored (full = true).

Activity ‘Move Files’

With the activity ‘Move Files’ we are able to move files between different folders. Input parameters are the source and the destination of the files.

As we select in the previous step to collect only the file names we have to compose the complete path out of the path and the name of the file. The name of the file stored in the variable currentMember of step 7. To achieve this we are using again the formula editor.

In this example we move the files file by file. We can do this using the control ‘For each’ which is another way to create a loop to work on a list.

In this control we have to set the looping list which is in our case the output parameter ‘coll’ from step 6 of the automation. The loop parameters are ‘currentMember’ with the value in this case the file name and the index value.

In this control we have to set the looping list which is in our case the output parameter ‘coll’ from step 6 of the automation. The loop parameters are ‘currentMember’ with the value in this case the file name and the index value.

Activity ‘Copy Complete Folder’

With this activity we copy all files in a folder to another folder. The input parameter are again source and the destination path. In addition we have an option overwrite files in the destination folder or not.

In case we do not allow overwriting we have to use the control ‘Try’ to handle potential error messages.

Activity ‘Remove Complete Folder’

With this activity we can remove a folder and delete the content. This activity has only the path to the folder which should be removed as an input parameter.

Conclusion

Now you should be able to use the basic file handling activities in the Cloud Studio. Try it out and combine it with other activities to create real world automations.

For more information on SAP Intelligent RPA

Assigned tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Juan Rodriguez
      Juan Rodriguez

      Hi, thanks for this amazing tutorial!

      I have a problem, when i add the step6 (GeT File Colection), i don't have the option of choose the 'full'. That's normal??

      Regards

      Author's profile photo Peter Engel
      Peter Engel
      Blog Post Author

      Hi Juan,

      my example was build on the 2102 release which is not yet released to customers or in trial. Could be new with this version. Also you can check if you have the latest available SDK activated.

      Br,

      Peter

      Author's profile photo Jan Pascal Tschudy
      Jan Pascal Tschudy

      Hello Peter Engel

      I see that you use hard-coded paths. Prior to iRPA 2.0 I used for that case the wscript library which was available to get access to the environment variables. Is this still possible with iRPA 2.0 because I don't see a wscript library or I'm unable to find it. Is there a new way to access the enviromnent variables in iRPA 2.0?

      Thanks

      Author's profile photo Peter Engel
      Peter Engel
      Blog Post Author

      Hi Jan,

      I used the hard-coded path to keep it simple at the beginning 😉

      Please find the description how to create a factory variable here: https://help.sap.com/viewer/8e71b41b9ea043c8bccee01a10d6ba72/Cloud/en-US/9e4bdfa20eab483694917c22c4bd675d.html?q=environment%20variable

      To use the environment variable you can easily set this in the e.g. value field of a set activity or of course as part of the path for the different file activities. You can recognise the variable on the E before the name.

      So no coding anymore.

      Br,

      Peter

      Author's profile photo Jan Pascal Tschudy
      Jan Pascal Tschudy

      Hello Peter

       

      Thanks for your reply. I guess I should have mentioned that I was referring to Windows-Environment variables, and not the Environment variables in a project itself.

      I used it following way to determine the HOME-Path on a user Machine which worked perfectly fine.

      There I used the ctx.wscript.shell and the enums which were exposed by the sdk to easily access those variables.

      So in this case I'm wondering myself how I can access the HOME-Path Windows variable within the iRPA 2.0 SDK. A workaround I was thinking of was accessing the WScript.Shell via

      var Shell = new ActiveXObject("WScript.Shell");

      but it turns out that I cannot create a Custom Script and accessing ActiveXObjects anymore in the new SDK.. or I just dont know how to do it.

      Greetings

      Author's profile photo Maty Seye
      Maty Seye

      Hi,

      thanks for this awesome post.

      I have an issue with 'Create File' activity' inside the For Each, no file are created when i run the automation. And all the steps are done correctly.

      Author's profile photo Peter Engel
      Peter Engel
      Blog Post Author

      Hi Maty,

      I used the Repeat activity in my example. Can you post some screen shots here?

      Br,

      Peter

      Author's profile photo Maty Seye
      Maty Seye

      Hi Peter,

       

      here is the capture

      Author's profile photo Peter Engel
      Peter Engel
      Blog Post Author

      Hi,

      can you show the full file path.

      Br,

      Peter

      Author's profile photo Rahul K
      Rahul K

      Hello Peter,

       

      Can you please guide how to download a report using the below icon?

       

      Thanks,

      Rahul Kothari

      Author's profile photo Peter Engel
      Peter Engel
      Blog Post Author

      Hi,

      can you show the complete captured screen? Without that one guess could be to declare the items as a collection.

      Br,

      Peter

      Author's profile photo Rahul K
      Rahul K

      Hello Peter,

      Thank you for response. Attached is the Ariba portal captured screen for reference.

      Author's profile photo Max McPhee
      Max McPhee

      Hi Rahul,

       

      As Peter suggested, you will want to capture that element as a collection.

       

      This page from the documentation will help explain this collection technique.

       

      Once you have captured that element as a collection you can use the Click activity to click on download.

       

      Best Regards,

      Max