Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 11
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: 8195
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: 1931
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: 11
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 Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 1 Wed Dec 06, 2017 1:50 am
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts unable to set RC = 4 when empty file migusd SYNCSORT 1 Tue Nov 21, 2017 1:21 am
No new posts How to create issuer certificate? :'( vasanthz All Other Mainframe Topics 1 Sat Nov 18, 2017 5:14 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us