Reading PDS Members
Select messages from
# through # FAQ
[/[Print]\]

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

#16:  Author: naveen_mehatak@hotmail.co PostPosted: Thu Apr 12, 2007 1:48 pm
    —
Thanks Kolusu,

one more...

can i use this call in a loop..and write records in the latest file allocated.

now looks like only first one file is created and write is happening in the same file.

the reult..one file is crested with the data which is suppose to be in the nth file.

Thanks
Naveen

#17:  Author: Bill DennisLocation: Iowa, USA PostPosted: Thu Apr 12, 2007 4:20 pm
    —
Do you CLOSE the file and re-OPEN between member name changes?

#18:  Author: naveen_mehatak@hotmail.co PostPosted: Thu Apr 12, 2007 5:34 pm
    —
yes bill

i close , free then reopen it.

but when i open it as

open output => file status 96
open extend => file status 35

Rolling Eyes

#19:  Author: kolusuLocation: San Jose PostPosted: Fri Apr 13, 2007 6:05 am
    —
naveen_mehatak@hotmail.co wrote:
yes bill

i close , free then reopen it.

but when i open it as

open output => file status 96
open extend => file status 35

Rolling Eyes


naveen,

did you read my last post? you are getting a file status of 96 because of CBLQDA(OFF) runtime option was specified. CBLQDA is the run time option which lets you dynamically allocate files.

You should set to CBLQDA(ON). search the application forum for CBLQDA

Kolusu

#20:  Author: naveen_mehatak@hotmail.co PostPosted: Fri Apr 13, 2007 12:06 pm
    —
yes Kolusu I did...few question on thet

1.if i want to use the file crested dynamically in the next JCl step.

is BPXWDYN call the right option.

2.if yes how CBLQDA = new delete delete.....will help

3.if no do we have a option to create file which could be used later.

as of now with the sring below i am getting a return code of 4062/63 for the
BPXWDYN call

ALLOC DD(OUTFILE) DSN('FBS205.1234.NAV1') NEW CYL SPACE(1,1) UNIT(SYSDA) DELETE BLKSIZE(3800) LRECL(380) RECFM(F,B) DSOR
G(PS) REUSE SHORTRC


Thanks

#21:  Author: kolusuLocation: San Jose PostPosted: Sat Apr 14, 2007 7:40 am
    —
naveen_mehatak@hotmail.co,

1. I don't have sufficient information on your requirements. So cannot comment on that.

2. No idea as to what you are talking

3. Didyou change the length field when you moved the value to the alloc text? Make sure that you move the right value. The examples above shows 100 , you might have exceeded that.

Kolusu

#22:  Author: naveen_mehatak@hotmail.co PostPosted: Mon Apr 16, 2007 12:43 pm
    —
Kolusu,

3.The text field length was taken care of.so that was not the problem.

1.based on a given input file I need to decide how many files i need to create DYNAMICALLY and write corresponding recs in those files.these files are fed to another system.
i want to do these with out REXX. better if its in the program.

2.so because i want these files in the next step.
my question was when CBLQDA=ON is set the file disp is set to (new ,delete,delete)
so will i have the file after the program ends.

Thanks
Naveen

#23:  Author: kolusuLocation: San Jose PostPosted: Mon Apr 16, 2007 1:04 pm
    —
naveen_mehatak@hotmail.co,

Quote:

The text field length was taken care of.so that was not the problem


If you taken care of the length , then you should not have got the error at all. You must have specified something wrong.

Quote:

so because i want these files in the next step.
my question was when CBLQDA=ON is set the file disp is set to (new ,delete,delete)
so will i have the file after the program ends.


CBLQDA is has got nothing to do with your DISP paramaeter. If you code new,delete,delete then after completion of the step the dataset will be deleted.

CBLQDA is a language environment variable which dynamically allocates a temp dataset when the QSAM file is unavailable. You also need the CBLQDA parm even though you are explicitly allocating the files.

Kolusu

#24:  Author: naveen_mehatak@hotmail.co PostPosted: Mon Apr 16, 2007 2:13 pm
    —
1.Yes somethign is wrong.It worked for me the first time.now it returns this code.

