IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Find the size of a PS file before reading


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vishnupriyamr

New User


Joined: 06 Jul 2023
Posts: 3
Location: India

PostPosted: Thu Jul 06, 2023 5:20 pm
Reply with quote

Hi Everyone

I am looking to find the size of a PS file with variable records that are assigned by the user .

The user will create the PS file with certain cylinders and block size. We need to write variable records to that block size. We want to ensure that we don't blow up the file. So we want to calculate before hand, how much data (bytes of data) it can hold and put a check.

So from the cobol program, is there a way to find the configuration of the file or the size of the file ?

Please give some thoughts.

Thank you !
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Thu Jul 06, 2023 8:09 pm
Reply with quote

There is no way to do this. Neither in COBOL, nor anywhere else.

BTW, what “blowing up the file” stands for?? 36_2_18.gif

PS.
The “file” in mainframe is equivalent to “DDNAME”. It has no size at all. It is something similar to a sort of connecting pipe, for data to flow between a program, and a dataset.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Thu Jul 06, 2023 8:31 pm
Reply with quote

One more note.
You want “to find the size of a PS dataset (not file!) before READING it”, just to start WRITE to it - ???!!!
What does this mean??
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Thu Jul 06, 2023 8:53 pm
Reply with quote

Highly likely, you want to find in advance: how much data might fit into a pre-allocated dataset, correct?

Absolutely not clear, what you plan to do if your data would not fit?

Normally it should be done in opposite way: FIRST calculate the expected amount of data to be written, and THEN allocate the dataset with required size. You can also use:
- dynamic allocation tools,
- secondary allocation amount,
- multi-volume allocation feature,
- etc.

Initially you tried to resolve your issue from the end. Better try to resolve it from the beginning.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Jul 06, 2023 9:49 pm
Reply with quote

Quote:
I am looking to find the size of a PS file with variable records that are assigned by the user .
Is there a limit to the record size? If not, you have a MAJOR problem because COBOL must know the record length for each file defined in the program at compile time, so you cannot specify record lengths at execution time.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Fri Jul 07, 2023 12:41 am
Reply with quote

There is no one word about any issue, or any question about the record size. The TS is interested in “file size”, and refuses to clarify any details, at all.
Back to top
View user's profile Send private message
Vishnupriyamr

New User


Joined: 06 Jul 2023
Posts: 3
Location: India

PostPosted: Fri Jul 07, 2023 4:19 pm
Reply with quote

Thank you Rob and Sergey for your replies. I apologize for the late reply . As I am in a different time zone, I just saw your replies now.

In our case, we supply the JCL to the user so the user can assign the PS dataset that they have created, to the DDNAME.

The record length we are assigning is 32100 for the file. But the user will create the PS dataset with Cylinders/Tracks. So we want to find out how many records that particular dataset can hold. So I am trying to see , if there is a way to find the allocations done by the user for the PS dataset.

Are there any utilities that we can call to find the allocation of the PS dataset ?

In our case, we want to continuously write the data to the PS dataset and once it is full ,we want to switch to another dataset to continue writing the data there.

I used " blowing up" for the scenario when the PS dataset is full and throwing error.

Please let me know your thoughts on this and sorry for any confusion.

Thank you !
Back to top
View user's profile Send private message
Pete Wilson

Active Member


Joined: 31 Dec 2009
Posts: 590
Location: London

PostPosted: Fri Jul 07, 2023 8:53 pm
Reply with quote

The information you're providing is almost impossible to interpret because it's so incoherent.

It looks like the Users are provided JCL by you, and this 'allocates' (not assign) the dataset as RECFM=VB,LRECL=31000 bytes using the 'DDNAME' you have chosen to use. And the User's have the option to specify SPACE values for the datasets on the DDNAME based on their expectations of the maximum number of records to be written to the dataset? Is that correct?

Specifying SPACE in terms of TRK/CYL is quite primitive really unless you know the geometry of the disk device. Currently a 3390 TRK is 56664 bytes, and there's 15 TRKs to a CYL.

But you can allocate space according to the number of expected records instead which means you don't need awareness of TRK/CYL capacities.
e.g.
SPACE=(31000,(50,50),RLSE),AVGREC=M
This will initially request enough Primary space for 50 million records of 31000 bytes, and same for Secondary space.

BUT, depending on the DATACLAS that gets assigned by SMS to the dataset it could potentially hold a LOT more than that because:
a) DATACLAS may allow it to extend to multiple volumes
b) DATACLAS may make it Extended Format so can have up to 123 extents per volume with no size limit for the total extents. (Non Extended is limited to 65k cyls per volume and max 16 extents)
c) DATACLAS may provide Compression of the data so uses less of the allocated capacity.

I'd suggest you talk to whoever does your Storage admin at your company and I'm sure they'll be able to provide more specific advice than this forum can because so much is site dependent. There may even be a DATACLAS that will provide the space without you having to code it, so you can code DATACLAS=name instead. And potentially a DATACLAS can be automatically assigned to a dataset by SMS without having to code it in the JCL at all.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Fri Jul 07, 2023 10:34 pm
Reply with quote

You can specify the requested size in blocks:
Code:
 SPACE=(32100,(100000,100000),RLSE),…

No need to compute tracks, or cylinders.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1334
Location: Bamberg, Germany

PostPosted: Fri Jul 07, 2023 11:49 pm
Reply with quote

I would also recommend to work with multivolume. A static volcount (coding VOL=(,,,<n>)) might work, but will stress your catalog structure. DYNVOL is the way to go here regarding definitions in DFSMS.
Sometimes "less" is "more" does not only apply to UNIX, see how you can deal with number of extents and such. DFSMS offers a wide range of possibilities for "flat" datasets. Basically you can cover everything with small efforts (One Ring to rule them all).
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Sun Jul 09, 2023 1:58 am
Reply with quote

sergeyken wrote:
You can specify the requested size in blocks:
Code:
 SPACE=(32100,(100000,100000),RLSE),…

No need to compute tracks, or cylinders.
Another option is to allocate the space in KB or MB using the AVGREC=K or AVGREC=M parameter. The interaction with the SPACE parameter isn’t exactly intuitive, but if you read the manual carefully it makes sense, in a JCL-ish sort of way.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Sun Jul 09, 2023 1:59 am
Reply with quote

sergeyken wrote:
You can specify the requested size in blocks:
Code:
 SPACE=(32100,(100000,100000),RLSE),…

No need to compute tracks, or cylinders.
Another option is to allocate the space in KB or MB using the AVGREC=K or AVGREC=M parameter. The interaction with the SPACE parameter isn’t exactly intuitive, but if you read the manual carefully it makes sense, in a JCL-ish sort of way.
Back to top
View user's profile Send private message
Vishnupriyamr

New User


Joined: 06 Jul 2023
Posts: 3
Location: India

PostPosted: Tue Jul 11, 2023 5:26 pm
Reply with quote

Thank you all for the suggestions.

I was able to find a way to get this working. In the cobol program, used the DSINFO DATASET(DSNAME) command to get the allocation values. All the values will be in the Z variables. Then used the VCOPY command to retrieve the Z variables in the working storage variables of the program and used them in the program.

STRING "DSINFO DATASET('DSNAME')"
DELIMITED BY SIZE
INTO CMD-TEXT.
MOVE 44 TO CMD-LENGTH.
CALL 'ISPEXEC' USING CMD-LENGTH, CMD-TEXT.

CALL 'ISPLINK' USING WS-V-COPY
WS-ZDSORG
WS-8
V-ZDSORG
WS-MOVE.

working storage variables
05 V-ZDSORG PIC X(08) VALUE SPACES.
05 WS-ZDSORG PIC X(8) VALUE 'ZDSORG '.
05 WS-MOVE PIC X(8) VALUE 'MOVE '.
05 WS-8 PIC S9(7) COMP VALUE +8.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2140
Location: USA

PostPosted: Tue Jul 11, 2023 5:38 pm
Reply with quote

Please, learn this very primitive trick, to make your posts more attractive to readers:

Vishnupriyamr wrote:
Thank you all for the suggestions.

I was able to find a way to get this working. In the cobol program, used the DSINFO DATASET(DSNAME) command to get the allocation values. All the values will be in the Z variables. Then used the VCOPY command to retrieve the Z variables in the working storage variables of the program and used them in the program.

Code:
STRING "DSINFO DATASET('DSNAME')" 
     DELIMITED BY SIZE                                 
     INTO CMD-TEXT.                               
MOVE  44 TO CMD-LENGTH.
CALL 'ISPEXEC' USING CMD-LENGTH, CMD-TEXT.

CALL 'ISPLINK' USING WS-V-COPY
                     WS-ZDSORG
                     WS-8     
                     V-ZDSORG
                     WS-MOVE.


working storage variables
Code:
05 V-ZDSORG                  PIC X(08) VALUE SPACES.       
05 WS-ZDSORG                    PIC X(8)  VALUE 'ZDSORG  '.
05 WS-MOVE                      PIC X(8)  VALUE 'MOVE    '.
05 WS-8                         PIC S9(7) COMP VALUE +8.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts how to eliminate null indicator value... DB2 7
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Reading Empty Dataset DFSORT/ICETOOL 5
No new posts Compare 2 alphabets in a REXX and fin... CLIST & REXX 2
Search our Forums:

Back to Top