VSAM question: can I read in reverse key sequence? 
Author Message
 VSAM question: can I read in reverse key sequence?

I work on a PL1 application that runs on both the mainframe (MVS) and PC
(both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
the mainframe it's VSAM (a KSDS).

In the enhancement I'm working on now, while examining a given database
record, the program is required to look at the *previous* record in key
sequence, i.e., with the next *lower* key.

With Btrieve this is no big deal, already have it worked out. However,
I've been unable to find any documentation to suggest that it can be
done with a VSAM dataset; and even more to the point, I have yet to find
any PL1 option or attribute by which it could be done.

Yet it seems a reasonable enough task, & it's hard to believe that
venerable VSM hasn't caught up with the [upstart] PC databases in this
respect.

Does anyone have a clue for me about this? On the answer hangs the
future of my enhancement, and perhaps the product itself, on the MVS
platform, form which for sentimental reasons (it's paid my bills for
years!) I would hate to see it disappear. (A few customers would be
disappointed, as well.)



Sun, 16 Jul 2000 03:00:00 GMT  
 VSAM question: can I read in reverse key sequence?

Quote:

> In the enhancement I'm working on now, while examining a given database
> record, the program is required to look at the *previous* record in key
> sequence, i.e., with the next *lower* key.

I have no access to VSAM, but I remember that there is an ENVIRONMENT
option BKWD which allows to read a VSAM dataset backwards.

If you need to step backwards dynamically I think you have to store the
needed RBAs (given by KEYTO) and use it in the KEY option.

Hope that helps!

/*---------------------------------------------------------------*/
     /* Eberhard Sturm                   Tel: +49-251-83-31679 (NEU!) */
    /* Universitaetsrechenzentrum       Fax: +49-251-83-31555 (NEU!) */

  /* D-48149 Muenster                                  "TEAM PL/I" */
 /* http://www.uni-muenster.de/URZ/Mitarbeiter/EberhardSturm.html */
/*---------------------------------------------------------------*/



Sun, 16 Jul 2000 03:00:00 GMT  
 VSAM question: can I read in reverse key sequence?

On Wednesday, 98/01/28, David Gascon wrote to All about "VSAM question: can
I read" as follows:

DG> I work on a PL1 application that runs on both the mainframe (MVS) and PC
DG> (both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
DG> the mainframe it's VSAM (a KSDS).
DG>
DG> In the enhancement I'm working on now, while examining a given database
DG> record, the program is required to look at the *previous* record in key
DG> sequence, i.e., with the next *lower* key.
DG>
DG> With Btrieve this is no big deal, already have it worked out. However,
DG> I've been unable to find any documentation to suggest that it can be
DG> done with a VSAM dataset; and even more to the point, I have yet to find
DG> any PL1 option or attribute by which it could be done.
DG>
DG> Yet it seems a reasonable enough task, & it's hard to believe that
DG> venerable VSM hasn't caught up with the [upstart] PC databases in this
DG> respect.

How many solutions would you like?

VSAM has been able to do this for over 20 years.

I'm not sure how fully you have stated what you are trying to do. You have
not said whether you always need to move backwards through the dataset or
sometimes backwards and sometimes forwards.

Given that you use a direct read to set the position, simply declaring
ENV(BKWD) will allow you to move backwards on all sequential reads. E.g.

     READ FILE(VSAMDS) INTO(Main_rec) KEY(Key_value);

     READ FILE(VSAMDS) INTO(Prev_rec);

The above will read the record of the given key into Main_rec and its
predecessor into Prev_rec.

If you need to toggle between forward and backward sequence then you will
need:
  to use assembler to toggle the forward/backward flags in RPL's;
  to use 2 PL/I files for the same physical dataset;
  to use an ESDS with an AIX and RBA pointers to forward and
    backward records (can you say HIDAM?).

Be aware that a KSDS is really for the intellectually lazy. There are much
slicker ways to access VSAM datasets using ESDS or RRDS clusters.

Regards

Dave
<Team PL/I>

 * KWQ/2 1.2i * I have a 286... Can I park in the handicapped space?



Sun, 16 Jul 2000 03:00:00 GMT  
 VSAM question: can I read in reverse key sequence?

Quote:

> On Wednesday, 98/01/28, David Gascon wrote to All about "VSAM question: can
> I read" as follows:

> DG> I work on a PL1 application that runs on both the mainframe (MVS) and PC
> DG> (both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
> DG> the mainframe it's VSAM (a KSDS).
> DG>
> DG> In the enhancement I'm working on now, while examining a given database
> DG> record, the program is required to look at the *previous* record in key
> DG> sequence, i.e., with the next *lower* key.
> DG>
> DG> With Btrieve this is no big deal, already have it worked out. However,
> DG> I've been unable to find any documentation to suggest that it can be
> DG> done with a VSAM dataset; and even more to the point, I have yet to find
> DG> any PL1 option or attribute by which it could be done.
> DG>
> DG> Yet it seems a reasonable enough task, & it's hard to believe that
> DG> venerable VSM hasn't caught up with the [upstart] PC databases in this
> DG> respect.

> How many solutions would you like?

> VSAM has been able to do this for over 20 years.

I think that's about how long since I've seen a new reference manual!
(Tried in vain to find one in BookManager, can't stand that thing!) My
PL1 Lang. Ref. doesn't mention it - but then, my most recent manuals are
for OS2 & NT compilers, & they don't tend to trouble about VSAM.

Quote:
> I'm not sure how fully you have stated what you are trying to do. You have
> not said whether you always need to move backwards through the dataset or
> sometimes backwards and sometimes forwards.

Keyed read to set position, then sequential reads forward until end of a
series is reached. However, under certain circumstances I have to look
backward, maybe after the keyed read, maybe after one of the sequentials
(at the look-back point, I don't necessarily know which).

- Show quoted text -

Quote:
> Given that you use a direct read to set the position, simply declaring
> ENV(BKWD) will allow you to move backwards on all sequential reads. E.g.

>      READ FILE(VSAMDS) INTO(Main_rec) KEY(Key_value);

>      READ FILE(VSAMDS) INTO(Prev_rec);

> The above will read the record of the given key into Main_rec and its
> predecessor into Prev_rec.

> If you need to toggle between forward and backward sequence then you will
> need:
>   to use assembler to toggle the forward/backward flags in RPL's;
>   to use 2 PL/I files for the same physical dataset;
>   to use an ESDS with an AIX and RBA pointers to forward and
>     backward records (can you say HIDAM?).

I assume the above is an OR. The second option looks promising.

Quote:
> Be aware that a KSDS is really for the intellectually lazy. There are much
> slicker ways to access VSAM datasets using ESDS or RRDS clusters.

Intellectually lazy, or just under the deadline gun? In any event, this
application (quite large, *many* programs involved) has been using a
KSDS for a long time (16 or more years, pretty long in the
application-software game, I think), and I don't think I'm going to be
the one to revolutionize it!

Anyway, there's a possibility the product will quit the mainframe in the
next couple of years and use Btrieve exclusively, in which case the
question will be moot.

But with your tips, perhaps VSAM has a fighting chance, at least for the
short run. Thanks for the info!

Quote:

> Regards

> Dave
> <Team PL/I>

>  * KWQ/2 1.2i * I have a 286... Can I park in the handicapped space?

Cheers,

David



Sun, 16 Jul 2000 03:00:00 GMT  
 VSAM question: can I read in reverse key sequence?

Quote:

>I work on a PL1 application that runs on both the mainframe (MVS) and PC
>(both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
>the mainframe it's VSAM (a KSDS).
>In the enhancement I'm working on now, while examining a given database
>record, the program is required to look at the *previous* record in key
>sequence, i.e., with the next *lower* key.
>With Btrieve this is no big deal, already have it worked out. However,
>I've been unable to find any documentation to suggest that it can be
>done with a VSAM dataset; and even more to the point, I have yet to find
>any PL1 option or attribute by which it could be done.
>Yet it seems a reasonable enough task, & it's hard to believe that
>venerable VSM hasn't caught up with the [upstart] PC databases in this
>respect.
>Does anyone have a clue for me about this? On the answer hangs the
>future of my enhancement, and perhaps the product itself, on the MVS
>platform, form which for sentimental reasons (it's paid my bills for
>years!) I would hate to see it disappear. (A few customers would be
>disappointed, as well.)

David
Specifying Bkwd will read an entire file in reverse sequence.
If you are going forward and then want to step back -it won't help.
Your choices are either to store the records until you are certain
that you won't need them (use allocate)
or store the key(s) and later re-read the record.
I have examples of both - somewhere.
Clement McGann


Mon, 17 Jul 2000 03:00:00 GMT  
 VSAM question: can I read in reverse key sequence?

Quote:


> >I work on a PL1 application that runs on both the mainframe (MVS) and PC
> >(both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
> >the mainframe it's VSAM (a KSDS).
> >In the enhancement I'm working on now, while examining a given database
> >record, the program is required to look at the *previous* record in key
> >sequence, i.e., with the next *lower* key.
> >With Btrieve this is no big deal, already have it worked out. However,
> >I've been unable to find any documentation to suggest that it can be
> >done with a VSAM dataset; and even more to the point, I have yet to find
> >any PL1 option or attribute by which it could be done.
> >Yet it seems a reasonable enough task, & it's hard to believe that
> >venerable VSM hasn't caught up with the [upstart] PC databases in this
> >respect.
> >Does anyone have a clue for me about this? On the answer hangs the
> >future of my enhancement, and perhaps the product itself, on the MVS
> >platform, form which for sentimental reasons (it's paid my bills for
> >years!) I would hate to see it disappear. (A few customers would be
> >disappointed, as well.)
> David
> Specifying Bkwd will read an entire file in reverse sequence.
> If you are going forward and then want to step back -it won't help.
> Your choices are either to store the records until you are certain
> that you won't need them (use allocate)
> or store the key(s) and later re-read the record.
> I have examples of both - somewhere.
> Clement McGann

I think something on this order will be the way I end up going (the
inspiration having struck me after reviewing suggestions in this group,
and banging at the code a bit more). I think storing the records will
work for all the cases except trying to go back for the record before
the *first* one I read (with a key) before reading the others forward --
and that will be a sufficiently rare case in this application that we
are going to dismiss it on the mainframe side, and instruct the users
that this will only be possible with the PC product (we ship both to our
maintenance clients). Isn't user documentation wonderful?


Mon, 17 Jul 2000 03:00:00 GMT  
 VSAM question: can I read in reverse key sequence?

Quote:

> On Wednesday, 98/01/28, David Gascon wrote to All about "VSAM question: can
> I read" as follows:

> DG> I work on a PL1 application that runs on both the mainframe (MVS) and PC
> DG> (both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
> DG> the mainframe it's VSAM (a KSDS).
> DG>
> DG> In the enhancement I'm working on now, while examining a given database
> DG> record, the program is required to look at the *previous* record in key
> DG> sequence, i.e., with the next *lower* key.
> DG>

And just to add to Dave's answer, another solution may be to have two
file declares for the same VSAM file. If you know the key of the
additional record you want to read, you can do so by reading a different
DD NAME but which is associated with the same DSNAME.

Did I make that clear?

Hth
Pjk  

x



Tue, 18 Jul 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Keyed-Sequence Reads

2. Help: VSAM Invalid Key Question

3. Need a key sequence for keys F8, SHIFT-F10, and F12 sending through Expect

4. Reverse-key order browse

5. read next after reading record via another key

6. Filter -vs- Key.Sequence

7. to xt's from KEY sequences

8. Read from a empty VSAM file

9. Read from a empty VSAM file

10. CICS coding..read a VSAM file

11. Set(Key,Key) Question

12. set(key, key) question

 

 
Powered by phpBB® Forum Software