2.Thanks for the info on CBLQDA. Please let me know how do we set CBLQDA if I am using program DFSRRC00 to run my program.

Thanks
Naveen

#25:  Author: Eric.C.BakkeLocation: Plano, TX PostPosted: Wed Jul 16, 2008 5:14 pm
    —
I'm new to this forum and appreciate the info in this post.

I've created a program that reads a pds directory and the subsequently reads each pds member record.

If your interested, the code is as follows:

Code:


 IDENTIFICATION DIVISION.                                         
 PROGRAM-ID.     PDSREAD.                                         
******************************************************************
**                                                              **
** PROGRAM TITLE: PDSREAD                                       **
**                                                              **
** PROGRAM PURPOSE: THIS COBOL PROGRAM IS A TEST PROGRAM THAT   **
** READS THE DIRECTORY MEMBERS OF A PDS DATASET AND THEN        **
** FOR EACH MEMBER DYNAMICALLY ALLOCATES A FILE TO BE OPENED    **
** AND READ TO DISPLAY THE PDS CONTENTS TO SYSOUT.              **
**                                                              **
** INPUT FILES: PDS-DATASET     SYS010                          **
**              IN-PDS          INFILE (DYNAMICALLY ASSIGNED)   **
**                                                              **
** OUTPUT FILES: SYSOUT                                         **
**                                                              **
** LINKAGE PARMS: NONE                                          **
**                                                              **
**                                                              **
******************************************************************
** MODIFICATION LOG:                                            **
******************************************************************
** ANALYST  DATE  CHANGE DESCRIPTION                            **
** ------- ------ ----------------------------------------------**
** EBAKKE  071608 ORIGINAL CREATION                             **
******************************************************************
                                                                 
 ENVIRONMENT DIVISION.                                           
 CONFIGURATION SECTION.                                           
 SOURCE-COMPUTER. IBM-370.                                       
 OBJECT-COMPUTER. IBM-370.                                       
                                                                 
 INPUT-OUTPUT SECTION.                                           
 FILE-CONTROL.                                                   
                                                                 
     SELECT PDS-DATASET                        ASSIGN TO UT-S-PDS.
                                                                 
     SELECT IN-PDS                             ASSIGN TO INFILE. 

 DATA DIVISION.

 FILE SECTION.

 FD  PDS-DATASET.

 01  PDS-DIRECTORY.
     05 USED-BYTES                     PIC S9(4) COMP.
     05 REST-OF-RECORD                 PIC X(254).

 FD  IN-PDS
     RECORDING MODE IS F
     BLOCK CONTAINS 0 RECORDS
     RECORD CONTAINS 80 CHARACTERS
     LABEL RECORDS ARE STANDARD.

 01  IN-REC                            PIC X(080).


 WORKING-STORAGE SECTION.

* CONSTANTS
 77  BPXWDYN                          PIC X(08) VALUE 'BPXWDYN'.
 77  CLEANUP                          PIC S9(9) COMP SYNC VALUE 1.

* DIRECTORY ENTRY LAYOUT
 01  DIRECTORY-ENTRY.
     05 MEMBER-NAME                    PIC X(8).
     05 FILLER                         PIC X(3).
     05 WS-INDC                        PIC X.

* PDS ALLOCATION STRING
 01  PDS-STRING.
     05 PDS-LENGTH                     PIC S9(4) COMP VALUE 100.
     05 PDS-TEXT                       PIC X(100).

* WORK FIELD FOR PARSING THRU DIRECTORY RECORDS
 01  WG-WORK-FIELD.
     05 WG-WORK-FIELD-NUMERIC          PIC S9(4) COMP.

* GENERAL WORKING STORAGE VARIABLES
 01  WG-GENERAL-WORKAREA.
     05 WG-IX-1                        PIC S9(4) COMP.
     05 WG-TRASH                       PIC S9(4) COMP.
     05 WG-HALF-WORDS                  PIC S9(4) COMP.
     05 WG-ABEND-CODE                  PIC S9(9) COMP.

