9
Connecting to Bluezone/Attachmate mainframe screens using excel VBA code 9-Feb-2015 Author Name: Chaithra HK

Connecting to Attachmate_Bluezone Using Excel VBA

Embed Size (px)

DESCRIPTION

This is very useful for connection between IBM Bluezone terminal and excel sheet.

Citation preview

Page 1: Connecting to Attachmate_Bluezone Using Excel VBA

 

 

Connecting to Bluezone/Attachmate mainframe screens using excel VBA code

9-Feb-2015

Author Name: Chaithra HK

Page 2: Connecting to Attachmate_Bluezone Using Excel VBA

  

 2 

 

 

 

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.

Page 3: Connecting to Attachmate_Bluezone Using Excel VBA

  

 3 

 

Table of Content 

1.  Introduction .............................................................................................................................................................. 4 

1.1  Purpose ..............................................................................................................................................................  

1.2  Description .........................................................................................................................................................  

3.  Steps to connect to Attachmate/BlueZone using excel VBA code ........................................................................... 4 

4.  Sample code .............................................................................................................................................................. 6 

4.  Basic Functions to interact between mainframe and VBA ....................................................................................... 7 

5.  Conclusion ................................................................................................................................................................. 8 

6.  Acknowledgements ................................................................................................................................................... 8 

7.  References ................................................................................................................................................................ 8

   

Page 4: Connecting to Attachmate_Bluezone Using Excel VBA

  

 4 

 

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 macro’s 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.

Page 5: Connecting to Attachmate_Bluezone Using Excel VBA

  

 5 

 

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.

Page 6: Connecting to Attachmate_Bluezone Using Excel VBA

  

 6 

 

 

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”)

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 

Page 7: Connecting to Attachmate_Bluezone Using Excel VBA

  

 7 

 

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

4.2. WaitHostQuiet:

Waits for the specified amount of time to elapse. The NUMBER is in milliseconds (i.e. 3000 = 3 seconds).

Syntax: Session.Screen.WaitHostQuiet (SettleTime)  

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

4.3. MoveTo

Used to move the cursor to a specific location on the screen. 

Syntax: Session.Screen.MoveTo ROW#, COL#

Example: Row = 11

Col = 76 

Session.Screen.MoveTo 11, 76  

4.4. GetString

Used to get data from the Attachmate/Bluezone mainframe screen. This function will store the data in a 

variable for later use. The system should be told about the location by row, column and how many 

characters should be returned (i.e. the length of the STRING).

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)

Page 8: Connecting to Attachmate_Bluezone Using Excel VBA

  

 8 

 

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.

Page 9: Connecting to Attachmate_Bluezone Using Excel VBA

  

Contact

For more information, contact [email protected](Email Id of ISU)

 

About Tata Consultancy Services (TCS) 

Tata Consultancy Services is an IT services, consulting and business solutions 

organization that delivers real results to global business, ensuring a level of certainty no 

other firm can match. TCS offers a consulting‐led, integrated portfolio of IT and IT‐

enabled infrastructure, engineering and assurance services. This is delivered through its 

unique Global Network Delivery ModelTM, recognized as the benchmark of excellence in 

software development. A part of the Tata Group, India’s largest industrial conglomerate, 

TCS has a global footprint and is listed on the National Stock Exchange and Bombay 

Stock Exchange in India. 

For more information, visit us at www.tcs.com. 

 

IT Services 

Business Solutions 

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

Thank You