Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Interesting Z/OS & COBOL Quirk

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 147
Location: Columbia, MO

PostPosted: Thu Sep 27, 2007 12:33 am    Post subject: Interesting Z/OS & COBOL Quirk
Reply with quote

I am retrofitting an old program that hasn't been touched since Y2K and had something very interesting happened that may benefit someone else.

This old program had the output record defined in the FD area - like most old programs. The record contains two parts: a "header" section and a "trailer" section (for lack of a better description - note that this is NOT true header and trailer records; just part of a single record).

The "header" is repeated for as many qualfiying "trailer" records with the only differences in the records being the trailing information. So the program builds the header information one time, then loops through a section to build the trailer section, writing a record for each occurance.

When testing, I found that the header section was only appearing on the first record of the series - not the subsequent records that should have shared the data. Now this is great on a report, but not in a data file.

What was happening? icon_question.gif It's really freaky to step through your code in Expeditor and watch your data disappear after the WRITE is executed! I have never heard of a "destructive" Write in COBOL!

I was told by senior personnel that Z/OS allocates FD storage areas dynamically, so where the FD storage area is on one pass may not be where it is on the second; although Working Storage remains static.

The solution was to build the record in Working Storage and then write the output record fom that area. Bingo - works great and all the data shows up.

Every day is a new adventure..... icon_rolleyes.gif
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Sep 27, 2007 12:40 am    Post subject:
Reply with quote

Oh my...You never expect the prior record's data to be in the 01 level of an FD, unless you are writing unblockes and single buffer......
The 01 is mearly a dsect view into the I/O buffer, is changes location for each record in the block...That's why sometimes the "apply write only" is nice for large differing variable length output....
Gee, Socker Dad, you must be a "young'n"....
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 147
Location: Columbia, MO

PostPosted: Fri Sep 28, 2007 4:16 am    Post subject: Reply to: Interesting Z/OS & COBOL Quirk
Reply with quote

icon_lol.gif

Thanks for the age complement!

No - I have been programming for about 20 years - I've just never seen a program try to reuse FD storage before. Oh, what a sheltered life I've led!

See - I am a GOOD programmer - I ALWAYS use working storage!
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Sep 28, 2007 4:37 am    Post subject:
Reply with quote

socker_dad wrote:
I am a GOOD programmer - I ALWAYS use working storage!
Things change, but when I learned, using the buffer was just fine, as long as you did not "expect" things to still be there....
working storage or the 01 of the FD, it all depended on what you needed and wanted.... icon_wink.gif
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 149
Location: Ottawa Canada

PostPosted: Fri Sep 28, 2007 8:00 pm    Post subject:
Reply with quote

With the FD buffer you must take care not to reference the buffer after the file has been closed. I can still remember my COBOL teacher warning us about this 25 years ago. I did debug somebody's problem that was caused by exactly this problem. They referenced the buffer but the buffer was no longer there.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Sep 28, 2007 8:32 pm    Post subject:
Reply with quote

Hello,

I've not "tried" this recently
Quote:
With the FD buffer you must take care not to reference the buffer after the file has been closed.
but once upon a time, referencing the buffer after the close, could cause an abend - the memory had been released and the address became invalid.

Referencing the buffer after a write, got whatever was in that part of the buffer - each write re-positions the displacement into the buffer for the "next" write. You might get pure junk and abend (if you were lucky) or you might get whatever data was already there from a previous write - sometimes very tough to recognize/resolve.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Sep 28, 2007 10:27 pm    Post subject:
Reply with quote

the original program probably ran in the days of bufno=1 was the default.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Sep 28, 2007 11:36 pm    Post subject: Reply to: Interesting Z/OS & COBOL Quirk
Reply with quote

Quote:
the original program probably ran in the days of bufno=1 was the default.
And lrecl = blksize. . . . icon_wink.gif
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 147
Location: Columbia, MO

PostPosted: Sat Sep 29, 2007 2:58 am    Post subject: Reply to: Interesting Z/OS & COBOL Quirk
Reply with quote

Gosh - I think it's time to invest in a retirement home.....ya'll are making me feel real old now!!! icon_lol.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Sep 29, 2007 3:06 am    Post subject: Reply to: Interesting Z/OS & COBOL Quirk
Reply with quote

Hmmm. . . Thought that would make you feel younger, not older. . . .

d
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 3:52 am    Post subject: Re: Reply to: Interesting Z/OS & COBOL Quirk
Reply with quote

socker_dad wrote:
Gosh - I think it's time to invest in a retirement home.....ya'll are making me feel real old now!!! icon_lol.gif
Sorry, you're are paying my SS benefits...grin...
In the "Old'n days", a lot of print outputs were unblocked and (dang I can't think of it) single buffered to allow the existing data in the last write to exist to the next write...
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Sep 29, 2007 4:48 am    Post subject: Reply to: Interesting Z/OS & COBOL Quirk
Reply with quote

Once upon a time (nah, this won't be a fairy tale) printers and "punches" were called "unit record" devices - no blocking possible.

This was after canned beer, but way before aluminum, easy-open cans icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us