Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Unable to create multiple files using BPXWDYN

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mbattu

New User


Joined: 19 Jan 2011
Posts: 7
Location: Hyderabad

PostPosted: Fri May 05, 2017 5:35 pm    Post subject: Unable to create multiple files using BPXWDYN
Reply with quote

Hi,

I have a requirement to create multiple files based on input file. I have first tried to create two files using BPXWDYN, if it is successful thought of creating the actual program.

Now the problem is job is running fine with zero return code for calls to BPXWDYN but only one file is being created. Below is the code, please let me know where I am going wrong. Thanks for the help.

Code:

 IDENTIFICATION DIVISION.             
 PROGRAM-ID. XXXXXXXX.               
 ENVIRONMENT DIVISION.               
 INPUT-OUTPUT SECTION.               
 FILE-CONTROL.                       
     SELECT OT-FILE ASSIGN TO OTFILE 
     FILE STATUS FS.                 
 DATA DIVISION.                       
 FILE SECTION.                       
 FD  OT-FILE.                         
 01  OT-REC PIC X(80).               
 WORKING-STORAGE SECTION.             
 01  FS PIC X(02).                   
 01  FN PIC X(17).                   
 01  WS-ALLOC-STRING PIC X(100).     
 01  PGM PIC X(08) VALUE 'BPXWDYN'.   
 PROCEDURE DIVISION.                 
***  FILE 1                           
     MOVE 'XXXXXXX.TSTS.DYN1'    TO FN.               
     STRING 'ALLOC DD(OTFILE) DSN(' FN ') NEW '       
            'CATALOG ' 'LRECL(80) RECFM(F,B)'         
        DELIMITED BY SIZE                             
        INTO WS-ALLOC-STRING                           
     END-STRING.                                       
     DISPLAY ' WS-ALLOC-STRING *' WS-ALLOC-STRING '*' 
     CALL PGM                    USING WS-ALLOC-STRING.
     DISPLAY RETURN-CODE.                             
                                                       
     OPEN OUTPUT OT-FILE.                             
     MOVE 'MY REC1'              TO OT-REC.           
     WRITE OT-REC.                                     
     DISPLAY 'FS :' FS                                 
     CLOSE OT-FILE.                                   
                                                       
***  FILE 2                                           
     MOVE 'XXXXXXX.TSTS.DYN2'    TO FN.               
     STRING 'ALLOC DD(OTFILE) DSN(' FN ') NEW '       
            'CATALOG ' 'LRECL(80) RECFM(F,B)'       
         DELIMITED BY SIZE                           
        INTO WS-ALLOC-STRING                         
     END-STRING.                                     
     DISPLAY ' WS-ALLOC-STRING *' WS-ALLOC-STRING '*'
     CALL PGM USING WS-ALLOC-STRING.                 
     DISPLAY RETURN-CODE.                           
                                                     
     OPEN OUTPUT OT-FILE.                           
     MOVE 'MY REC2'              TO OT-REC.         
     WRITE OT-REC.                                   
     DISPLAY 'FS :' FS                               
     CLOSE OT-FILE.                                 
                                                     
     GOBACK.                                         
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Fri May 05, 2017 6:22 pm    Post subject:
Reply with quote

You need to call BPXWDYN with a request type of FREE after you close OT-FILE the first time. Otherwise, OTFILE remains allocated to your first file until the end of the job step (or job).
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1788
Location: UK

PostPosted: Fri May 05, 2017 6:23 pm    Post subject:
Reply with quote

For a start you are using the same DDNAME for your allocated dataset (not a "file" on mainframe). Try using different DDNAMEs for each allocation.
Back to top
View user's profile Send private message
mbattu

New User


Joined: 19 Jan 2011
Posts: 7
Location: Hyderabad

PostPosted: Fri May 05, 2017 6:32 pm    Post subject:
Reply with quote

Thank you so much Robert. It worked when I used CLOSE command along with ALLOCATE.


Hi Nic, the reason I am using only one DDNAME is the number of files I use vary and can't be determined before. Using CLOSE command I can use the same for multiple files.

Thank you both for the response.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts copy SEQ to PDS and create stats steve-myers JCL & VSAM 5 Thu Apr 27, 2017 1:15 am
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us