* 88-LEVEL SWITCHES
 01  WS-SWITCHES.
     05 END-OF-DIRECTORY-SW            PIC X VALUE 'N'.
        88 EOF-DIRECTORY                     VALUE 'Y'.
     05 END-OF-MEMBER-SW               PIC X VALUE 'N'.
        88 EOF-MEMBER                        VALUE 'Y'.

 LINKAGE SECTION.
 01  LINK-PARM.
     05 PARM-LENGTH                    PIC S9(4) COMP.
     05 PARM-TEXT                      PIC X(44).

 PROCEDURE DIVISION USING LINK-PARM.

     DISPLAY ' '.
     DISPLAY 'PROCESSING PDS FILE ' PARM-TEXT.

     PERFORM 0100-INITIALIZATION.

     PERFORM 0200-PROCESS-LOOP UNTIL EOF-DIRECTORY.

     PERFORM 0300-FINALIZATION.

     STOP RUN.

******************************************************************
* 0100-INITIALIZATION                                            *
******************************************************************
 0100-INITIALIZATION.
* CHECK INPUT PARM FOR DATA THAT IS UP TO MAX DSN SIZE OF 44 BYTES
     IF PARM-LENGTH < 1 OR PARM-LENGTH > 44
        DISPLAY 'INVALID INPUT PARM LENGTH' PARM-LENGTH
        MOVE 1 TO WG-ABEND-CODE
        PERFORM 9999-ABEND
     END-IF.

* OPEN INPUT PDS DATASET
     OPEN INPUT PDS-DATASET.

* DO PRIMING READ OF PDS DATASET
     PERFORM 8000-READ-DIRECTORY.

******************************************************************
* 0200-PROCESS-LOOP                                              *
******************************************************************
 0200-PROCESS-LOOP.

* PROCESS EACH DIRECTORY ENTRY LISTING THE MEMBERS NAME AND
* CONTENTS TO SYSOUT
     MOVE 1 TO WG-IX-1.
     PERFORM
      UNTIL USED-BYTES - WG-IX-1 < 11 OR
            REST-OF-RECORD (WG-IX-1:1) = HIGH-VALUES
       MOVE REST-OF-RECORD (WG-IX-1:12) TO DIRECTORY-ENTRY
       PERFORM 1000-PROCESS-MEMBER
       INITIALIZE WG-WORK-FIELD
       MOVE WS-INDC TO WG-WORK-FIELD (2:1)
       DIVIDE WG-WORK-FIELD-NUMERIC BY 32 GIVING WG-TRASH
        REMAINDER WG-HALF-WORDS
       COMPUTE WG-IX-1 = WG-IX-1 + 12 + WG-HALF-WORDS * 2
     END-PERFORM.

* READ NEXT DIRECTORY RECORD IF NOT DONE YET
     IF REST-OF-RECORD (WG-IX-1:1) = HIGH-VALUES
        SET EOF-DIRECTORY TO TRUE
     ELSE
        PERFORM 8000-READ-DIRECTORY
     END-IF.

******************************************************************
* 0300-FINALIZATION                                              *
******************************************************************
 0300-FINALIZATION.

* CLOSE PDS DATASET USED FOR ACCESSING DIRECTORY RECORDS.
     CLOSE PDS-DATASET.

******************************************************************
* 1000-PROCESS-MEMBER                                            *
******************************************************************
 1000-PROCESS-MEMBER.

* DISPLAY MEMBER NAME TO SYSOUT
     DISPLAY '** PROCESSING MEMBER ''' MEMBER-NAME ''' **'.

* INITIALIZE STUFF FORE EACH DIRECTORY MEMBER
     MOVE SPACES TO PDS-TEXT, END-OF-MEMBER-SW.

* STRING TOGETHER THE PDS ALLOCATION STRING WITH MEMBER NAME
     STRING
        'ALLOC DD(INFILE) DSN(''' DELIMITED BY SIZE
        PARM-TEXT (1:PARM-LENGTH) DELIMITED BY SIZE
        '('                       DELIMITED BY SIZE
        MEMBER-NAME     DELIMITED BY ' '
        ')'') SHR REUSE'   DELIMITED BY SIZE
       INTO PDS-TEXT.

* DYNAMICALLY ALLOCATE PDS DATASET WITH MEMBER AS IN-PDS FILE
     CALL BPXWDYN USING PDS-STRING.

