Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End of volume processing

Status
Not open for further replies.

skippy2347

Programmer
Nov 19, 2002
2
US
Does anyone know of a method to process at end of volume. I need to be able to get the last record on the volume and can find no method to do this. and if possible get the volume serial number of the tape being read. I would appreciate any help.
 
Hi Skippy,

If you're talking about MVS/OS390 COBOL, you can use the POINTER facility and "chain" through system control blocks to get both these bits of info. But it's "dangerous", in that these system chains may change over time. It's an unusual but not unheard of occurrence.

Regards, Jack.
 
Hi skippy,

Try this.
Set up a field in working storage that is the same size of your record, and when you get to the 'AT END '
of the file, your last record will be there. If
you want to get the last n records, set up a table with that amount (i.e. 10) of records and keep on moving them down the line (9->10) (8-> 9) etc. and that way you will get the last n recods.

example 1;

77 WS-REC PIC X(150).
READ FILE-IN INTO WS-REC
AT END
ETC ...

example 2:

77 WS-REC-TEMP PIC X(150).
01 WS-REC-TABLE.
05 WS-RECS OCCURS 10 TIMES INDEXED BY REC-IX.
10 WS-REC PIC X(150).

READ FILE-IN INTO WS-REC-TEMP
AT END
.....
PERFORM
VARYING REC-IX FROM 9 BY -1
UNTIL REC-IX < 1
MOVE WS-REC(REC-IX) TO WS-REC(REC-IX + 1)
END-PERFORM

MOVE WS-REC-TEMP TO WS-REC(1)

To get the volume serial number go to 3.4
or from a command line type
listc vol ent('datasetname') or run a batch job with the
IDCAMS program with a listcat statement.

I hope this answers your question.

random acts of kindness is good
for the doer and the whole world

[roll1]
[smile] shloimyb [spin]
[wavey]

 
Hi shlo,

I think what Skip is saying is he has a 5 volume dataset that is read into his pgm and at the end of each volume he wants to get control to do some EOV (not EOF) processing.

At least that's how I interpreted the problem. If he just wants control at EOF, then your solution will work well.

Regards, Jack.
 
That is correct, need to know at end of volume. Purpose is to be able to only mount a selected tape instead of spinning through all 10 volumes if the data i need is on the last one. we have many request jobs that run and they take for ever, trying to shorten the processing time. Thanks
 
Hi Skip,

Doing what you want to do in COBOL gets sticky bordering on impossible. Using IBM's Basic Assembler Language (BAL) is probably the preferred approach. But since most IBM shops frown upon BAL application pgms, you don't have much of a choice.

I'd suggest dropping the idea of finding the last rec on a tape vol and settle for the 1st rec. I'm assuming your tape file is sorted on a field(s) and you want to start processing at that point in the file and end processing when there are no recs remaining with that key, or when the remaining recs in the file have been exhausted.

What I'd propose is a 3 pgm, one utility solution. The utility step would invoke IDCAMS/listcat for the file in question, outputting the listing to a permanent sequential dataset. The listing contains the vol ser #s associated w/the dataset.

The 1st COBOL pgm will use a new COBOL facility called &quot;external variables&quot; that enables a COBOL pgm to &quot;dynamically&quot; allocate a file. You can then OPEN/process/CLOSE the file, and change the vol ser# and repeat the OPEN/process/CLOSE sequence for as many vol ser#s passed to the pgm by the IDCAMS step.

The &quot;process&quot; steps in the sequence would consist of reading the 1st rec on each vol and write its key (for the purposes of this discussion I'll call it the acct#), and it's associated vol ser to a file that's eventually passed to pgm 2.

So now you have a file that contains a rec for each vol ser in the original file and each of those recs contains the vol ser# and the 1st acct# on each vol in the file. Pgm 3 can now read this file to determine what volume contains the the desired acct#.

Once the vol has been determined, the pgm constructs JCL containing a DD stmt that points to the desired tape vol ser and (finally) executes the pgm that finds and processes the acct# on the tape.

The constructed JCL is written to the JES internal reader. Note that the constructed JCL can invoke a cataloged procedure and the vol ser can be a JCL symbolic.

The DD for the internal reader would look something like this:

//yourddn DD SYSOUT=(*,INTRDR)

Your pgm, of course would define a file assigning it to &quot;yourddn&quot; lrecl of 80.

The tricky part of this long winded process is using the &quot;dynamic alloc&quot; facility. I have to admit that I haven't used it myself, but there are many examples of its use.

Ready to give up? :) I wouldn't blame you.

Regards, Jack.


 
Hi again skippy and slade,

I have another suggestion, similar somewhat to slade's
but not using the 'dynamic allocation' since I am not
familiar with that, and I think that if you have a file
that is on multiple volumes and you just use a volume that
is not the first, you will get an error since it's not the first volume of the file. (an open error with a S0C1)

Estimate the amount of records that fit on a volume of the dataset that you are referring to.
(use whatever tape management facility that you have to
find out the amount of blocks that are on a volume, divide
the blocksize by record length for the amount of records
in a block, and records on volume = (recs/block) * blocks).
Estimate the maximum amount of records that would be on the file and allocate that amount of datasets in your jcl
with a descriptive format like dataset.v1, dataset.v2, etc...
In your program set up a counter and write out the estimated amount of records (minus a few for good measure)
to each dataset saving the first key (i.e. acct#) and last key. Display the amount of datasets written with the keys of each.
This will take time to set up, but will make subsequent processing quicker. If you get a lot of key specific requests this might be worthwhile for you. Or if you know the dasd limit for each dataset based on the record count you could set this up to divide up this large multi volume tape dataset into many smaller dasd datasets.

Good luck.

random act of goodness and kindness will
make the world a better place for all.

[roll1]
[spin] shloimyb [spin]
[wavey]

 
Hi shlo,

I should have mentioned this in my solution.

Once the desired volum(s) are identified, they are referenced as unlabled tapes. The DD stmt built to access the volume(s) contains label=(2,blp). This allows the tape vols to be treated individually. The COBOL pgm varies the vol ser each time the FD is reopened.

Regards, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top