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

how to read a Unformatted file


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

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Fri Jan 18, 2008 11:32 am
Reply with quote

Hi,

how to define and read a unformatted file in cobol program. I will be getting the file as U type. ie. Unformatted.
when i seen the properties of this U file, the LRECL is 0.

How to define in file section. How to handle this unformatted file in cobol program. Is it different from FB and VB.

Help me in this regard.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Jan 18, 2008 11:56 am
Reply with quote

Bhaskar,
Quote:
how to define and read a unformatted file in cobol program.

Refer 'RECORDING-MODE' and 'read' statements in the COBOL manual.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Jan 18, 2008 9:02 pm
Reply with quote

Hello,

If the file is "unformatted", how will you process it?

What kind of data will/does it contain?

What does the data look like if you view it in tso/ispf or some other editor?
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 631
Location: Wisconsin

PostPosted: Fri Jan 18, 2008 9:20 pm
Reply with quote

U doesn't mean unformatted, it means the blocking for the file is unknown. If the records actually have a layout but have unknown blocking, you would have to read a byte stream and look for indicators that you have read a whole record.

Things just don't deal well with U though.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1049
Location: Richmond, Virginia

PostPosted: Sat Jan 19, 2008 6:30 am
Reply with quote

Dick's question is the key - what are you doing with this file?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 20, 2008 9:27 am
Reply with quote

Hi Bhaskar,

Whoever created this file holds the key to processing it. If you don't know the name of the pgm that created the file, search the JCL/sourcelib(s) at your site to find it.

Then study the code. It will tell you how to acess the data in the file. Then do what you need to do.

PS. The blocks in the file can be either fixed length (as in a PDS directory) or variable in length, but will not contain RDWs or BDWs as V/VB files do.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jan 23, 2008 4:56 am
Reply with quote

While we're waiting for Bhaskar to reply...

Steve said:
Quote:
you would have to read a byte stream and look for indicators that you have read a whole record.

Actually, U records can be processed very much like V recs:

Use the same RECORD VARYING.... DEPENDING ON .... clause in the FD or multiple 01 rec descriptions.

READ the file and chk the DEPENDING ON field for the length of the block.
Fill the DEPENDING ON field before issuing each WRITE.

The only difference between V and U is that U recs use the same length in the pgm and JCL, and, there's no block (or is it rec?) w/format U.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Jan 23, 2008 5:07 am
Reply with quote

Quote:
The only difference between V and U is that U recs use the same length in the pgm and JCL, and, there's no block (or is it rec?) w/format U.


record format undefined, blksize xxxxx
at every read or write operation up to xxxxx bytes are going to transferred
from/to the external medium

from an I/O point of view the logical record is always a full block..

there is no guarantee at all that each block(record) will be of the same size
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 631
Location: Wisconsin

PostPosted: Wed Jan 23, 2008 5:18 am
Reply with quote

If it is just a big XML stream you could be fine too. Then who cares what the layout of the data is, just use the cobol XML PARSE.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jan 23, 2008 7:07 pm
Reply with quote

Enrico,

You quoted my post and then commented. I'm not sure of what you disagreed.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Jan 23, 2008 8:38 pm
Reply with quote

Hi Guys,

Maybe i'm still in the fog, but i read it as additional clarification rather than a difference. . .

If i'm still in the fog, shine a light my way. . . icon_smile.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jan 23, 2008 10:38 pm
Reply with quote

Agreement is usually prefaced with: "To expand on Jack's EXCELLENT comments, ......" icon_biggrin.gif

I think Enrico may have thought that I was saying that all blocks(recs) in a fmt U file are the same. What I meant was that fmt U recs, unlike fmt V recs, don't use a n RDW.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Jan 23, 2008 11:17 pm
Reply with quote

Quote:
Agreement is usually prefaced with: "To expand on Jack's EXCELLENT comments, ......"
heh heh heh. . .

d
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Jan 24, 2008 1:36 pm
Reply with quote

Hi Jack,
I was not disagreing icon_biggrin.gif

Quote:
... there's no block (or is it rec?) w/format U.


I was lazy not to quote the exact fragment I wanted to comment on...

I have always, in my loong years of IT practicing, spoken about

blocks when seen from the point of view of the data management
records when seen from the point of view of the program

maybe was the question mark which made me try to clarify
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jan 24, 2008 7:22 pm
Reply with quote

Hi Enrico,

The reason I used the "?" is that I noticed COBOL prohibits the use of the "BLOCK CONTATNS ..." clause for fmt U files, but on the other hand, in the JCL, the DD stmt requires "BLKSIZE= ..." when creating one.

I'm easily confused.
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 Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top