PDA

View Full Version : Read a Mainframe Dataset (PDS) using VBA



Kuttralakani
05-12-2009, 08:32 AM
Hi All,

I need an idea how to write a VBA that will read the content of the Mainframe Dataset (PDS).

I can able to access the tables available in DB2 on the specified Database using IBM Data Provider from VBA. So, I guess there should be a solution to read a PDS content using VBA.

Your quick response will be appreciated.

Thanks in advance.


Regards,
Kuttralakani

stanl
05-13-2009, 03:52 AM
I assume you are using an ADO Connection with the DB2 Driver. What does your SELECT statement look like - meaning are you accessing the PDS as a whole, or specific fields in a data subset? Stan

Kuttralakani
05-14-2009, 05:02 AM
I assume you are using an ADO Connection with the DB2 Driver. What does your SELECT statement look like - meaning are you accessing the PDS as a whole, or specific fields in a data subset? Stan
Hi Stan,

Currently, I have hard-coded the DB2 SQL inside the macro itself. And I use ADO Connection to connect with DB2 (As you said).

Now I wish to have the DB2 SQL in a PDS. So that I will read the SQL from the PDS and imported into VBA to run it.

Hope I have answered your question. Let me know if you need any info.

Kuttralakani
05-22-2009, 02:16 PM
Hi All,

I need an idea how to write a VBA that will read the content of the Mainframe Dataset (PDS).

I can able to access the tables available in DB2 on the specified Database using IBM Data Provider from VBA. So, I guess there should be a solution to read a PDS content using VBA.

Your quick response will be appreciated.

Thanks in advance.

Kenneth Hobs
05-22-2009, 04:30 PM
Not sure how the pc side would talk to the mainframe side. I used to use a pc program to download or upload a file.

Once you get the pds file to the pc side, one of several methods should work. I would have to have an example to test to be sure.
e.g.

Sub t()
Dim s As String
s = TXTStr("C:\myfiles\wp\ken.txt")
End Sub
Function TXTStr(filePath As String) As String

Dim str As String, hFile As Integer

If Dir(filePath) = "" Then
TXTStr = "NA"
Exit Function
End If

hFile = FreeFile
Open filePath For Binary Access Read As #hFile
str = Input(LOF(hFile), hFile)
Close hFile

TXTStr = str
End Function

amnamansoor
04-01-2012, 04:41 PM
Mainframes are powerful machines now a days.
so for reading mainframe dataset using VBA we have to go through from DB2 which can easily access to Dataset.
VBA uses the databases to hold data in mainframes and for this purpose it uses COBOL and JCL.
so simply to read dataset by VBA you should have command on COBOL.

asifkhan
05-25-2012, 02:15 AM
Data that could have resided on a mainfram or in another PC program. The code in Listing BC3-2 places the contents of the Word List table of the recodset.