Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help automating a CICS mainframe job

Status
Not open for further replies.

accjrf

Technical User
Apr 1, 2004
39
US
we use a CICS host mainframe to do most of our work. I have one screen in paticular that i have people typing in 4 key fields from paper to pull up information and update it. I know how to use a macro that stops and asks for prompts, but that doesnt give me the solution i need. I would like to use Access and VBA code to interact with my mainframe screens so that i can step through one record at a time and save thousands of keystokes my employees make every day. Any way this can be done??
 
Some thoughts which may help ...

I have written something similar - i.e. a 'keystroke simulator' - in VB6. I used:

AppActivate - to activate the target window
SendKeys to simulate key presses

SendKeys can replicate almost any keyboard action, so if you can write a script for your mainframe records along these lines ...
Code:
Display record
Move to field
Type in field
Move to next field
Type in field
etc ...
Save record
then you can put this in a program loop and execute it for each record in the data. It might look something like this:
Code:
'Imaginary code to display next record
SendKeys "{F8}", True
'Move to next field
SendKeys "{Tab}", True
'Type some data
SendKeys "SomeData", True
'Move to next field
SendKeys "{Tab}", True
'Type some data
SendKeys "MoreData", True
'Save record
SendKeys "{F2}", True
SendKeys can also simulate combinations such as Home, End, Shift + End etc so you can copy the contents of a mainframe window field onto the clipboard. You can then test it, change it etc as required.

Combine all this with reading information from a data file, and you have the tools which I think you need. For example:
Code:
Line Input #MyInputFile, stOneLine
AppActivate "My Target Window"
Sendkeys OneLine, True
This code fragment reads a line of text from an input text file, then sends it to the target window using SendKeys

I hope these notes are of some help.


Bob Stubbs
 
Bob, thanks so much for taking time to help me out. Although I have been using VBA code for several years, there is still so much I have to expirement to get correct. You are a little above my head with your code. I cant even get my module to recognize my as400 mainframe rumba screen. I am unsure of my "dim" and "set" statements because i am not sure what application to refer to. If you can continue to help me, I would so greatly appreciate it. Thanks
 
OK ... let's start with some more details of AppActivate ...

This is program equivalent of you clicking the title bar of a window to activate it. The Active Window is the one which receives keyboard input. In your case, you need to activate your mainframe window so you can send keystrokes into it.

AppActivate takes the window title bar text as its parameter. As an example, suppose you open a Notepad window, and create a text file called Test.txt in it. When you look at the notebook window, its title bar will contain:

Test.txt - Notepad

In a Visual Basic program, write this code (for example, in the On Click event of a button):
Code:
AppActivate "Test.txt - Notepad"
SendKeys "Hello World", True
When you click the button, you should see:
-- The Notepad window becomes the active window
-- The message 'Hello World' is typed into the window

AppActivate is very particular - you must get the window text exactly right or it won't work. So, if your mainframe window is called PCOM - Session A for example, you would need to write:
Code:
AppActivate "PCOM - Session A" to switch to it.

Try my Notepad example above - if you can get this working, then you are well on the way to seeing how the SendKeys idea works.  Please come back with any further questions and I'll see if I can help again.



Bob Stubbs
 
Bob...Got it...thanks so much. This should save us a world of time...the use for this code is invaluable to me. Many thanks
 
I use a similar code but one that does not necessitate the use of the AppActivate command. I have created an initialize module that sets the communication between My Access database and the CICS session. This was, regardless of what I am doing, the send.keys command will work, even if I am not in the CICS session as my active window. Here is the code that I use to connect to the mainframe session...


Code:
Public Sub Initialize()
Set MyDB = CurrentDb
Set Rst = MyDB.OpenRecordset("tbl_TSYSImportResults", dbOpenDynaset)

Set auteclpsobj = CreateObject("pcomm.auteclps")
Set auteclconnlist = CreateObject("pcomm.auteclconnlist")
Set autecloia = CreateObject("pcomm.autecloia")
Set auteclps = CreateObject("pcomm.auteclps")
auteclconnlist.Refresh
auteclpsobj.setconnectionbyname (auteclconnlist(1).Name)
autecloia.setconnectionbyname (auteclconnlist(1).Name)
auteclps.setconnectionbyname (auteclconnlist(1).Name)

Call "your function name here"
End Function


Then use the code below to use the sendkeys command to enter your text automatically...


This first line ensures that Access waits until the application is ready to accept input...
Code:
autecloia.waitforinputready
This next line waits for 2 seconds ( or 2000 milliseconds ) before continuing to the next line of code, again to make sure that the code does not run faster than your system can allow...
Code:
auteclps.waitforcursor 5, 31, 2000
This line is your specific sendkeys statement...
Code:
auteclpsobj.SendKeys "[ENTER]"

Also keep in mind that depending on your version of windows, you may need a patch for PCOMM, not sure where you would get that. Our IT department set me up.

I also use this to scrape info from mainframe session screens, and navigate between the screens.

Happy programming...
 
This post is a little late but this might be helpful, I'm in the same boat with CICS and my company uses Attachemate EXTRA! as the CICS interface.

Can data from an Attachemate EXTRA! session screen be captured directly into an MS Access database?
faq181-4619
 
You should check with the vendors of your version of Attachmate Extra!, to see if they have API information available. This might make your job easier, if you can 'talk' directly to the mainframe window. If not, these thoughts may help:

A standard mainframe screen is 25 rows of 80 columns. I'm assuming that the information which you want to 'screen scrape' is in a fixed position, e.g. a Customer ID is always displayed on the third row, starting in column 10, and seven characters long.
Through VBA, you should be able to:

-- Activate the mainframe window
-- Copy the window to the clipboard
-- In Access VBA, use DoCmd.RunCommand acCmdPaste to paste the clipboard into e.g. a text box on a form (set to memo format so it can hold 2,000 characters of text).
-- Now treat this as a string which is exactly 2000 characters long.
-- Work out where each field appears in the string
-- Use Mid$ to extract it into a variable

Example for my Customer ID mentioned earlier:

-- row 3 is characters 161 to 240 of the screen
-- the Customer ID will start at position 170
Code:
strCustomerID = mid$(txtMainframe,170,7)

I hope that these thoughts are of some help.


Bob Stubbs
 
I have used Attachemate EXTRA and it was fantastic! If I remember right it was almost identicle to VBA. I'd look into it if you can.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top