IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Call IDCAMS in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rochej3

New User


Joined: 02 Aug 2005
Posts: 4

PostPosted: Tue Aug 02, 2005 8:47 pm
Reply with quote

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
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Aug 03, 2005 12:37 am
Reply with quote

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
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Aug 03, 2005 12:42 am
Reply with quote

Any way here is a piece of code through which you can invoke IDCAMS from COBOL, http://www.naspa.com/PDF/2000/0100%20TS%20PDFs/T0001006.pdf
Back to top
View user's profile Send private message
rochej3

New User


Joined: 02 Aug 2005
Posts: 4

PostPosted: Wed Aug 03, 2005 2:10 am
Reply with quote

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
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Aug 03, 2005 2:41 am
Reply with quote

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
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Aug 03, 2005 3:15 am
Reply with quote

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
View user's profile Send private message
rochej3

New User


Joined: 02 Aug 2005
Posts: 4

PostPosted: Wed Aug 03, 2005 3:34 am
Reply with quote

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
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Aug 03, 2005 3:59 am
Reply with quote

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
View user's profile Send private message
rochej3

New User


Joined: 02 Aug 2005
Posts: 4

PostPosted: Wed Aug 03, 2005 10:41 pm
Reply with quote

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
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Aug 03, 2005 11:13 pm
Reply with quote

Yes, u can Release the unused but allocated Space from a VSAM Dasaset using the ALLOCATE Command of IDCAMS, for syntax follow this link
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/FRAMESET/DGT2I230/CCONTENTS?DT=20040628101835
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top