You are on page 1of 9

Connecting to Bluezone/Attachmate mainframe screens

using excel VBA code


9-Feb-2015
Author Name: Chaithra HK

Confidentiality Statement
Include the confidentiality statement within the box provided. This has to be legally
approved
Confidentiality and Non-Disclosure Notice
The information contained in this document is confidential and proprietary to TATA
Consultancy Services. This information may not be disclosed, duplicated or used for any
other purposes. The information contained in this document may not be released in
whole or in part outside TCS for any purpose without the express written permission of
TATA Consultancy Services.

Tata Code of Conduct


We, in our dealings, are self-regulated by a Code of Conduct as enshrined in the Tata
Code of Conduct. We request your support in helping us adhere to the Code in letter and
spirit. We request that any violation or potential violation of the Code by any person be
promptly brought to the notice of the Local Ethics Counsellor or the Principal Ethics
Counsellor or the CEO of TCS. All communication received in this regard will be treated
and kept as confidential.

TableofContent
1.

Introduction..............................................................................................................................................................4
1.1

Purpose..............................................................................................................................................................

1.2

Description.........................................................................................................................................................

3.

StepstoconnecttoAttachmate/BlueZoneusingexcelVBAcode...........................................................................4

4.

Samplecode..............................................................................................................................................................6

4.

BasicFunctionstointeractbetweenmainframeandVBA.......................................................................................7

5.

Conclusion.................................................................................................................................................................8

6.

Acknowledgements...................................................................................................................................................8

7.

References................................................................................................................................................................8

1. Introduction

1.1

Purpose
The purpose of this document is to provide the user details of how to connect and interact with
Attachmate/BlueZone screens using excel VBA code. This can be used for establishing
Attachmate/BlueZone mainframe connection using excel VBA, then sending values from excel to
mainframe or vice-versa to automate mainframe process.

1.2

Description
Many people interacts with Mainframe numerous times for accessing back end information.
Considering banking application, the customer data (like name, account#, phone#, address,
Account#, services enrolled etc) are accessed using mainframe screens.
The user has to manually operate through mainframe screen to view/update the customer
information. When there are large number of records to be viewed or updated then, excel macros
are very useful.
Attachmate and BlueZone supports to create and run excel macros on them which makes easy to
fetch/update bulk of information in mainframe without manual intervention.

2. Steps to connect to Attachmate/BlueZone using excel VBA code

a) Open a new excel work book.


b) User should have Developer tab enabled to run excel macro.
c) User should have Developer tab enabled to run excel macro.
d) If developer tab not found, go to excel options and enable developer tab. Press ALT+F11 key, to
open excel VBA editor, Visual Basic for Application opens as in below screen.
e) Select the Sheet1 in VBA Project, code window appears as in below screen shot.
f)

Declare the objects for Attachmate/BlueZone system, session, screen as in below sample code.

g) Create Attachmate/BlueZone object as in sample code.


Note: Copy paste the sample code in VBA window, but provide the BlueZone/Attachmate File path
of the system in which the code will be running.
h) Create Attachmate/BlueZone session and screen objects as in sample code.

i)

Error handling has to be taken care if the system/session/screen object creation fails.

j)

Once the session is established successfully, values/strings/keystrokes can be sent from excel
(using VBA editor) to mainframe and values can be fetched from mainframe screen and put it in
excel cells.

k) Run the code. (F8 to run in Debug mode).

3. Sample code
Sample code how to connect to Bluezone/Attachmate.

Sub Main()
Dim HostSettleTime As Integer
HostSettleTime = 300
' Get the main system object
Dim oSessions As Object
Dim oSystem As Object
Dim oScreen As object
Set oSystem = CreateObject("<Bluezone/Extra object>") ' To Create the BlueZone system object BZWhll.WhllObj, for Extra "EXTRA.System"
oSystem.Connect "<Session name>" 'Returns 0 for success; or a non-zero error code.
If (oSystem Is Nothing) Then
MsgBox "Could not create the Bluezone/Extra System object."
Stop ' Stop running macro
End If
If oSystem.Sessions.Count = 0 Then
Set oSession = oSystem.Sessions.Open("<Bluezone/Attachmate file path>") ' If there are no open session, open a new session
Else
Set oSession = oSystem.ActiveSession ' If there is an existing Active session, utilize the same
End If
If (oSession Is Nothing) Then ' check for successful creation of session, if not stop the macro
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If
Set oScreen = oSession.Screen Set the active screen
End Sub

