Hello,
I am trying to dynamically allocate files on Unix on z/os. There will be multiple files generated for each input record and all the output files will have same DDNAME. I am able to allocate these file but all the output records are written in single file.
I am closing the file after each record is written and allocating a different file again, but still the records are in same file. how to write multiple files for multiple input records using BPXWDYN? Please help
TIA
Heisenberg
Dynamic allocation in COBOl using BPXWDYN
-
- Posts: 7
- Joined: Thu Jun 22, 2023 7:30 pm
- Skillset: COBOL,DB2,JCL
- Referer: Google
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Dynamic allocation in COBOl using BPXWDYN
Heisenberg wrote:I am able to allocate these file but all the output records are written in single file.
these = Plural
file = Singular
How many files actually allocated?
And how the allocated files are connected to COBOL's (single?) file definition?
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 7
- Joined: Thu Jun 22, 2023 7:30 pm
- Skillset: COBOL,DB2,JCL
- Referer: Google
Re: Dynamic allocation in COBOl using BPXWDYN
Hello sergeyken,
Sorry that was a typo. There are seven records in my test input file. All the 7 records are written in a single file. But my expectation is to allocate 7 different output files each having one single record in USS path.
Sorry that was a typo. There are seven records in my test input file. All the 7 records are written in a single file. But my expectation is to allocate 7 different output files each having one single record in USS path.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Dynamic allocation in COBOl using BPXWDYN
Heisenberg wrote:Hello sergeyken,
Sorry that was a typo. There are seven records in my test input file. All the 7 records are written in a single file. But my expectation is to allocate 7 different output files each having one single record in USS path.
What exactly is the obstacle which prevents you from doing this?
There are tons of existing documentation, and examples in internet on this issue.
Did you try something? What are the results of your attempts?
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 7
- Joined: Thu Jun 22, 2023 7:30 pm
- Skillset: COBOL,DB2,JCL
- Referer: Google
Re: Dynamic allocation in COBOl using BPXWDYN
Hello sergeyken,
Based on the forums and documentation, I used FREE option from the BPXWDYN utility to free the dataset as below.
But the allocation of multiple files is not happening.
01 W-STRING-ALLOC PIC X(200) VALUE 'FREE DD(OTFILE)'.
CALL BPXWDYN USING W-STRING-ALLOC
Based on the forums and documentation, I used FREE option from the BPXWDYN utility to free the dataset as below.
But the allocation of multiple files is not happening.
01 W-STRING-ALLOC PIC X(200) VALUE 'FREE DD(OTFILE)'.
CALL BPXWDYN USING W-STRING-ALLOC
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Dynamic allocation in COBOl using BPXWDYN
Heisenberg wrote:Hello sergeyken,
Based on the forums and documentation, I used FREE option from the BPXWDYN utility to free the dataset as below.
But the allocation of multiple files is not happening.Code: Select all
01 W-STRING-ALLOC PIC X(200) VALUE 'FREE DD(OTFILE)'.
CALL BPXWDYN USING W-STRING-ALLOC
When using FREE option, you make the DD-name OTFILE available for further use.
Since you did not try to allocate any new file in place of the released one, that's why "the allocation of multiple files is not happening"
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Dynamic allocation in COBOl using BPXWDYN
For example: How to Use BPXWDYN Utility to Allocate File
Did you try this?
Did you try anything at all?
Code: Select all
01 WS-TEXT PIC X(55) VALUE "ALLOC FI(OUT) DS('WORK.TAPE') NEW KEEP UNIT(TAPE) REUSE"
CALL BPXWDYN USING WS-TEXT.
Did you try this?
Did you try anything at all?
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 474
- Joined: Thu Mar 10, 2016 5:03 pm
- Skillset: assembler rexx zOS ispf racf smf
- Referer: saw it in the experts foprum thought I could help here
Re: Dynamic allocation in COBOl using BPXWDYN
Not being a COBOL person, I will ask a stupid question - do you close the file before the FREE? Otherwise you can't.
-
- Posts: 7
- Joined: Thu Jun 22, 2023 7:30 pm
- Skillset: COBOL,DB2,JCL
- Referer: Google
Re: Dynamic allocation in COBOl using BPXWDYN
Hello sergeyken,
The allocation of the file has been done using below code.
'ALLOC DD(N3FIPSO) PATH(/u/USERS/userid/file1.text) PATHOPTS(ORDWR,OCREAT) PATHDISP(KEEP,KEEP) PATHMODE(SIRWXU) FILEDATA(RECORD) '
The file was successfully allocated in the USS directory with 7 records inside it, but I expect seven files with one record each.
The logic as follows.
1. Allocate file using BPXWDYN
2. Open the output file
3. Write Output file
4. Close the Ouput file
This will be performed 7 times with different files name (like file1.txt, file2.txt...) , but only file1.txt created with 7 records in it.
Each time the file is opened and closed, and the allocate function is repeated 7 times with different file names.
@willy jensen, yes ofcourse the file is closed each time.
The allocation of the file has been done using below code.
'ALLOC DD(N3FIPSO) PATH(/u/USERS/userid/file1.text) PATHOPTS(ORDWR,OCREAT) PATHDISP(KEEP,KEEP) PATHMODE(SIRWXU) FILEDATA(RECORD) '
The file was successfully allocated in the USS directory with 7 records inside it, but I expect seven files with one record each.
The logic as follows.
1. Allocate file using BPXWDYN
2. Open the output file
3. Write Output file
4. Close the Ouput file
This will be performed 7 times with different files name (like file1.txt, file2.txt...) , but only file1.txt created with 7 records in it.
Each time the file is opened and closed, and the allocate function is repeated 7 times with different file names.
@willy jensen, yes ofcourse the file is closed each time.
-
- Posts: 474
- Joined: Thu Mar 10, 2016 5:03 pm
- Skillset: assembler rexx zOS ispf racf smf
- Referer: saw it in the experts foprum thought I could help here
Re: Dynamic allocation in COBOl using BPXWDYN
Seems that you do not free the file, as sergeyken hinted above.
You must
5. Free the Ouput file
You could use the REUSE parameter for BPXWDYN, but you still must free the file at the very end.
You must
5. Free the Ouput file
You could use the REUSE parameter for BPXWDYN, but you still must free the file at the very end.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 14
- 4300
-
by steve-myers
View the latest post
Tue Apr 05, 2022 10:04 pm
-
- 4
- 3006
-
by Robert Sample
View the latest post
Wed Jun 07, 2023 7:53 pm
-
- 5
- 1783
-
by willy jensen
View the latest post
Fri Dec 03, 2021 8:16 pm
-
- 12
- 12746
-
by Robert Sample
View the latest post
Thu Dec 15, 2022 9:28 pm
-
- 2
- 4477
-
by sergeyken
View the latest post
Sat Nov 11, 2023 3:01 am