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: 8134
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: 1848
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
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
This topic is locked: you cannot edit posts or make replies. rexx to create a tso command Bharath Vikraman CLIST & REXX 1 Tue Aug 08, 2017 3:32 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts How do you create Eclipse based dialogs jasorn IBM Tools 0 Thu Aug 03, 2017 5:05 pm


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