Question on Reading a PDS in a Cobol Program

Post anything related to mainframes (IBM & UNISYS) if not fit in any of the above categories

Question on Reading a PDS in a Cobol Program

Postby Gururao78 » Wed Sep 30, 2009 2:56 am

Hi I am writing a COBOL pgm to Read a PDS and fetch the member names inside the PDS for further comparision. But when I am trying to do that. I ma facing some problem.

The PDS I am trying to read is of 80 bytes -- IT0007.PMSTB.PI.TEST
Management class . . : MC3
Storage class . . . : TSOLIB
Volume serial . . . : BALP2C
Device type . . . . : 3390
Data class . . . . . : DC4
Organization . . . : PO
Record format . . . : FB
Record length . . . : 80
Block size . . . . : 32720
1st extent cylinders: 10
Secondary cylinders : 50
Data set name type : LIBRARY

When you browse thr Dataset, you see the follwing members :

VIEW IT0007.PMSTB.PI.TEST Row 00001 of 00003
Command ===> Scroll ===> CSR
Name Prompt Size Created Changed ID
_________ C0003001 0 2009/02/26 2009/02/26 12:47:00 BSQBOC
_________ C0003002 0 2009/02/26 2009/02/26 12:47:00 BSQBOC
_________ C0003003 0 2009/02/26 2009/02/26 12:47:00 BSQBOC

When I am trying to read the PDS in my Pgm, The first read gives me the following result :
ðC0003001 " " å BSQBOC C0003002 " " å BSQB

I would have expected the first read giving me the result:
ðC0003001 " " å BSQBOC

and second read should give the result:
ðC0003002 " " å BSQBOC

Can someone help me with this and let me know if there is any different approach to read the above mentioned PDS so that I get my desired results.

Posts: 9
Joined: Mon Sep 28, 2009 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Question on Reading a PDS in a Cobol Program


Re: Question on Reading a PDS in a Cobol Program

Postby dick scherrer » Wed Sep 30, 2009 3:24 am


How does the code know which member to read? What is the DD statement for this input file?

I suspect that this is not a good exercise for learning. . . COBOL has no built-in function to do what i believe you want.

To read one member, specify the member name on the DD statement. If there are to be multiple members processed, concatenate them behind the DD statement for the first member.
Hope this helps,
User avatar
dick scherrer
Global moderator
Posts: 6308
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 90 times

Re: Question on Reading a PDS in a Cobol Program

Postby MrSpock » Wed Sep 30, 2009 5:00 pm

Look here at the READPDS program. I think that may be what you want.
User avatar
Global moderator
Posts: 811
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Question on Reading a PDS in a Cobol Program

Postby enrico-sorichetti » Wed Sep 30, 2009 11:46 pm

it would be nice if You explained exactly what You are trying to achieve ...
what You are getting is the directory content
a PDS directory can be read as a sequential file with a LRECL of 256,
but then You would have to do the deblocking to find the info of each member by Yourself,
( probably by using reference modification with a lot of redefines )

the info for a member entry is a made up of
12 bytes of fixed info - 3 bytes for the TTR, 8 bytes for the member name, 1 byte for flags and user data length
( the byte flag is divided into 3 bits of flag an 5 bits for the user data length divided by two )

managing all of this in cobol is not the best approach , so please reply to the request in line 1
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
Global moderator
Posts: 2490
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 119 times

Return to All other Mainframe Topics


  • Related topics
    Last post