Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AIX COBOL & VARIABLE LENGTH FILES

Status
Not open for further replies.

pthboss

IS-IT--Management
Jan 15, 2003
8
0
0
US
I am having a very hard time trying to create a true variable length record using IBM COBOL on an AIX UNIX. Is this even possible. The record descriptor has the correct record length but the program or UNIX wants to place null characters in the remainder of the record up to the maximum record length.

I have tried RECORDING MODE IS V, RECORDING MODE is U, RECORD CONTAINS 112 to 14907 CHARACTERS, RECORD IS VARYING, RECORD IS VARYING IN SIZE FROM 112 TO 13907 CHARACTERS.

I have tried a number of BLOCK CONTAINS combinations.

Nothing seems to work.

I am at your mercy. Please help.
 
Did you define your output file with an "FD"? In your earlier post you defined it with an "SD". Defining it with an "SD" probably would confuse the compiler if it did not detect the error.
 
Hi Boss,

Why don't you pick the solution you like best, then show us the SELECT stmt(s), the FD(s) SORT stmt RELEASE/RETURN stmts, and error msgs, if any and what you know about the I/P O/P. I might help us understand the problem better.

Thanx, Jack.
 
Hi Boss,

Here's what's done to copy a VB file when the length of each rec is not known. You might be able to apply it to your sort problem.
Code:
fd infile
.
.
record varying from 1 to xxx depending on ws-len.
01  inrec.
    05  f  pix x occurs 1 to xxx depending on ws-len.

fd otfile
.
.
record varying from 1 to xxx depending on ws-len.
01  otrec.
    05  f  pix x occurs 1 to xxx depending on ws-len.

WS
01 ws-len pic 9(005) comp.

PD

read infile
write otrec from inrec
Notes:

After the read is performed ws-len contains the length of the rec just read. Since we write from the iprec not changing its length the write uses the value contained in ws-len. If we wanted to change the length of the rec before writing we could add something to ws-len before the write is performed. Remember though, we have to move the additional data to the iprec because that's where we're writing from.

We could have built an entirely new oprec in WS, but we must move the new len to ws-len before we write. We could have used a separate len for the oprec, butwe have to then maintain it separately.

The things to remember is when you use varying...depending on... the length of the new rec is returned in the ODO object field. When writing an ODO rec the field must be populated w/the length before the write.

If I left something out, somebody will set me straight.:)

HTH, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top