4. Basic Functions to interact between mainframe and VBA

4.1. Sendkeys
Types the desired keys in Extra/BlueZone at the current cursor location. The keys to be sent are a
STRING and should be put in parenthesis (). Special keys listed inside the parenthesis should also
be in (< >).
Syntax: Session.Screen.SendKeys(STRING)

Examples:
Session.Screen.SendKeys ("<Clear>")
Session.Screen.SendKeys ("<Enter>")

4.2.

WaitHostQuiet:
Waitsforthespecifiedamountoftimetoelapse.TheNUMBERisinmilliseconds(i.e.3000=3seconds).
Syntax: Session.Screen.WaitHostQuiet (SettleTime)

Example:
Sess0.Screen.WaitHostQuiet (5000) 5sec.

4.3.

MoveTo
Usedtomovethecursortoaspecificlocationonthescreen.
Syntax:Session.Screen.MoveTo ROW#, COL#
Example:
Row = 11
Col = 76
Session.Screen.MoveTo 11, 76

4.4. GetString
UsedtogetdatafromtheAttachmate/Bluezonemainframescreen.Thisfunctionwillstorethedataina
variableforlateruse.Thesystemshouldbetoldaboutthelocationbyrow,columnandhowmany
charactersshouldbereturned(i.e.thelengthoftheSTRING).
Syntax: VARIABLE_NAME = Session.Screen.GetString (Row, Col, String Length)
Example:
Row = 10
Col = 7
Length = 6 (6 Characters)
var = Session.Screen.GetString (10,7,6)

5. Conclusion
Excel VBA macro provides an easy way to get rid of repeated, time consuming manual process performed
on mainframe screens.
Whenever it is required to search or fetch or update huge amount of data in mainframe, most of those
process can be automated by establishing session between mainframe and excel VBA to automate the
mainframe process.

6. Benefits
By establishing connection between mainframe (Bluezone/Atachmate) and excel application, many
mainframe process can be automated using excel VBA macro.
The main benefits are:
1. Time saving.
2. Reduction in human error.

7. References
[1] Attachmate help documents.
[2] BlueZone help documents.

Thank You

Contact
For more information, contact gsl.cdsfiodg@tcs.com(Email Id of ISU)

AboutTataConsultancyServices(TCS)
TataConsultancyServicesisanITservices,consultingandbusinesssolutions
organizationthatdeliversrealresultstoglobalbusiness,ensuringalevelofcertaintyno
otherfirmcanmatch.TCSoffersaconsultingled,integratedportfolioofITandIT
enabledinfrastructure,engineeringandassuranceservices.Thisisdeliveredthroughits
uniqueGlobalNetworkDeliveryModelTM,recognizedasthebenchmarkofexcellencein
softwaredevelopment.ApartoftheTataGroup,Indiaslargestindustrialconglomerate,
TCShasaglobalfootprintandislistedontheNationalStockExchangeandBombay
StockExchangeinIndia.
Formoreinformation,visitusatwww.tcs.com.

ITServices
BusinessSolutions
Consulting

All content / information present here is the exclusive property of Tata Consultancy Services Limited (TCS). The content /
information contained here is correct at the time of publishing. No material from here may be copied, modified, reproduced,
republished, uploaded, transmitted, posted or distributed in any form without prior written permission from TCS.
Unauthorized use of the content / information appearing here may violate copyright, trademark and other applicable laws,
and could result in criminal or civil penalties. Copyright 2011 Tata Consultancy Services Limited

You might also like