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
 
Why FD variable initializes automatically?

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

New User


Joined: 25 Oct 2006
Posts: 33

PostPosted: Mon Nov 10, 2008 2:31 pm    Post subject: Why FD variable initializes automatically?
Reply with quote

I didn't use FROM, just MOVE some values into the FD variables and WRITE into the file, then I found that after WRITE, the FD variables will be initialized automatically... Just wondering why it happened?

Thanks!
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Nov 10, 2008 3:00 pm    Post subject:
Reply with quote

Quote:

then I found that after WRITE, the FD variables will be initialized automatically


You did not find what you think you found.
Back to top
View user's profile Send private message
cser_oxygen

New User


Joined: 25 Oct 2006
Posts: 33

PostPosted: Mon Nov 10, 2008 3:16 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
Quote:

then I found that after WRITE, the FD variables will be initialized automatically


You did not find what you think you found.


For example:

FD FILE-NAME.
01 RECORD-NAME PIC XXX.

In the pgm:

MOVE ABC TO RECORD-NAME

WRITE RECORD-NAME

Then:
DISPLAY RECORD-NAME

It will show empty, means no data in variable RECORD-NAME
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Nov 10, 2008 3:47 pm    Post subject:
Reply with quote

When you write directly from the buffer (WRITE without the workarea option),
each successive WRITE will position the register, which is assigned to the buffer, to the next record position w/in the buffer.

It is possible after the 1st write that the next record position in the buffer seems to be initialized. But if it is initialized to anything, it would be low-values.

IBM COBOL does not guarentee any 'automatic' initialization other than that explilcitly required due to
a VALUE clause of data element description
or
the INITIAL clause of the PROGRAM-ID paragraph.

If you had a block size of one (1), I imagine you would find that after the WRITE, your display would be that of the record just written.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Nov 10, 2008 5:33 pm    Post subject: Re: Why FD variable initializes automatically?
Reply with quote

cser_oxygen wrote:
I didn't use FROM, just MOVE some values into the FD variables and WRITE into the file, then I found that after WRITE, the FD variables will be initialized automatically... Just wondering why it happened?

Thanks!


It would be a bad idea to write a program based on that assumption.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Mon Nov 10, 2008 6:07 pm    Post subject:
Reply with quote

Quote:
IBM COBOL does not guarentee any 'automatic' initialization other than that explilcitly required due to
a VALUE clause of data element description
or
the INITIAL clause of the PROGRAM-ID paragraph.
On the other hand, LE does have the STORAGE option to automatically initialize storage to a given value -- and it can be turned on at the site level by default.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Nov 10, 2008 6:32 pm    Post subject:
Reply with quote

Robert,
thanks for the expansion/correction.
That would account for spaces in the OPs subsequent record area.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Nov 10, 2008 6:41 pm    Post subject:
Reply with quote

The manual clearly states:
"6.2.40.5 WRITE for sequential files

The maximum record size for sequential files is established at the time the file is created and cannot subsequently be changed.

After the WRITE statement is executed, the logical record is no longer available in record-name-1 unless either:


The associated file is named in a SAME RECORD AREA clause (in which case, the record is also available as a record of the other files named in the SAME RECORD AREA clause)

The WRITE statement is unsuccessful because of a boundary violation.


In either of these two cases, the logical record is still available in record-name-1."
Copyright IBM
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: Mon Nov 10, 2008 9:30 pm    Post subject:
Reply with quote

Hello,

Something that has caused problems for very many systems/programs is that when there have been "enough" writes to a file, the address for the "next" write is an address that has been written from previously. If the output record area is not completely, properly initialized, some value(s) from some previous record are written and can be a nightmare to diagnose.

If it is early in the run and some field is unitialized, it is usually easier to detect than completely valid data that is "left over" from some previous write.
Back to top
View user's profile Send private message
cser_oxygen

New User


Joined: 25 Oct 2006
Posts: 33

PostPosted: Mon Nov 10, 2008 10:29 pm    Post subject: Re: Why FD variable initializes automatically?
Reply with quote

Craq Giegerich wrote:
cser_oxygen wrote:
I didn't use FROM, just MOVE some values into the FD variables and WRITE into the file, then I found that after WRITE, the FD variables will be initialized automatically... Just wondering why it happened?

Thanks!


It would be a bad idea to write a program based on that assumption.


I just did some test on this icon_razz.gif

Thank you for all the replies!
Back to top
View user's profile Send private message
cser_oxygen

New User


Joined: 25 Oct 2006
Posts: 33

PostPosted: Wed Nov 02, 2016 11:01 pm    Post subject:
Reply with quote

Just happen to be back to ibmmainframes today.
After 10 years working this field, I have to admit I am being very selfish, just search for answers and walk away, zero contribute...

Today I thought why not take a look what I have posted previously... so here i am...

Reading my 8 years back post still moves me... what a great forum! icon_exclaim.gif icon_exclaim.gif icon_exclaim.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 Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

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