Using Visual Basic for applications DDE with IBM Personal Communications 5.0

Note : IBM Personal Communications was previously known as Client Access

If there is one thing that I try to avoid like the plague, it is the mind numbing repetition of data entry. So last summer when I was confronted with the prospect of having to change several thousand records in my company's billing system, I looked desperately for a way to accomplish the task without having to type each entry. I knew what records I would have to correct and that the same change had to be done to each record. An update query was not an option because of agreements with our software vendor and the potential for causing instability in the system. My only option was to use the existing billing system interface which is a 5250 terminal emulator session using IBM Personal Communications 5.0. I looked first at the macro utility that came with Personal Communications but I could see no way to read from a text file and write to the emulator session. As a stop gap measure I discovered the sendkey statement in Microsoft Visual basic. Using that command, I was able to write a short macro that did most of the job. Unfortunately it was prone to failure if the server response was slow and it required that the emulator session retain the focus while the program was running which meant that the pc could not be used for anything else. For my particular purpose, these script failures were merely a nuisance because the session would stop accepting information and remain on the same screen. I would have to find out what was the last record written and then restart the program where it left off.

At this time it would probably be worth saying that there is no warranty expressed or implied for any code or method on this website and that it would be used at the users own risk.

I managed to finish this project but I knew that at some point there would be another so I experimented with DDE (Dynamic Data Exchange). Fortunately this functionality exists the Personal Communications software. DDE is a method of exchanging information between Windows Applications by establishing a channel between the Client ( Which in my first test was a Word Macro)and a Server which was the 5250 session. The first hurdle was initiating a channel between my Word macro and the session which I was able to do after reading the Emulator Programming Manual from an IBM WebSite and some experimentation.

The syntax is ChannelNumber = DDEInitiatate(IBM525032,SessionA) this returns a channel number that is used for all subsequent commands. I found that by using the set cursor command that each space in the presentation space is numbered starting at the top left hand corner starting at 0 to 1919 for a 24 x 80 screen. After 8 hours of trial and error I discovered the syntax for most of the commands necessary to write DDE scripts in VBA. My first DDE scripts were Word Macros that read from Comma delimited text files and wrote errors to text files. After that it was easy to use Microsoft Access Modules and Tables instead of messing around with text files.

SendKey Script

An example of a DDE Word Macro Script

An Access Visual Basic Module using DDE

A short list of DDE commands and syntax

IBM Technical Manuals for Personal Communications

Home

Hosted by www.Geocities.ws

1