MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading PDS Members
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
butta_mvs
Beginner


Joined: 17 Aug 2003
Posts: 22
Topics: 18

PostPosted: Sun Feb 29, 2004 11:08 pm    Post subject: Reading PDS Members Reply with quote

How to read members of a PDS thruogh COBOL pgm.In my cobol iwant to process all members of PDs.How can i do it.

Babu
Back to top
View user's profile Send private message
raggop
Beginner


Joined: 05 Feb 2003
Posts: 19
Topics: 3

PostPosted: Mon Mar 01, 2004 12:13 am    Post subject: Reply with quote

Use an utility like IEBPTPCH to dump the PDS members onto a single dataset and then process that dataset thru your Cobol pgm.

raghu
Back to top
View user's profile Send private message
butta_mvs
Beginner


Joined: 17 Aug 2003
Posts: 22
Topics: 18

PostPosted: Mon Mar 01, 2004 12:10 pm    Post subject: Reply with quote

Hi
actually my question is how to access files dynamically in cobol.
for example say a file consists the list of data files.i want to process all these data files.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Mar 01, 2004 2:03 pm    Post subject: Reply with quote

butta_mvs,

Cobol does not offer any mechanism to read the PDS members directly. As Raghu mention you can flatten the PDS into a sequential file using IEBPTPCH and read it in your cobol pgm. Search for IEBPTPCH in the JCl forum and you will find example JCL to run IEBPTPCH.

The other option is if you know all the PDS member names then you can simply concatenate them to the Input DD as follows:
Code:

//INPUT    DD DSN=YOUR PDS(MEM1),
//            DISP=SHR
//         DD DSN=YOUR PDS(MEM2),
//            DISP=SHR
.....
//         DD DSN=YOUR PDS(MEM'N'),
//            DISP=SHR


You can also use Dynamic allocation which involves a CLOSE and the FREE the DD before ALLOCATE and OPEN.

I have a Cobol program to read PDS members and it is quite complicated. I will post it once I find it in my libraries. Right now I am a little tired from my vacation.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Mon Mar 01, 2004 2:51 pm    Post subject: Reply with quote