* CHECK RETURN CODE AND ABEND IF CAN'T ALLOCATE DATASET
     IF RETURN-CODE = 0
        CONTINUE
     ELSE
        DISPLAY 'ALLOC FAILED, RETURN-CODE WAS ' RETURN-CODE
        MOVE 2 TO WG-ABEND-CODE
        PERFORM 9999-ABEND
     END-IF.

* OPEN IN-PDS FILE TO START READING MEMBER RECORDS
     OPEN INPUT IN-PDS.

* DISPLAY EACH MEMBER RECORD UNTIL THE END IS REACHED
     DISPLAY ' MEMBER RECORDS ARE: '.
     PERFORM 8100-READ-MEMBER UNTIL EOF-MEMBER.
     DISPLAY ' '.

* CLOSE DYNAMICALLY ALLOCATED IN-PDS FILE
     CLOSE IN-PDS.

******************************************************************
* 8000-READ-DIRECTORY                                            *
******************************************************************
 8000-READ-DIRECTORY.

     READ PDS-DATASET
       AT END
         SET EOF-DIRECTORY TO TRUE.

******************************************************************
* 8100-READ-MEMBER.                                              *
******************************************************************
 8100-READ-MEMBER.

     READ IN-PDS
       AT END SET EOF-MEMBER TO TRUE
       NOT AT END
          DISPLAY IN-REC.

******************************************************************
* 9999-ABEND.                                                    *
******************************************************************
 9999-ABEND.
     CALL 'CEE3ABD' USING WG-ABEND-CODE, CLEANUP.


Use the following JCL to execute the above:

Code:

//JS001    EXEC PGM=IKJEFT1B,REGION=0M
//STEPLIB  DD DSN={your.loadlib},DISP=SHR
//PDS      DD DSN={your.pds.dataset},DISP=SHR,RECFM=U,LRECL=256
//SYSOUT   DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
 DSN SYSTEM(DSN)
    RUN PROGRAM(PDSREAD) PARM('{your pds dataset}')
 END
//* END OF JCL


Last edited by Eric.C.Bakke on Mon Jul 21, 2008 3:11 pm; edited 1 time in total

#26:  Author: semigeezerLocation: Atlantis PostPosted: Wed Jul 16, 2008 9:22 pm
    —
Nice. Since I can barely spell "COBOL" (hope I got that right!) I'm curious about the use of TSO and the DSN command. Wouldn't PGM=PDSREAD,PARM='dsname' be sufficient? I don't pretend to understand the ASSIGN stuff in COBOL, but I didn't see anything that directly associated the file definition for the directory with a ddname.

#27:  Author: Eric.C.BakkeLocation: Plano, TX PostPosted: Thu Jul 17, 2008 10:01 am
    —
Yes, you could replace IKJEFT1B with this...I'm a DB2 DBA so I'm used to using the batch TSO method...both work the same.

#28:  Author: Eric.C.BakkeLocation: Plano, TX PostPosted: Thu Jul 17, 2008 10:08 am
    —
One more thing...I realized that I left the DB2 connection to DSN in my example JCL after I posted it but since I'm not allowed to edit my posts I couldn't change it. You should probably use the direct method instead of doing the DB2 connections unless you have DB2 work to do with the PDS members. Sorry for any confusion here.

#29:  Author: Terry_HeinzeLocation: Richfield, MN, USA PostPosted: Thu Jul 17, 2008 11:12 am
    —
Ask the moderator for "edit" authorization and he'll probably grant it.

#30:  Author: kolusuLocation: San Jose PostPosted: Thu Jul 17, 2008 11:43 am
    —
Eric.C.Bakke,

You can now edit your OWN posts. btw I haven't tested it but does the program support PDSE's?

Thanks

#31:  Author: Eric.C.BakkeLocation: Plano, TX PostPosted: Thu Jul 17, 2008 12:50 pm
    —
kolusu,

Thanks for edit capability.

I tested the program on both PDS and PDSE using Z/OS v1.9. I'm working on a new directory module that will provide in linkage the member name and additional attributes. I'll post that if anyone's interested in this.

