View previous topic :: View next topic
|
Author |
Message |
mbattu
New User
Joined: 19 Jan 2011 Posts: 15 Location: Toronto
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
mbattu
New User
Joined: 19 Jan 2011 Posts: 15 Location: Toronto
|
|
|
|
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 |
|
|
|