While Kolusu rests up from his vacation (don't you hate coming back after an extended period of time off), I'd like to offer some suggestions as to how you might approach this problem and come up with a resolution on your own. Since I'm not a programmer, I can't offer much help with specific COBOL code.

I would consider how I could handle this requirement outside of the COBOL environment. Am I familiar with Assembler? The assembler language can read the PDS directory index and easily perform dynamic allocations to specific members within a PDS all day long. Certainly I can easily obtain a member list in a flat-file format (some suggestions have already been given), or I could consider using ISPF Library Management Services that are specifically designed to deal with PDS files (LMMLIST, LMSTATS, etc.).

For dynamic allocation, I could always call a TSO "ALLOC" command and a TSO "FREE" command from virtually any programming environment. I would consider using the "BPXWDYN" dynamic allocation routine (I believe this was originally developed for use in COBOL).

A few items to consider.
Back to top
View user's profile Send private message
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Thu Mar 04, 2004 9:36 am    Post subject: Reply with quote

Hi

You can issue the LISTDS TSO command from cobol, using the COB2TSO example.

O.
________
Ford Orion specifications


Last edited by ofer71 on Sat Feb 05, 2011 11:16 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Thu Mar 04, 2004 12:18 pm    Post subject: Reply with quote

Butta_mvs,
You can do this real simple in Cobol if using version COBOL for OS/390 & VM 2.2.2
and above. We now have some pretty cool functions PUTENV & GETENV to allocate and process files dynamically. It also handles PDS very well. I had not tested PDS before but for your requirement I coded one and it looked fine to me. You need to go thru little bit of reading about how to use these dynamic call - look into manuals for LE, its hard to cover different scnarios here. i am just pasing you the concept I picked up from an article in NASPA.com.

Basic requirement
Code:

FILE-CONTROL.        (Do not code this DD name in the JCL )                     
     SELECT INPUT-FILE ASSIGN UT-S-DYNFILE
       FILE STATUS IS INPUT-FILE-STATUS.   

01 RC                               PIC 9(9) BINARY.       
01 ADDRESS-POINTER                  POINTER.               
01 FILE-ENVIRONMENT-VARIABLE        PIC X(xx)               
         VALUE 'DYNFILE=DSN(xxx.xxx(xxx) SHR'.
                                                           
01 FILE-ENVIRONMENT-OUT             PIC X(150) VALUE SPACES.
SET ADDRESS-POINTER TO ADDRESS OF             
    FILE-ENVIRONMENT-VARIABLE.                 
                                               
CALL "PUTENV" USING BY VALUE ADDRESS-POINTER   
     RETURNING RC.                             
IF RC NOT = ZERO         
 THEN                   
  DISPLAY 'PUTENV FAILED'
  STOP RUN               
END-IF.               

OPEN INPUT INPUT-FILE.
READ INPUT-FILE (maybe in a loop)
CLOSE INPUT-FILE.
STOP RUN.

Regards
Suresh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Mar 04, 2004 2:21 pm    Post subject: Reply with quote

Butta_mvs,

I completely forgot that I promised to post my cobol code. Sorry about that. Here is a sample cobol code which will read a pds member and just display the contents of the member. You can tweak the program according to your needs.


Code:

IDENTIFICATION DIVISION.                     
PROGRAM-ID.    DYN                           
DATE-COMPILED.                               
ENVIRONMENT DIVISION.                       
CONFIGURATION SECTION.                       
INPUT-OUTPUT SECTION.                       
FILE-CONTROL.                               
                                             
      SELECT IN-PDS                         
      ASSIGN TO INFILE                       
      ORGANIZATION IS SEQUENTIAL.           
                                             
DATA DIVISION.                               
                                             
FILE SECTION.                               
                                             
FD IN-PDS                                   
   RECORDING MODE IS F                       
   LABEL RECORDS ARE STANDARD               
   BLOCK CONTAINS 0 RECORDS                 
   DATA RECORD IS IN-REC.                   
                                             
01 IN-REC                      PIC X(80).   

WORKING-STORAGE SECTION.                                     
                                                             
01 BPXWDYN                     PIC X(08) VALUE 'BPXWDYN'.   
01 S-EOF-FILE                  PIC X(01) VALUE 'N'.         
01 PDS-STRING.                                               
   05 PDS-LENGTH               PIC S9(4) COMP VALUE 100.     
   05 PDS-TEXT                 PIC X(100) VALUE             
   'ALLOC DD(INFILE) DSN(''YOUR.PDS.FILE(MEMBER)'') SHR'.
                                                             
PROCEDURE DIVISION.                                         
                                                             
     CALL BPXWDYN USING PDS-STRING                           
                                                             
     IF RETURN-CODE = ZERO                                   
        DISPLAY 'ALLOCATION OK'                             
     ELSE                                                   
        DISPLAY 'ALLOC FAILED, RETURN-CODE WAS ' RETURN-CODE
        PERFORM INHOUSE-ABEND-ROUTINE
     END-IF                                                 
                                                             
     OPEN INPUT IN-PDS                                       
                                                             
     PERFORM 1000-READ-INFILE UNTIL S-EOF-FILE = 'Y'         
                                                             
     CLOSE IN-PDS                                           
                                                             
     GOBACK.                                                 
                                                             
1000-READ-INFILE.                                           
                                                             
      READ IN-PDS                                           
          AT END                                             
              MOVE 'Y'            TO S-EOF-FILE             
          NOT AT END                                         
              DISPLAY IN-REC                                 
      END-READ                                               
      .                                                     
 



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Jul 29, 2004 2:02 am    Post subject: Reply with quote

Hi,

Can someone list down the pros & cons between the two solutions provided above.

1. The one that uses PUTENV (provided by sureshkumar).
2. The one which uses BPXWDYN (calls to SVC99) (provided by Kolusu).

Which one is efficient, secure, reliable. etc.....

Thanks a lot for the help and guidance,
Phantom
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 29, 2004 4:31 am    Post subject: Reply with quote

Phantom,

On any given day I would prefer BPXWDYN to PUTENV, and I am not telling this because I proposed the solution using BPXWDYN.

some of the reasons as to why I don't prefer PUTENV are:
Code:

1. The call using PUTENV is static. You MUST compile the program with NODYNAM compiler option. If you don't then you will have abends like S0C1

2. The minimum level of COBOL required for the PUTENV to work is COBOL 2.2 and you would also need some Language environment PTF's. The older versions of COBOL do not have the ability to set a pointer to the Address Of a Working-Storage item.

3.The PUTENV by itself is only a stub to the routine in SCEERUN, not a complete module.

4. BPXWDYN on the other hand is a well written program which does not have any of the above listed problems.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Jul 29, 2004 7:40 am    Post subject: Reply with quote

Thanks for the clarification Kolusu,

Regards,
Phantom
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Thu Jul 29, 2004 6:25 pm    Post subject: Reply with quote

You can access a PDS directory from a COBOL pgm. If you provide a DD card using the PDS DSN w/o a member name and open the file in the pgm, you can read the dir blks as a recfm=u PS dataset with a blksize of 256.

Then you can use the BPXWDYN or PUTENV code to process each member found in the directory. I've written COBOL code to do this. If anyone is interested let me know how to contact you and I'll send you a copy.

Regards, Jack.
Back to top
View user's profile Send private message
cobcurious
Beginner


Joined: 04 Oct 2003
Posts: 68
Topics: 25

PostPosted: Wed Sep 01, 2004 8:39 am    Post subject: Reply with quote

Hi slade,
Can u please send me across the code which you have written ?
Thanks
Cobcurious
Back to top
View user's profile Send private message
naveen_mehatak@hotmail.co
Beginner


Joined: 11 Apr 2007
Posts: 6
Topics: 0

PostPosted: Thu Apr 12, 2007 12:50 pm    Post subject: Reply with quote

Quote:

WORKING-STORAGE SECTION.

01 BPXWDYN PIC X(08) VALUE 'BPXWDYN'.
01 S-EOF-FILE PIC X(01) VALUE 'N'.
01 PDS-STRING.
05 PDS-LENGTH PIC S9(4) COMP VALUE 100.
05 PDS-TEXT PIC X(100) VALUE
'ALLOC DD(INFILE) DSN(''YOUR.PDS.FILE(MEMBER)'') SHR'.

PROCEDURE DIVISION.

CALL BPXWDYN USING PDS-STRING

IF RETURN-CODE = ZERO
DISPLAY 'ALLOCATION OK'
ELSE
DISPLAY 'ALLOC FAILED, RETURN-CODE WAS ' RETURN-CODE
PERFORM INHOUSE-ABEND-ROUTINE
END-IF

OPEN INPUT IN-PDS

PERFORM 1000-READ-INFILE UNTIL S-EOF-FILE = 'Y'

CLOSE IN-PDS

GOBACK.


Hi ,

I am able to creat a file dynamically,but when i try to open it...gives a file status code of 96.

Plz advice.

Thanks
Naveen
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 12, 2007 1:10 pm    Post subject: Reply with quote

Quote:

I am able to creat a file dynamically,but when i try to open it...gives a file status code of 96.

Plz advice.


naveen,

file status of 96 means

Code:

For QSAM file: An OPEN statement with the OUTPUT phrase was attempted, or
an OPEN statement with the I-O or EXTEND phrase was attempted for an     
optional file but no DD statement was specified for the file and the     
CBLQDA(OFF) runtime option was specified.                               


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group