For most automations involving text adapters (AS400 or other terminal sessions, AKA "green screens"), you will need to create an automation that returns you to a known screen. The easiest way to do this is with a combination of the NewScreenShowing event and a script to get the screen you are currently on. In the example below, I have a forLoop that will try up to 20 times to navigate back to the scrBaseMenuOption screen. The 20 figure is arbitrary and yours may be lesser of greater depending on how many screens deep you may get into an application. The necessary script is below along with an image of the automation and the references required for the script.
Parameters: OpenSpan.Adapters.Text.Host.IBM.PComm.WinHllapi.PCommWinHllapiAdapter adapter, out OpenSpan.Adapters.Text.Automation.Screen screen
screen = null;
if(adapter != null)
foreach(OpenSpan.Adapters.IControl ctrl in adapter.Controls)
screen = ctrl as OpenSpan.Adapters.Text.Automation.Screen;