Reading PDS Members
Select messages from
# through # FAQ
[/[Print]\]
Goto page 1, 2, 3  Next  :| |:
MVSFORUMS.com -> Application Programming

#1: Reading PDS Members Author: butta_mvs PostPosted: Sun Feb 29, 2004 11:08 pm
    —
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

#2:  Author: raggop PostPosted: Mon Mar 01, 2004 12:13 am
    —
Use an utility like IEBPTPCH to dump the PDS members onto a single dataset and then process that dataset thru your Cobol pgm.

raghu

#3:  Author: butta_mvs PostPosted: Mon Mar 01, 2004 12:10 pm
    —
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.

#4:  Author: kolusuLocation: San Jose PostPosted: Mon Mar 01, 2004 2:03 pm
    —
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

#5:  Author: superk PostPosted: Mon Mar 01, 2004 2:51 pm
    —
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.

#6:  Author: ofer71Location: Israel PostPosted: Thu Mar 04, 2004 9:36 am
    —
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

#7:  Author: SureshKumar PostPosted: Thu Mar 04, 2004 12:18 pm
    —
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

#8:  Author: kolusuLocation: San Jose PostPosted: Thu Mar 04, 2004 2:21 pm
    —
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

#9:  Author: PhantomLocation: The Blue Planet PostPosted: Thu Jul 29, 2004 2:02 am
    —
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

#10:  Author: kolusuLocation: San Jose PostPosted: Thu Jul 29, 2004 4:31 am
    —
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

#11:  Author: PhantomLocation: The Blue Planet PostPosted: Thu Jul 29, 2004 7:40 am
    —
Thanks for the clarification Kolusu,

Regards,
Phantom

#12:  Author: sladeLocation: Edison, NJ USA PostPosted: Thu Jul 29, 2004 6:25 pm
    —
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.

#13:  Author: cobcurious PostPosted: Wed Sep 01, 2004 8:39 am
    —
Hi slade,
Can u please send me across the code which you have written ?
Thanks
Cobcurious

#14:  Author: naveen_mehatak@hotmail.co PostPosted: Thu Apr 12, 2007 12:50 pm
    —
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

#15:  Author: kolusuLocation: San Jose PostPosted: Thu Apr 12, 2007 1:10 pm
    —
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



MVSFORUMS.com -> Application Programming


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Goto page 1, 2, 3  Next  :| |:
Page 1 of 3

Powered by phpBB © 2001, 2005 phpBB Group