Page 1 of 1

Accessing All members of A PDS Through COBOL program

PostPosted: Fri Nov 09, 2007 8:39 pm
by Subha.siva
I would like to know how to access all members of a PDS through a COBOL code.

Thank you

Re: Accessing All members of A PDS Through COBOL program

PostPosted: Sat Nov 10, 2007 12:26 am
by MrSpock
You probably will want to use the ISPF LMMLIST Service in your program.

Re: Accessing All members of A PDS Through COBOL program

PostPosted: Sat Nov 10, 2007 10:37 am
by dick scherrer
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?

Re: Accessing All members of A PDS Through COBOL program

PostPosted: Thu Apr 14, 2011 1:53 am
by rcsauce
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

Re: Accessing All members of A PDS Through COBOL program

PostPosted: Thu Apr 14, 2011 3:23 am
by MrSpock
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.