#32:  Author: semigeezerLocation: Atlantis PostPosted: Thu Jul 17, 2008 4:38 pm
    —
If you need info for ISPF stats, you can see my exec at http://sillysot.com/ftp/mlrexx.txt

Kolusu. This should work fine for PDSE because an attempt to read a PDSE directory directly causes MVS to simulate a PDS directory and return records as if they were part of a real PDS directory. Good for compatibility, but for obvious reasons, it is much slower than reading the real thing, and you can't write a PDSE directory directly.

#33:  Author: SreejithLocation: N.Ireland PostPosted: Tue Nov 04, 2008 2:13 pm
    —
Hi,
Did anyone successfully managed to use BPXWDYN to read PDS member ? I use the same code given above by Kolusu. It work for a dataset, but if I use a PDS it abends with 4072 and the return code from BPXWDYN is 0002M. The dataset I am using is PDS not a PDSE.

Any idea why I am getting this error.

Thanks
Sreejith

#34:  Author: kolusuLocation: San Jose PostPosted: Tue Nov 04, 2008 2:38 pm
    —
Sreejith wrote:
Hi,
Did anyone successfully managed to use BPXWDYN to read PDS member ? I use the same code given above by Kolusu. It work for a dataset, but if I use a PDS it abends with 4072 and the return code from BPXWDYN is 0002M. The dataset I am using is PDS not a PDSE.

Any idea why I am getting this error.



Sreejith


Code:


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'.


You probbaly had a file name longer than 100 bytes. Make sure that you have coded enough length. Put a display of the PDS-text and PDS-length and see if there is an overflow.

#35:  Author: SreejithLocation: N.Ireland PostPosted: Wed Nov 05, 2008 8:34 am
    —
Thanks Kolusu. Problem solved.
Displayed PDS-lenght (after moving to 9(4)) and it was zeroes
I initialized PDS-String in the program and resulted in error. Supposed to initialize PDS-TEXT. The program is building PDS-TEXT from SYSIN.

#36:  Author: jim haire PostPosted: Tue Apr 17, 2018 10:40 am
    —
Kolusu,
You provided the example above which is greatly appreciated. I am doing something similar, although I am allocating new datasets (multiple datasets within the same run).

I am building the allocate statements via a COBOL STRING statement, taking the dataset names from an input file I am reading. My allocate statement looks like this:

Code:

ALLOC DD(CCCTRIGF) DSN([i]'dataset.name.here[/i].TRIGGER') NEW CATALOG RECFM(F) LRECL(80) SPACE(1,1) TRACKS DSORG(PS)


I string this into a variable called WS-ALLOCATION-STRING.
My WS-ALLOCATION-STRING is fixed length for 132. I then call BPXWDYN statically using the WS-ALLOCATION-STRING.

Code:

CALL 'BPXWDYN' USING WS-ALLOCATION-STRING.


I am getting a return code of -00332. I am not sure how to interpret this.

I noticed your example is using a length when defining the allocation string. Is that necessary? Is there a maximum length this allocation string can be? The length of my allocation string could be different based on the length of the dataset name I read from the input file.

#37:  Author: jim haire PostPosted: Tue Apr 17, 2018 11:03 am
    —
Never mind. I figured out what it was. I took one of your earlier posts and read the dataset being enclosed by two single quotes, when really it was a double quote.

To answer my own questions:
1. Yes, you should use a 01 level with a length when defining your application string for BPXWDYN.

2. The length of the string being passed to BPXWDYN can be longer than 100.
I'm not sure what the maximum length it can be. (Mine is 132).

#38:  Author: kolusuLocation: San Jose PostPosted: Tue Apr 17, 2018 11:30 am
    —
jim haire wrote:
Never mind. I figured out what it was.

2. The length of the string being passed to BPXWDYN can be longer than 100.
I'm not sure what the maximum length it can be. (Mine is 132).


Jim,

Glad you are able to figure it out. As for the length field it is 2 byte binary and hence it can have a max length of 32767. However since we are calling BPXWDYN using a parameter list, most times it is limited to 4096, which is more than enough as you do not have parms that exceed 4096



MVSFORUMS.com -> Application Programming


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

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group