BLOCK CONTAINS 0 RECORDS.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Nick Jones
Registered Member
Posts: 22
Joined: Tue Jul 23, 2013 10:56 pm

BLOCK CONTAINS 0 RECORDS.

Post by Nick Jones »

Hi,

Please consider the below code:

Code: Select all

FD INPUT-FILE 
RECORDING MODE F 
LABEL RECORDS ARE STANDARD 
BLOCK CONTAINS 0 RECORDS 
DATA RECORD IS IN-REC. 
In above the statement BLOCK CONTAINS is used along with the RECORD CONTAINS statement - is it used to calculate the block size, by the Program?

I've been told that based on these details the data read is optimized, I'm confused - how is that optimized?

Could someone help me here to understand the concept of BLOCK SIZE we use in COBOL programs and the one we use in JCL at DCB?

Thanks
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: BLOCK CONTAINS 0 RECORDS.

Post by Robert Sample »

The answer actually is complicated. When JCL references a file, where does z/OS get the DCB data (record length and block size in particular)? The answer to THIS question is that z/OS uses a specific hierarchy to find DCB data:
1. The program
2. The JCL
3. The data set
Any values not found in the program will be searched in the JCL; any not found in the program and JCL will be discovered by looking at the actual data set characteristics. If you code BLOCK CONTAINS 10 RECORDS in your program, then the block size is 10 times the record length -- period. If you are using 100-byte fixed length records, that gives you a block size of 1000 bytes. The most efficient block size, however, depends upon the device being used (3380 disks are most efficient with a block size no larger than 23476 bytes; 3390 devices with a block size no larger than 27998 bytes, and tapes with a block size of 32760).

BLOCK CONTAINS 0 RECORDS tells the operating system, therefore, that the program is not going to provide the block size, allowing either the JCL or the actual data set to provide the block size. This allows changes from 3380 to 3390 to tape to occur with only a JCL change rather than having to recompile the program with a new BLOCK CONTAINS clause every time.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: BLOCK CONTAINS 0 RECORDS.

Post by Anuj Dhawan »

Robert Sample wrote:BLOCK CONTAINS 0 RECORDS tells the operating system, therefore, that the program is not going to provide the block size, allowing either the JCL or the actual data set to provide the block size. This allows changes from 3380 to 3390 to tape to occur with only a JCL change rather than having to recompile the program with a new BLOCK CONTAINS clause every time.
Does that mean if for DASD pools, (for example) a shop start using 3390 instead of 3380 - JCLs might need change? I think, this will be applicable only when BLKSIZE is hard-coded to some specific value in JCL?
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: BLOCK CONTAINS 0 RECORDS.

Post by Robert Sample »

If the JCL is coded to use 23440 block size for a data set with LRECL=80, then changing the pool DASD from 3380 to 3390 would indicate a change in the block size in the JCL to use 27920; otherwise, the data set would be using more tracks than needed.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: BLOCK CONTAINS 0 RECORDS.

Post by Anuj Dhawan »

Thanks Robert. Having you around always gives a point or two to learn.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Nick Jones
Registered Member
Posts: 22
Joined: Tue Jul 23, 2013 10:56 pm

Re: BLOCK CONTAINS 0 RECORDS.

Post by Nick Jones »

Thanks Robert.

Should not we just leave this clause and let the system decide the BLKSIZE?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: BLOCK CONTAINS 0 RECORDS.

Post by Robert Sample »

It is HIGHLY recommended these days to use BLOCK CONTAINS 0 RECORDS. However, there are thousands if not millions of existing programs that have the block size hard-coded in the program. If the program is being modified, making the BLOCK CONTAINS 0 RECORDS change would be easy. However, if that is all that needs to be changed then it is probably not worth the effort of pulling the production code into test, changing, then promoting the code back into production.
Nick Jones
Registered Member
Posts: 22
Joined: Tue Jul 23, 2013 10:56 pm

Re: BLOCK CONTAINS 0 RECORDS.

Post by Nick Jones »

Thanks Robert.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”