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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can data from an Attachemate EXTRA! (CICS) session screen be captured directly into an MS Access database?

VBA and Custom Functions

Can data from an Attachemate EXTRA! (CICS) session screen be captured directly into an MS Access database?

by  CautionMP  Posted    (Edited  )
Working in an environment that uses mainly "mainframe" applications that use a terminal emulator to attach to I developed this Class module to scrape data from the session screen which I then have several MS Access routines that I use to normalize the data for importing data into MS Access tables. Because I know that I am not the only developer in this situation I thought I would post this code.

This module will require a reference to the [tt]Attachmate EXTRA! 6.5 Object Library[/tt] to work.

Code:
Option Compare Database
Option Explicit

Dim objExtraSystem As ExtraSystem
Dim objExtraSessions As ExtraSessions
Dim objExtraSession As ExtraSession
Dim objExtraScreen As ExtraScreen
Dim objExtraArea As ExtraArea

Private Sub Class_Initialize()[green]
'Connect to an active Extra instance[/green]
Set objExtraSystem = CreateObject("Extra.System")
If objExtraSystem Is Nothing Then
    MsgBox "Could not create an Extra System Object" & Chr(13) & "because there is no mainframe session open", vbCritical, "Capture Error"
    Exit Sub
End If[green]
'Establish a Sessions collection for objExtraSystem[/green]
Set objExtraSessions = objExtraSystem.Sessions
If objExtraSessions Is Nothing Then
    MsgBox "Could not create an Extra Sessions Object"
    Set objExtraSystem = Nothing
    Exit Sub
End If[green]
'Append objExtraSystem.ActiveSession to objExtraSessions[/green]
Set objExtraSession = objExtraSystem.ActiveSession
If objExtraSession Is Nothing Then
    MsgBox "Could not create an Extra Session object"
    Set objExtraSessions = Nothing
    Set objExtraSystem = Nothing
    Exit Sub
End If
If Not objExtraSession.Visible Then objExtraSession.Visible = True[green]
'Establish a Sreen Object[/green]
Set objExtraScreen = objExtraSession.Screen
If objExtraScreen Is Nothing Then
    MsgBox "Could not create an Extra Screen object"
    Set objExtraSession = Nothing
    Set objExtraSessions = Nothing
    Set objExtraSystem = Nothing
    Exit Sub
End If
End Sub

Private Sub Class_Terminate()
Set objExtraSession = Nothing
Set objExtraSessions = Nothing
Set objExtraSystem = Nothing
End Sub

Public Property Get ConnectionDetails() As String
Dim strTestResult As String
strTestResult = "Extra System Object " & objExtraSystem.Name & Chr(13)
strTestResult = strTestResult & "Extra Sessions Object " & objExtraSessions.Count & Chr(13)
strTestResult = strTestResult & "Extra Session Object " & objExtraSession.FullName
ConnectionDetails = strTestResult
End Property

Public Sub MoveNext()
objExtraScreen.SendKeys ("<Home>")
objExtraScreen.WaitHostQuiet (0)[green]
'In my world F8 scrolls down so [i]1<PF8>[/i] will scroll 1 line[/green]
objExtraScreen.SendKeys ("1<PF8>")
objExtraScreen.WaitHostQuiet (0)
End Sub

Public Property Get CurrentLineText(StartRow As Integer, StartColumn As Integer, StopRow As Integer, StopColumn As Integer) As String
Set objExtraArea = objExtraScreen.Select(StartRow, StartColumn, StopRow, StopColumn)
CurrentLineText = objExtraArea.Value
End Property

Public Property Get SessionActive() As Boolean
If objExtraSystem Is Nothing Then
    SessionActive = False
ElseIf objExtraSessions Is Nothing Then
    SessionActive = False
ElseIf objExtraSession Is Nothing Then
    SessionActive = False
Else
    SessionActive = True
End If
End Property

Public Property Get HostBusy() As Boolean
If objExtraScreen.OIA.XStatus = 5 Then
    HostBusy = True
Else
    HostBusy = False
End If
End Property

This code is still changing (evolving) and if you find this useful I have a series of routines written specifically for the Computer Associates "View" facility for capturing archived reports (primarily from AFS Level III).
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top