Jump to content
Neutro

AS400 tasks automation

Recommended Posts

IErrors

This is great -  It's cool to see someone else interested in AS400 automation!

A few years ago I developed an application for my employer that automated iSeries and wrote a massive library to operate on these PCOMM classes. I found that using the AutScreenDesc class was a very reliable way of waiting for a screen by first describing it then calling the WaitForScreen() method. Alternatively, the WaitForString() and WaitForStringInRect() methods work just as well.

I also found the SetConnectionByHandle() method was a bit more reliable when dealing with multiple sessions.

I wish I could share the lib, but unfortunately it technically doesn't belong to me :(

Though IBM provides a wealth of knowledge on these classes here and even provide VB example code which makes it super easy to translate into AU3.

  • Like 2

Share this post


Link to post
Share on other sites
ViciousXUSMC

Not sure what I will need this for yet, but  I know I will.

Just got assigned t he AS400 and do not know a thing about it.

First things first, gotta go figure out where to get the PTF's and how to install them.

  • Like 1

Share this post


Link to post
Share on other sites
Neutro

Welcome to the AS400 world :D

PTFs are the windows updates of AS400, so IBM are providing them ;)

Fyi all moderns AS400 are virtual and run on an IBM hypervisior (the same way a VM runs on ESXi), so I recommend you backup your virtual AS400 image before trying anything ;) 

  • Like 1

Share this post


Link to post
Share on other sites
ViciousXUSMC
5 hours ago, Neutro said:

Welcome to the AS400 world :D

PTFs are the windows updates of AS400, so IBM are providing them ;)

Fyi all moderns AS400 are virtual and run on an IBM hypervisior (the same way a VM runs on ESXi), so I recommend you backup your virtual AS400 image before trying anything ;) 

Not ours.  Not one but 2 physical machines :)

and we have a TON of other servers and services that interface it.

Some of those might be virtual, not sure yet.

Edited by ViciousXUSMC

Share this post


Link to post
Share on other sites
Neutro
13 hours ago, ViciousXUSMC said:

Not ours.  Not one but 2 physical machines :)

and we have a TON of other servers and services that interface it.

Some of those might be virtual, not sure yet.

When you have 2 physical machines, 1 is usually dedicated to business operations and the other one to backup/test.

I find it unlikely that your 2 physical machines are not hypervisors. If they are not then your hardware is most likely kinda old ^^

As i told you by PM you should try to contact IBM support :)

Edited by Neutro

Share this post


Link to post
Share on other sites
PhilippeLabarre

Thanks for the information, that is very helpful.

I almost succeed to do what I try to do.

I tried to get screen content using  GetScreen function but I always got errors.

Is it my syntaxe or it's not possible to use that function ?


My code.

global $oOIA = ObjCreate("PCOMM.autECLOIA")
$oOIA.SetconnectionByName("A")

global $oPS = ObjCreate("PCOMM.autECLPS")
$oPS.SetConnectionByName("A")

Global $actualKw

$oPs.GetScreen($actualKw, 51, 9, 18, 50);

MsgBox($MB_SYSTEMMODAL,"Actual Web Keyword", _ArrayDisplay($actualKw))

 

Share this post


Link to post
Share on other sites
PhilippeLabarre

I got what I wanted by using 

