Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

How can I read Vsam files.

by prgeorge (Initiate)
on Dec 26, 2001 at 22:10 UTC ( #134448=perlquestion: print w/ replies, xml ) Need Help??
prgeorge has asked for the wisdom of the Perl Monks concerning the following question:

Hi, All most all the legacy data is in VSAM files.How can I read those. Thanks Roy

Comment on How can I read Vsam files.
Re: How can I read Vsam files.
by Corion (Pope) on Dec 26, 2001 at 22:21 UTC

    My experience with host computers is very limited, but depending on the type of your host you might want to consider the Perl/VMS build and look whether they have VSAM support or not. Other than that, I would try to program a client to the host program that sucks out the data through the 3270 terminal emulation if you have that kind of access to the host.

    There are also some commercial products out there that (claim to) create code to read files from the COBOL PICT statements or copybooks. Many host programs also have the capability to generate lists as output (formerly intended to be printed), maybe you can rework those lists into something to be processed.

    On the other side, the question is why move away from the host at all ? If you manage to achieve a critical mass of COBOL programmers (I guess 10 persons), you can even set up a COBOL shop and do work for other people.

    Disclaimer: I don't find COBOL fun and haven't yet programmed a single line in it, but many host applications are old and do the work they were intended to - so never change a running system.

    Update:As mikeB does point out to me, if you are lucky, you are on OS/390, there is also a Perl build for it, and I'd guess that there is some documented way of getting at VSAM files in some fashion. Also, a google search for Perl 390 VSAM gives http://pvhp.best.vwh.net/os390/OS390-Stdio/OS390-Stdio-0.005.html among others as a result, which discusses the OS390::Stdio module that exports some functions that sound interesting : vsamdelrec,vsamlocate and vsamupdate.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: How can I read Vsam files.
by Juerd (Abbot) on Dec 26, 2001 at 22:21 UTC
    Just like any other file. Open it, read its contents and parse if necessary. Then, close the handle or let perl close it for you.
    I have no idea what VSAM files are, but I don't think the procedure will be any different.
    open (FOO, 'a_VSAM_file'); while (<FOO>){ do_something(); } close FOO;

    What are VSAM files? How do you want the data?

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

      No, no, you can't do this. This is like opening a file used for database storage and blindly reading bytes out of it. VSAM files are structured storage: you can't treat them as byte streams.

      VSAM files are used on IBM and plug-compatible mainframe systems. Generally they implement a hierarchical (rather than relational) database. To read and write data requires an "access method". There are several flavors, depending on how the key and data are structured. Maintaining a VSAM file can seem like a black art sometimes....

      I don't know if Perl for MVS or Perl for 390 will be able to read them at all: that depends on the underlying operating system. But trying to open a dataset (or member thereof) like this will just get you garbage.

        you can't treat them as byte streams.
        Sorry, my bad. I always thought _every_ file was just a string of bytes. And I thought any string of bytes would be parseable somehow.

        Anyway, I've used Google and Google Groups to seek an answer to this question. No-one seems to have bothered to write some perl code to parse this "VSAM" thing. I guess converting the file or parsing it yourself are the only options here.

        2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Re: How can I read Vsam files.
by prgeorge (Initiate) on Dec 27, 2001 at 02:59 UTC
    I am trying to read , vsam files in windows and unix... parsing them will be a herculian task as they contain huge chunks of data ... an average of 10 million records.... I searched in google and all the search engines I know... never found one..... So if any body knows please help.
VSAM, ISAM, DL1 (Re: How can I read Vsam files.)
by Corion (Pope) on Dec 28, 2001 at 18:05 UTC

    After a talk with my local mainframe guru, here is some more information about the concepts of ISAM and VSAM databases.

    ISAM databases are little more than flat (row oriented) files together with an index (file) that gives the start offsets of the differen rows in the data file. Reading and sorting is only possible in one order, the order determined by the index.

    VSAM databases have more than one index and also have the concept of "keys" for the data. You can traverse the data along several axes, as determined by the keys, so you don't have to scan the whole database on each query.

    Both databases have no intrinsic support for hierarchies or joined queries.

    The "successor" to VSAM and ISAM is DL1, a somewhat hierarchical storage of datasets which was famed for its raw speed. After that came DB2 and SQL as the mediator between the programmer and the database (and thus, the interest in different database concepts faded as all DBs are accessible via SQL).

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-07-25 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls