Page 1 of 1

Can't read Variable Block Mainframe file

Posted: Sat Dec 08, 2012 8:32 am
by pradkumar
Hi All,

I am new to COBOL and I have been struggling for a week. I have a Variable Block file and 3 copybooks (header, detail and trailer) from our Mainframe guy. The record length in Mainframe shows 27840 bytes ( I guess it means maximum length for VB format). I created 3 COBOL FD by using the copybooks.

In CFF stage, I noticed the total length of all columns is 40 bytes for header, 930 for detail and 136 for trailer. I tried to configure CFF stage in many ways and I can't read the file.

File Options: Record Type - Variable/Variable Block
Record Options: Byte Order -Native-endian; Data format- binary ; Character set: EBCDIC.
Records ID: RECORD_TYPE='H'
RECORD_TYPE_2='D'
RECORD_TYPE_3='T'

Can anyone help me with this? Thanks in advance.

Posted: Sat Dec 08, 2012 9:07 am
by chulett
Have you checked this FAQ?

Posted: Sat Dec 08, 2012 9:51 am
by pradkumar
Yes, Craig. I have read the FAQ and also searched in forum about Mainframe and COBOL before I posted this. Although I learned a lot from that, i still can't figure out my problem.

In FAQ, it says mainframe variable length data has the usual attributes: a field containing the actual length of the field or record followed by the data.

But the file doesn't have such a field.

Thanks for any help

Posted: Sat Dec 08, 2012 10:52 am
by chulett
pradkumar wrote:the file doesn't have such a field
Then it sounds like you may not have a "variable block" file. I'm not the best one to help for stuff like this, I've done more than my share of COBOL in the past but never actually got any hands on time with the CFF stage and not done much mainframe stuff either. You'll need to wait for other more helpful types to wander along, which may not happen over the weekend. FYI.

Posted: Sat Dec 08, 2012 12:43 pm
by FranklinE
It is only coincidental that I'm here to contradict Craig: I am rarely in my office on a weekend.

First, revisit the attributes of the mainframe file in detail. You need to look at two explicit data control block (DCB) attributes. LRECL is the logical record length, and BLKSIZE is the length of the block. I am guessing that 27840 is the block length, not the record length.

Unfortunately, I don't have much experience with CFF either, but the concepts are the same. When reading the mainframe file, you are depending on the DCB to manage your reads. If, for example, your copybooks indicate fixed record lengths for each record type, then you are not reading a variable length record. It could be as simple as that.

Good luck.

Posted: Mon Dec 24, 2012 11:15 am
by pradkumar
Merry Chrismas everyone.

I still have some problem on this one with an additional question:

I was told in Variable Block mainframe file, in the beginning of each record, there is a record prefix which indicates the actual length of the current record. So is DataStage able to read and understand the record prefix? If not, how does DataStage delimit the records in Variable Block file?

Any help would be Appreciated. Happy holidays!

Posted: Mon Dec 24, 2012 2:07 pm
by ray.wurlod
If there is a length prefix, then it will be declared in the COBOL FD and, yes, if it exists DataStage can read it. However you may have to design in the "understanding" part, perhaps by specifying {prefix} in the record schema.

Posted: Wed Dec 26, 2012 9:44 am
by bobyon
Unfortunately I've not used the CFF stage much either, but like Craig have quite a bit of experience with mainframe and variable lenght files.

My only contribution to the conversation at this point is to say that the 4 bytes at the beginning of the variable length record are not always apparent when viewing the file on the mainframe so don't be sure it is not there simply because you don't see it when looking at it on the mainframe. It depends on which tool you are using to display it,