Accessing All members of A PDS Through COBOL program

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS
Subha.siva
Posts: 1
Joined: Fri Nov 09, 2007 8:28 pm
Skillset: Working on Mainframes
Referer: Google

Accessing All members of A PDS Through COBOL program

Postby Subha.siva » Fri Nov 09, 2007 8:39 pm

I would like to know how to access all members of a PDS through a COBOL code.

Thank you

User avatar
MrSpock
Global moderator
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Skillset: REXX, JCL, DFSORT, Syncsort, Axway MFT, Connect:Direct, FTP, SFTP
Referer: ibmmainframes.com
Location: Raleigh NC USA
Contact:

Re: Accessing All members of A PDS Through COBOL program

Postby MrSpock » Sat Nov 10, 2007 12:26 am

You probably will want to use the ISPF LMMLIST Service in your program.

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: Accessing All members of A PDS Through COBOL program

Postby dick scherrer » Sat Nov 10, 2007 10:37 am

Hello Subha.siva and welcome to the forums,

Do you want to read each individual member or do you want to read all of the members as a single file?
Hope this helps,
d.sch.

rcsauce
Posts: 1
Joined: Thu Apr 14, 2011 1:43 am
Skillset: Self taught
Referer: mainframe forum

Re: Accessing All members of A PDS Through COBOL program

Postby rcsauce » Thu Apr 14, 2011 1:53 am

I am creating a simple batch program to call LMMDISP and LMMLIST to see which will be most usefull but I am getting an RC 20. Should the library be allocated in the JCL or do I need to allocate it via LMMINIT or something. Unfortunately, this has to COBOL not rexx or clist. An example would also be really helpfull.
Finally, so I don't have to post again. Where the member information is returned to?

CALL 'ISPLINK' USING BY CONTENT
'LMMDISP '
'CISE.TEST.SOURCE '
'YES '
'DISPLAY'
'CIBPC701'.

IF RETURN-CODE > 0
DISPLAY 'display CALL RC = ' RETURN-CODE.

CALL 'ISPLINK' USING BY CONTENT
'LMMLIST '
'CISE.TEST.SOURCE '
'LIST '
'CIBPC701'
'YES '.

IF RETURN-CODE > 0
DISPLAY 'CALL RC = ' RETURN-CODE.

This is just a proof of concept but I am struggling.

Thanks

User avatar
MrSpock
Global moderator
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Skillset: REXX, JCL, DFSORT, Syncsort, Axway MFT, Connect:Direct, FTP, SFTP
Referer: ibmmainframes.com
Location: Raleigh NC USA
Contact:

Re: Accessing All members of A PDS Through COBOL program

Postby MrSpock » Thu Apr 14, 2011 3:23 am

Like any program that requires ISPF Services, it needs to run from within a TSO/ISPF environment. So, in batch, you need to execute PGM=IKJEFT01, you need to start ISPF and your program (with the ISPSTART command) and you need all of the necessary ISPF Library Definitions in your JCL. Also, from the manual:
You must complete the LMINIT and LMOPEN services before using LMMLIST. Use the LMMLIST FREE option to release the list storage space when it is not needed.


and, as you probably know, the individual member names can be retrieved from the appropriate dialog variable.

I've posted an example COBOL program here as a working example.