Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Accessing flat files on the mainframe

by Fuism (Beadle)
on Sep 02, 2004 at 21:47 UTC ( [id://388130]=perlquestion: print w/replies, xml ) Need Help??

Fuism has asked for the wisdom of the Perl Monks concerning the following question:

I have copies of the queries used to grab data from these flat files. I also have access to the IBM mainframe(I have no idea what version or type) using Power Term in order to run these queries. I can also FTP to the mainframe and grab my datasets created by these queries. My question is how do I access these flat files using a perl script to run these queries?
Can I use DBD and DBI to hit these flat files using the access I have available? Any help from you Perl gurus out there would be greatly appreciated. Thank you for your time and efforts.
Sincerely, Fuism

Replies are listed 'Best First'.
Re: Accessing flat files on the mainframe
by DamnDirtyApe (Curate) on Sep 02, 2004 at 21:57 UTC
    My question is how do I access these flat files using a perl script to run these queries?

    Depends on the file, but one common approach is:

    open FILE, '<', $filename; while (<FILE>) { # ... do something here ... }
    Can I use DBD and DBI to hit these flat files using the access I have available?

    Possibly. It's tough to give any specific help without knowing what your queries look like, and what the files look like. If you were to post samples both, the value of the responses here will increase substantially.


    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche
      OK guys, heres the information. Some of the data is packed so it doesnt look like a CSV file or anything like that. Supposely some of the packed information are read vertically rather than horizontally. An example of what the file looks like :
        WHEEEE!

        If you have a SAS proc to access your data, then change the Proc Print statements to put the packed-decimal fields out in zoned-decimal (printable character) format. That solves one of your biggest issues right off the top -- If you have a MainFrame format problem, use MainFrame re-formatting tools before you grab the file. Now use your favorite FTP to get the file over from the Big Iron World into the small iron world.

        Procede to read the resultant file as the normal string-of-characters that Unix expects. You will have to use substr or something simular to break up the string into records (unless you remembered to have the SAS code write the new lines for you...) and then attack each record with substr and crow-bar to get the fields pulled out of the record correctly.

        Wheee what fun. (And don't even think about trying to create a MainFrame readable record on your Unix system. Send SAS a flat file and have it rebuild the pack-decimal for you.)

        (Personally, I do the whole problem over on the MF using PL/1. But.)

        ----
        I Go Back to Sleep, Now.

        OGB

Re: Accessing flat files on the mainframe
by jZed (Prior) on Sep 02, 2004 at 22:42 UTC
    DBD::AnyData works with many types of flatfiles including CSV, fixed length, XML, etc. If you have LWP installed, DBD::AnyData can use it to access flatfiles through either FTP or HTTP transparently. You just specify the URL of the file when you load the table, then use DBI and SQL on it as though it were a local database table.
Re: Accessing flat files on the mainframe
by jbodoni (Monk) on Sep 02, 2004 at 22:12 UTC
    We have an IBM 825 iSeries (aka an AS/400) where I work.

    I regularly access DB2 files on it by using the ODBC driver that comes with iSeries Access (aka Client Access). It's an optional component, so you might to install it... and of course, this is assum taking for granted that your environment is at least a little bit like mine.

    I'm running Windows XP and ActiveState. Using DBI and the ODBC driver, I'm able to retrieve the data with normal SQL statements, and it's great!

    John

Re: Accessing flat files on the mainframe
by VSarkiss (Monsignor) on Sep 02, 2004 at 21:56 UTC

    If these are flat files and you have access to the host via FTP, your best bet is to use Net::FTP or something similar.

    If they're not truly flat files (such as VSAM datasets or libraries or some such), there's not much point in copying them off the mainframe because you won't be able to do anything with them anyway. To my knowledge DBI doesn't support any type of hierarchical data store -- although I haven't checked.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://388130]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found