You are on page 1of 16

How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

How to Access Mainframe DB2 Data Through MFE


- Ankit D Agarwal

Here is the method through which we can access Mainframe DB2 Data through MFE by
changing some TCP Port Settings in the XDB Settings for MFE .

Step 1: Create a user ID and password in local XDB of your MFE


Log on to your local DataBase(SYSTEM or DB2L) with SQL Wizard. Now select
'Admin' -> 'Users'. Specify the user ID and password which match those of yours on the
mainframe. Select SuperUser Option in User-Type and Check both options in Security
Options.

Step 2: Create a New XDB Link


XDB Link is the Location pointing to the remote DB2 system. Like presently you may
be using DB2L as your Local Location.
Select 'Options' - 'SQL for DB2' - 'XDB Link'.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Log on with user ID 'INSTALL" and no password.


Click 'Register' button.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Define the following two remote locations.


DB2 on INS1
---------------------
Location name DB2T
Connection Type DRDA(TCP/IP)
Remote HOST DB2T
Port 5002
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Step 3: Update 'Hosts' file to map 'remote HOST' name to the IP addresses of
the mainframe.
Open the file 'C:\WINDOWS\system32\drivers\etc\hosts' with Notepad.
Add the following line to the bottom of this file.

20.17.189.66 DB2T DB2T


Note: You can give any name in place of DB2T and thereafter that will be your
new Location. Also the Ip Address may Differ in different Projects.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC
Step 4: Modify XDB Client setting
Select 'Option' - 'SQL for DB2' - 'Client'.

On 'Connect' tab, enter DB2G or DB2T on 'Locations' and clear out 'AuthID'.

1) This is the initial setup before you made the changes.


How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

2) This is the Setup after you have made the changes.


How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

On 'Security' tab, check 'Client Security' checkbox on if it is not.

Step 5: Log in to the remote DB with SQL Wizard


When 'Connect' dialog comes up, specify DB2G or DB2T on 'Location', your mainframe
user ID and password.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

If the connection is successful, you may see the Transaction dialog. Then you can just
click 'Commit'.

And now you will see the 'Catalog Browser' showing all the databases under DB2T
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC
For Eg : For MLJ Model Office : MCQV1D0A
For John Hancock Model Office : MBQV1D0A

Note: In order to Further exploit this Utility , we can Use Load-Unload Utility in MFE. When
we access the Mainframe Database through MFE , we can only Read the Database (Until and
Unless the User has Right to change the Mainframe Database on his Mainframe Id). Therefore ,
we can change the settings as Explained in this Document, use the Unload Utility to export all
the DB2 Tables on Sequential Datasets.
Thereafter we can again redo the Settings to the original Settings , i.e., we will change the
Location to DB2L (our local Database) and use the Load Utility to Load the DB2 Tables in our
Local Database using the Sequential Datasets created after Unloading .
This way we can replicate the Mainframe Database in our Local region and thus we can carry out
the Testing in Our Local Region using the Mainframe Data and play around with that Data.
The best part of all this is that we are not using any Mainframe CPU Time and thus saving a
lot of Client money :-)

The sample Load-Unload Job for MFE is also mentioned below for your reference. You need to
change the Qualifier and the Table name based on your Project Settings.
In my project : Qualifier : MCQV1D0A ( Mainframe Database Qualifier Name )
MCQV1F0A ( MFE Local Database Qualifier Name)

1. DB2 Unload Job : SYSREC00 is the Dataset Created after running this Job. This Dataset
Contains the Unloaded DB2 Table and this will be used for Loading the DB2 Table in your
Local Region. You can modify the JCL based on your requirements like the parameters CYC
and CDATE can be removed based on the requirement.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

//DB2UNLD JOB (TUXX,,,,,LIFE),'D02236MLJADMIN',


