How To Run AS400 With Power Automate Desktop Terminal Actions

How To Run AS400 With Power Automate Desktop Terminal Actions

Power Automate Desktop is excellent at automating AS400 tasks. AS400, also known as the IBM iSeries, has been around since the late 1980s. Many business still use this legacy system because of its reliability, security and the ability to operate it with only keyboard commands. There are no cloud based APIs for AS400, which makes it a perfect candidate for Power Automate Desktop.

Table Of Contents:
• Introduction: AS400 Terminal EmulationRun The AS400 ApplicationConfigure The PC5250 MenuOpen An AS400 Terminal Session (HLLAPI)Login To AS400 With User And Password Navigate The AS400 Main Menu Alternate: Open An AS400 Terminal Session (Micro Focus Reflection)




Introduction: AS400 Terminal Emulation

In this tutorial I will show you how to open AS400, login to the system and navigate menus with Power Automate Desktop. We will do this by using terminal emulation actions.




Run The AS400 Application

Open Power Automate Desktop and create a new desktop flow. Add the Run Application action. Fill-in with the application path parameter with the path to pcsws.exe which opens AS400. The screenshot below shows the default AS400 installation path but check your own installation to confirm the correct path.



When pcsws.exe is run a new window appears with an AS400 session. In the screenshot below, the session name is “A”.



Use a Wait for Window action to ensure the session has started before more Power Automate Desktop actions are run. Set the Find window parameter to By title and/or class and the Window title to Session*. The star (*) symbol is a wildcard.



Next, insert an Open terminal session. Select the Provider HLLAPI and choose the the path to the AS400 ehlapi32.dll file. The Session name is found in the AS400 window title.



Now Power Automate Desktop can open AS400 by using these 2 actions.




Configure The PC5250 Menu

Upon opening AS400 appears asking to configure PC5250. An IBM 5250 is the type of terminal AS400 runs on.

Populate the system name text field with your system name. I cannot tell you the correct value for this. It differs for every company. Select the Radio button Specific Workstation ID. Then populate the Port number text field with the number 23. Press the properties button.



When the Connection menu appears, set the drop-down list value to Prompt Every Time. Choose Use Operations Navigator Default. Press the OK button.



Then press the OK button on the Configure PC5250 screen.



Wait for the The IBM i signon prompt to show on the screen. Then populate the UserID and password fields with values and then press the OK button.



The desktop flow actions for the previous steps look like this:


Open An AS400 Terminal Session (HLLAPI)

Once the login is successful we add an Open terminal session action.

There are 2 different providers for AS400: HLLAPI and Micro Focus Reflection. This section will show how to setup AS400 for HLLAPI. If you are using Micro Focus Reflection instead, please go here to find setup alternate instructions.



Login To AS400 With User And Password

On the AS400 Sign On screen we will use Power Automate Desktop to fill-in the user and password a 2nd time.



Add a Set text on terminal session action to the desktop flow. Write the username in the text parameter. Tell Power Automate which field to populate using these parameters.

  • Set text – Field
  • Get field by – Label
  • Label – User



Add another Set text on terminal session to fill-in the password.



When the desktop flow runs it the login information will be entered into the fields as shown below. The final step is to press the Enter key to submit the user/password.



Use the Send key to terminal session action to press the Transmit button. Transmit is the same as pressing the Enter key.



The desktop flow actions to log into AS400 should look like this.

The AS400 main menu will appear after we login. Next, we want to navigate to option 3. General system tasks.



It is important to make sure the main menu has loaded before we start entering keystrokes. Use the Wait for text on terminal session action and fill the Text to wait for parameter with the words Main Menu. Select Screen as the Wait for text location.



Then we will type a command into the AS400 line. Add a Set text on terminal session action. Use the Text “3” to choose the 3rd menu option.

The command line does not have a label. So we’ll Set Text based on the Field and Position of the cursor. The command line starts at Row 20 and Column 7.



Finally, add a Send key to terminal session action to Transmit the command.



Power Automate Desktop will now select 3. General system tasks and navigate to the next screen.



The Power Automate Desktop code the navigate to the main menu looks like this. Our desktop flow to login to AS400 and open the menu is now completed.




Alternate: Open An AS400 Terminal Session (Micro Focus Reflection)

The provider Micro Focus Reflection can also open an AS400 terminal session but the setup steps are slightly different. As a prerequisite, Application Programmer Interface must be enabled for Power Automate Desktop terminal emulation to work. Turn it on in the Reflection settings menu.



Setup the Open terminal session action as shown below.

  • Select the provider Micro Focus Reflection
  • Choose the installation path C:\Program Files (x86)\Micro Focus\Reflection
  • Pick the host type will be IBM 5250. Host address
  • Enter your host address and port
  • Enable the attach to running session setting.



Now Power Automate Desktop can open AS400 by running these 3 actions.





Questions?

If you have any questions about How To Run AS400 With Power Automate Desktop Terminal Actions please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest
2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Ruben Nicolas
Ruben Nicolas
1 month ago

Hi Matt, do we nees a premium license to do this?