[Editors note: Although Chris discusses an OS/2 EHLLAPI with REXX, the concepts presented here apply to Windows EHLLAPI, using a language like Visual Basic.]
You have a green-screen 5250 emulation session and you have a PC capable of running multiple tasks. Wouldnt it be great if the two could interact such that the power of the PC could be used to automate routine AS/400 tasks and facilitate the creation of new applications?
They can.
A program running in an OS/2 window can actually enter keystrokes into the emulator session and retrieve command output. What makes this interaction possible is the emulator high-level language application programming interface, or EHLLAPI, which is now supported with Client Access/400 Optimized for OS/2.
EHLLAPI (pronounced e-hlappy) has been around for some time in various forms. Versions of Communications Manager, for example, supported EHLLAPI for 5250 emulation sessions. But now, Client Access/400 Optimized for OS/2 bundles Client Access and a version of Communications Manager to provide shared folder access and emulator support all in one neat package. EHLLAPI support is provided with the Communications Manager included in this package.
This article introduces the concepts of EHLLAPI and provides a simple example of an EHLLAPI program written in REXX (a general-purpose, high-level language) to logon to the AS/400. By creating and running this example, youll see that REXX EHLLAPI is a simple-to-implement but powerful tool for interacting with 5250 emulation sessions.
The Many Uses of EHLLAPI
EHLLAPI allows an OS/2 program to interface directly with the emulator session much like a user does. The emulator session makes no distinction between keystrokes entered by the keyboard and those entered programmatically via the EHLLAPI interface. Further, data presented on an emulation screen with which a user interacts is equally available to the OS/2 program to copy, parse, or search.
EHLLAPI uses can be classified into three categories: automation, application, and presentation.
In its simplest operation, EHLLAPI allows tasks to be automated by simply entering keystrokes. In this capacity, EHLLAPI is known as a Program Operator. The OS/2 program, for example, can type an AS/400 command and press the Enter key. The benefit of this simple action is the minimization of errors associated with complex commands, or automating a routine task like signing on. Existing AS/400 application interfaces could easily be simplified or several routine operations consolidated. Anything that can be accomplished manually can be automated with an EHLLAPI program.
Another use of EHLLAPI is to create new applications. Without having to view or interact with the 5250 emulator, a user can automate many tasks like retrieving the current CPU utilization of a target AS/400. These routine or complex operations can be completely hidden from the user by programmatically minimizing the emulator session window while the interaction is proceeding. Figure 1 shows an example of the CPU percentage-used application running in a minimized window. Note the window title in this example has been updated for the minimized window, showing the most recently sampled data.
An OS/2 EHLLAPI program can also access the emulator sessions Presentation Manager window. For example, an emulation session title bar or minimized window caption might normally say something less than descriptive like A - 5250 Session. That can be updated to reflect an active logon or various stages of activity. EHLLAPI also allows you to zoom, unzoom, maximize, minimize, resize, or move emulator windows on your OS/2 desktop.
The REXX Interface
Strictly speaking, EHLLAPI is a programming interface and can be called from COBOL, C, and other compiled languages. However, Client Access/400 Optimized for OS/2 introduces a REXX interface, which makes programming considerably easier.
REXX has been included with OS/2 as far back as V1.2, and has become popular with users as a quick and easy method of creating programs. It uses an intuitive BASIC-like syntax. Many users learn it by simply reviewing existing programs. With a little effort and some help from one of the online references available with OS/2, you can become REXX-proficient in a matter of days.
REXX is also one of the languages available on the AS/400. In 1987, IBM stated that REXX was to be the procedures language for its Systems Application Architecture (SAA), solidifying its future in programming circles. Although the label procedures language might be a blow to its sophistication, it is a powerful language and has quite a following. Several REXX enhancements are also available, including visual programming aids (e.g., pop-ups, lists, buttons), and interfaces to facilitate TCP/IP socket programming and access to FTP functions. Even the argument that REXX is simply an
interpreted language is no longer strictly true, as compilers exist for many of the platforms on which REXX is implemented.
If REXX programming is familiar to you, EHLLAPI programming will be a snap. But even if its brand new to you, you can learn how to start taking advantage of EHLLAPI with REXX in this article. Start with the fully-functioning example and build from there. Dont be shy about running REXX programs youve modified; REXX is great about pin-pointing error messages.
Running a REXX EHLLAPI Program
To run an OS/2 REXX EHLLAPI program, check these items:
Ensure Client Access/400 Optimized for OS/2 is correctly installed.
Include the directory PCOMOS2 in your path. PCOMOS2 contains the actual REXX EHLLAPI DLL that your program loads.
Configure Client Access/400 Optimized for OS/2 appropriately for your environment, ensuring you have at least one 5250 emulation session defined.
Start the emulator session.
Open an OS/2 window and execute your program. As you develop your program, its a good idea to leave it zoomed and in the background behind your OS/2 window, so you can see how your program interacts with the session. You can minimize your emulator window while the REXX EHLLAPI program runs.
Conclusion
If you run the example program following this article, youll have an example of the power of REXX EHLLAPI. You can build on that example to automate laborious tasks you routinely perform on the AS/400, so they can be executed with no more than the double click of your mouse.
References
EHLLAPI Programming Reference, SC31-6163 (for Communications Manager/2) EHLLAPI Programming Reference, S04G-1027 (Extended Services for OS/2) Client Access/400 PC5250 Programmers Guide Client Access/400 RUMBA/400 Tools OS/2 Procedures Language/2 REXX (Available on soft copy in the OS/2 Information folder)
The REXX Language, A Practical Approach to Programming, Michael Cowlishaw (Prentice Hall)
The REXX Language page at IBM Hursley:http://rexx.hursley.ibm.com/ rexx/rexx.htm
Figure 1: Sample EHLLAPI: Retrieve CPU Percentage Used
LATEST COMMENTS
MC Press Online