Dynamic allocation in COBOl using BPXWDYN

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS
Heisenberg
Posts: 7
Joined: Thu Jun 22, 2023 7:30 pm
Skillset: COBOL,DB2,JCL
Referer: Google

Dynamic allocation in COBOl using BPXWDYN

Postby Heisenberg » Thu Jun 22, 2023 7:35 pm

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

User avatar
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

Postby sergeyken » Thu Jun 22, 2023 8:17 pm

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.

Heisenberg
Posts: 7
Joined: Thu Jun 22, 2023 7:30 pm
Skillset: COBOL,DB2,JCL
Referer: Google

Re: Dynamic allocation in COBOl using BPXWDYN

Postby Heisenberg » Thu Jun 22, 2023 8:23 pm

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.

User avatar
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

Postby sergeyken » Thu Jun 22, 2023 8:52 pm

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.

Heisenberg
Posts: 7
Joined: Thu Jun 22, 2023 7:30 pm
Skillset: COBOL,DB2,JCL
Referer: Google

Re: Dynamic allocation in COBOl using BPXWDYN

Postby Heisenberg » Thu Jun 22, 2023 8:57 pm

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

User avatar
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

Postby sergeyken » Thu Jun 22, 2023 11:11 pm

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.

User avatar
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

Postby sergeyken » Thu Jun 22, 2023 11:23 pm

For example: How to Use BPXWDYN Utility to Allocate File

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.

willy jensen
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

Postby willy jensen » Fri Jun 23, 2023 1:35 am

Not being a COBOL person, I will ask a stupid question - do you close the file before the FREE? Otherwise you can't.

Heisenberg
Posts: 7
Joined: Thu Jun 22, 2023 7:30 pm
Skillset: COBOL,DB2,JCL
Referer: Google

Re: Dynamic allocation in COBOl using BPXWDYN

Postby Heisenberg » Fri Jun 23, 2023 3:21 pm

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.

willy jensen
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

Postby willy jensen » Fri Jun 23, 2023 3:40 pm

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.


  • Similar Topics
    Replies
    Views
    Last post