// CLASS=O,MSGCLASS=X,
//* RESTART=DLTE119,
// REGION=0M,
// NOTIFY=&SYSUID
/*JOBPARM S=INS2
//PROCLIB JCLLIB ORDER=(KKPE.MCLPROD.MCMULFDF.PROCLIB,
// KKPE.VBASEKC.MULFDO.PROCLIB)
//JOBLIB INCLUDE MEMBER=JOBPROD
//PLATFORM INCLUDE MEMBER=PLPROD
//*
// SET CYC=PST
// SET CDATE=110306
//*
//*------------------------------------------------------------+
//* PURPOSE: DB2 UNLOAD UTILITY ³
//*------------------------------------------------------------+
//DLTE001 EXEC PGM=IEFBR14
//SYSREC01 DD DSN=&PFLIDO..&CYC..ANNSF.LOAD.D&CDATE,
// DISP=(MOD,DELETE,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
//ANNSF EXEC PGM=IKJEFT01,DYNAMNBR=30
//STEPLIB DD DSN=DNTDB2.DB2T.SDSNLOAD,
// DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSPUNCH DD DUMMY
//SYSREC00 DD DSN=&PFLIDO..&CYC..ANNSF.LOAD.D&CDATE,
// DISP=(,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(15,5),RLSE)
//SYSTSIN DD *
DSN SYSTEM(DB2T)
RUN PROGRAM(DSNTIAUL) PLAN(DSNTIB61) -
LIB('DNTDB2.DB2T.RUNLIB.LOAD')
END
/*
//SYSIN DD *
DB2T.MCQV1D0A.ANNSF
/*

You Need to change the Fields Marked Bold in Red Color based on your Project Settings
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

2. DB2 Load Job : SYSREC00 is the Dataset Created after running Unload Job and thus is
used here to Load the Table. Note here that the Qualifier is changed from MCQV1D0A to
MCQV1F0A. You can modify the JCL based on your requirements like the parameters
CYC and CDATE can be removed based on the requirement.

//DB2LOAD JOB (TUXX,,,,,LIFE),'383236MLJADMIN',


// CLASS=O,MSGCLASS=7,
// REGION=0M,
// NOTIFY=&SYSUID
/*JOBPARM S=INS2
//PROCLIB JCLLIB ORDER=(KKPE.MCLPROD.MCMULFDF.PROCLIB,
// KKPE.VBASEKC.MULFDO.PROCLIB)
//JOBLIB INCLUDE MEMBER=JOBPROD
//PLATFORM INCLUDE MEMBER=PLPROD
//*
// SET CYC=PST
// SET CDATE=110306
//*
//*------------------------------------------------------------+
//* PURPOSE: DB2 LOAD UTILITY 3
//*------------------------------------------------------------+
//ANNSF EXEC PGM=DSNUTILB,
// PARM=(DB2L,'LOAD15ANN'),
// REGION=0M
//STEPLIB DD DSN=DNTDB2.DB2G.SDSNLOAD,DISP=SHR
//ABNLIGNR DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//UTPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
LOAD DATA LOG NO REPLACE INDDN SYSREC00
INTO TABLE MCQV1F0A.ANNSF
/*
//SYSUT1 DD DSN=&&TSYSUT1,
// DISP=(NEW,DELETE),
// SPACE=(CYL,(10,2)),
// UNIT=SYSDA
//SORTOUT DD DSN=&&TSORTOUT,
// DISP=(NEW,DELETE),
// SPACE=(CYL,(10,2)),
// UNIT=SYSDA
//SYSMAP DD DSN=&&TSYSMAP,
// DISP=(NEW,DELETE),
// SPACE=(CYL,(10,2)),
// UNIT=SYSDA
//SYSERR DD DSN=&&TSYSERR,
// DISP=(NEW,DELETE),
// SPACE=(CYL,(10,2),RLSE),
// UNIT=SYSDA
//SYSREC00 DD DSN=&PFLIDO..&CYC..ANNSF.LOAD.D&CDATE,DISP=SHR
//*------------------------------------------------------------+

You Need to change the Fields Marked Bold in Red Color based on your Project Settings

*****************************************************************************
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Import Export Utility of MFE

There is one Import-Export Utility in MFE which we can use if we want to Import or Export the
Data from One Region to another Region or vice versa. Lets See Step by Step the Procedure to
Import the Data of a Table from One Region to Another Region. Let’s say I want to Import the
Data from Table ROLES of Database TUTORIAL to Database DB2L.

Step 1: We will Export the Table Data from the Table ROLES of Database TUTORIAL using
the Export Option in SQL Wizard as shown here :

Once you select the Export Option, there will be several options that you need to select from. A
sample Screen is shown below. Here you need to select the Location from Column Location: ,
here its selected as TUTORIAL. Thereafter you have to select the Database Qualifier from the
Column AuthId: , here I have selected MCQV1F0A and lastly the selection of the Table to be
Exported is to done from the Column Table Name : , here I have selected Table ROLES. Once
you click OK , it will itself take the Default file name to be created and you can change the File
Location as per your requirement in the Column File Name:.

Note: Here the option FORMAT is always to be selected as DSNTIAUL until and unless you
have specific project requirement. DSNTIAUL Format exports the Table preserving its format
and type.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Note: The best part of this Utility is that we can also select the Records which we want to
Export based on some Selection Criterion as I have done. I have selected only those records
from ROLES table where MATER_ID < ‘ 6660050’ . Use the RUN oprion and the data
will be Exported in the File ROLES.DSN.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Step 2: The next Step is to Import the Table in the Database DB2L using the File created after
the Export Step ( ROLES.DSN in my case) . First go to File -> Import option.

Thereafter , select the File you want to use (ROLES.DSN in this case) , the Location (DB2L in
my case) , AuthId ( MCQV1F0A in my case ) and Table (ROLES in my case) . Thus the screen
will look like as shown here after you have made the selections.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Once you select all these options and click OK , you will get the following screen. Click the
RUN option at the Top and the Data will be imported in the Table. Also you have 2 options
1. Create Table ,
2. Replace Data
which you can use based on your requirement like I have used Replace Data Option as is clear
from the Screen Shot.

Note: We can use this Export-Import Utility to get the Data from Mainframe DB2 or to Export
the Data to Mainframe DB2 . For example if you want to get the data from Mainframe DB2
Table .
1. You will have to first change the Client settings as explained earlier and point to the
Mainframe Database.
2. Next you will Export the Table you want in a file ( as we did in ROLES.DSN)
3. Now to have to again change the Client settings and point to your Local Database.
4. Import the Data from the File in the Table in your Local Database.
How to access Mainframe DB2 Through MFE - Ankit D Agarwal CSC

Migrate Utility in MFE


One more Utility that MFE provides to transfer DB2 Data from one region or One Database to
other is MIGRATE Utility. For this utility go to you MFE Project at location
Tools-> SQL for DB2 ->Migrate

This utility also serve the purpose of Migrating Data from one region to another . Through this
utility we can Migrate complete Database in one go by creating Batch Scripts which will
migrate multiple Tables in one go .

*************************** THE END*****************************

You might also like