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

I'm hung up with accessing OS390 VSAM files. I've the feeling that I nearly tried everything. I now can open them, read them sequentially and position them to the last line, but the vsamlocate command doesn't want to work. So I can't set the file position to a desired key.
use strict; use warnings; use OS390::Stdio qw( :CONSTANTS :FUNCTIONS ); my $fh = mvsopen("//'FILE.NAME'", "rb") or die $!; my $key = "THIS IS THE KEY"; my $key_ptr = pack( 'P15', $key ); my $ret = vsamlocate( $fh, $key_ptr, 15, KEY_GE ) or die $!;
I don't know why this doesn't work. Is it the key or the file? In principle vsamlocate is only a call of flocate(). Can you help please?

Replies are listed 'Best First'.
Re: OS390 VSAM-files
by BrowserUk (Patriarch) on Jan 09, 2006 at 16:02 UTC

    Is it possible you need to indicate the record format (recfm) and/or blocksize (blksize) when opening a VSAM file before it will allow you to use vsamlocate()?

    See OS390 cookbook for more information.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Maybe but every attempt to pass such a option to mvsopen leads to a dump in vsamlocate. The cookbook was not really helpfull as there's no example of vsamlocate.

      My VSAM-file has VB-blocking and is a KSDS. The key is a hex value.

        Sorry if the information sources were not helpful. I do not have access to big iron, so cannot even begin to try this stuff out. If the module itself was solid, then I might be able to resurrect enough of my memory from the little I did with VSAM under MVS back before the dawn of time to help you--though you seem to have a pretty good handle on it yourself--but if the module itself is flaky, there is pretty much nothing more I can offer.

        It sounds as if your next best option will be to try and contact the modules author, and if that doesn't produce satisfactory results you may be faced with the prospects of trying to:

        1. fix the module yourself.

          You'll need some C skills and a lot of reading on XS to understand what is going on in Studio.xs

        2. Resort to using another language.

          REXX is pretty easy to pick up if you are not already familiar with it, and from my brief look at the IBM documentation links I provided, will support full access to VSAM datasets. And via IBM supplied/tested libraries.

          If you would rather do the bulk of your work in Perl, you could consider using REXX to read/write the datasets and then invoke perl from within the REXX to do the rest. Not elegant, but Perl regex are rather more flexible than PARSE.

        Again, sorry if the information didn't help you solve your problem.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: OS390 VSAM-files
by rinceWind (Monsignor) on Jan 09, 2006 at 15:38 UTC

    You say vsamlocate doesn't want to work. I presume it is throwing an exception viz or die $!. Any chance you could let us know what it is dying with?

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

      Very difficult to say cause I've tested so many versions. The version above gives me a:
      invalid control request: '\071'
      I think this is a problem with the key as I get other error messages when I change the way to pass the key. So what interrests me is if the way I pass the key is OK or if the problem is somehow with the way I open the file (if I have to state something like "rb,recfm=VB" which leads to a dump if I try it that way). And the problem is: There is NO documentation in the internet. The only thing I found is: "noone has tested this till now".
        There is NO documentation in the internet.

        You might find VSAM demystified useful.

        This also


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.