View previous topic :: View next topic
|
Author |
Message |
rochej3
New User
Joined: 02 Aug 2005 Posts: 4
|
|
|
|
Hello,
I want to call IDCAMS in my Cobol program. Using the LISTCAT command in IDCAMS, I want to retrieve the number of records in a certain file that the program is reading. I want to pass this number back to my Cobol program. How can I go about this?
Any information will be very much appreciated.
Thanks! |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
If I understood u correctly, I dont think u can use the LISTCAT command to get the number of records in a file. U can count the number of records using a simple cobol code, by incrementing a counter every time u read a record but if you want the count from a JCL find here http://ibmmainframes.com/viewtopic.php?t=2235&highlight=record+count |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
Back to top |
|
|
rochej3
New User
Joined: 02 Aug 2005 Posts: 4
|
|
|
|
Thanks for your prompt reply.
I was wrong when I said number of records. What I meant was number of record bytes actually used by the file. I want to use the number to allocate another file eliminating the freespace the 1st file has. Is there a way to do this? |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
By counting the number of records and by knowing the LRECL,BLKSIZE of the file the space can be allocated in BLKS for the dataset. Suppose the LRECL is 10 and the BLKSIZE is 50 then for storing 100 Records u shud allocate 20 BLOCKS
Code: |
No. of Blocks = No. of Records * LRECL / BLKSIZE
SPACE=(50,20,RLSE) |
|
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
U can also allocate the space based on the No. of records(100) & LRECL (10) only as follows for the above example
Code: |
SPACE=(10,100,RLSE),AVGREC=U |
|
|
Back to top |
|
|
rochej3
New User
Joined: 02 Aug 2005 Posts: 4
|
|
|
|
Thanks again!
I think it's better if I give you the logic I'm creating. My program is currently reading file1 and backing up all the contents into file2. File1 has a lot of freespace. What I want to do is get the actual space used by file1 and then use that number to allocate file2. Then, i will delete file1.
Can you recommend anything?
Thanks! :^) |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
rochej3,
Do u want to know how to find the no. of recs in the file ???
U can find the records by using a variety of ways, I wud write a cobol code to do that. Do u need the code??
The actual space occupied by the file1 can be calculated only if u know the no. of records.
U have to find the No. of records to allocate the space more precisely, it can also be done less acurately by allocating a maximum no of cylinders as
SPACE=(CYL,(100,20),RLSE)
and the RLSE parm wud free all the cylinders that are not used when it closes the file. |
|
Back to top |
|
|
rochej3
New User
Joined: 02 Aug 2005 Posts: 4
|
|
|
|
Thanks for that information.
Can I use the RLSE parameter in this logic?
DEFINE CLUSTER (NAME(filename.test1) -
MODEL(filename.test) -
CYLINDERS(25 25 ) ) |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
Back to top |
|
|
|