$oPs.GetText(9, 18, 50);

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Radiance
      By Radiance
      Hi all,

      this is very specific. I'm an administrator for several IBM i Power mainframe servers that run i5/OS and people use the Client Access Software.
      For now I've been using the Host Access Class Lib in my AutoIt Scripts on Client Access to automate most of my tasks.
      The essential code lines are this:

      After this you can use the methods listed here to remote-control your Client Access session. Much like a macro.

      This worked fine for the Client Access software. Now IBM released their new IBM i Access Client Solutions and I can't get it to work with it.
      Does anyone have any experience with this already by chance?
    • Bennet
      By Bennet
      I'm actually really proud of myself today. I'm always keen on using AutoIT wherever I can, as I've been developing in it since the age of 14 and whenever I meet any new technical staff or developers at the different clients I visit it always gets a mention and a demonstration. So we had a minor problem today at one of our clients, whereby they had an existing Windows Service implemented with a config file but the source-code was missing, which limited the ability of our company to enhance the interface in any way.

      Now considering the fact that I was paid to develop this I will refrain from divulging any company names or "secrets" as, of course, there are clauses in my contract that state that my work belongs to them. I am however a SAP ABAP developer by trade so anything that falls outside of the defined limits of this trade I can technically share, but regardless I'll keep the information limited.

      So the requirement was to pull data from IBM Websphere, write it out to a file and post it into SAP through a custom built RFC. It turned out to be much less complicated than I imagined and through the research on these forums, I had discovered that similar things had been attempted but that nothing concrete had been written for AutoIT specifically (The MQ part, not the SAP part). So without further adieu I present my thinking.

      I started out with the IBM Websphere dll using DllOpen and DllCall. After a few frustrating attempts at creating COM objects through the DLL Call. I finally discovered that there was another dll that I could register using regsrv32. It was called MQAX200.dll

      Once this dll was registered on the system I could access the following piece of code;



      EnvSet("MQSERVER", $iniServer) ;MQ Server Environment Variable $MQSess = ObjCreate("MQAX200.MQSession") $QMgr = ObjCreate("MQAX200.MQQueueManager") $QMgr = $MQSess.AccessQueueManager($iniQM) ;Queue Manager ConsoleWrite("Connected" & @CRLF)
      After this was complete and I successfully tested my connection I added the following to read from MQ;


      $Queue = $QMgr.AccessQueue($iniQueue, 2) ;Queue (2=MQOO_INPUT, 16=MQOO_OUTPUT) While 1 $GetMsg = $MQSess.AccessMessage $GetOptions = $MQSess.AccessGetMessageOptions $Queue.Get($GetMsg, $GetOptions) If $Queue.ReasonCode = 2033 Then ;When there aren't any new messages sleep for 2 seconds. Sleep(2000) Else #EndRegion Accessing MQ #Region Write File $MsgData = $GetMsg.MessageData ....
      I then wrote this out to a file and attempted my SAP connection using the following code;


      Dim $LoggedIn = False $oConnection = $LogonControl.NewConnection $oConnection.System = $System $oConnection.ApplicationServer = $AppServer $oConnection.SystemNumber = $SysNumb $oConnection.User = $User $oConnection.Password = $Password $oConnection.Client = $Client $oConnection.Language = $Language $LoggedIn = $oConnection.Logon(0, True) Return $LoggedIn
      which resulted in failure as the SAP COM object wasn't registered on the system. After attempting to register the correct object without installing SAP GUI, I ended up with a slightly different solution for an executable supplied by SAP called startrfc.exe;


      $foo = Run(@ComSpec & " /c " & $RFCExec & " -3 -h " & $AppServer & " -s " & $SysNumber & " -F " & $RFC & " -u " & $User & " -p " & $Password & " -c " & $Client & " -l " & $Language & " -E FNAME=" & $FilePath & " -E PNAME=" & $Program, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($foo) If @error Then ExitLoop ConsoleWrite($line) $LogFile = FileOpen(StringReplace($FilePath, "\In\","\Logs\"), 2) FileWrite($LogFile, $Line) FileClose($LogFile) FileMove($FilePath, StringReplace($FilePath, "\In\","\Out\")) WEnd While 1 $line = StderrRead($foo) If @error Then ExitLoop ConsoleWrite($line) $ErrFile = FileOpen(StringReplace($FilePath, "\In\","\Errors\E"), 2) FileWrite($ErrFile, $Line) FileClose($ErrFile) FileMove($FilePath, StringReplace($FilePath, "\In\","\Errors\")) WEnd

      One last piece of code that you should keep in mind if you attempt this so that your program doesn't stop when a COM error is returned (MQ returns an error that indicates there is no data available on the queue as you see with the reason code check earlier);


      Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ;Catch COM errors
      In conclusion, I really enjoyed implementing something that'll be used for the foreseeable future at a powerful company and writing it in my favorite language. I hope you find some use in these snippets.

      This will be running as a Windows Service from now on using srvany.exe.
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.