View previous topic :: View next topic
|
Author |
Message |
cser_oxygen
New User
Joined: 25 Oct 2006 Posts: 33
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
cser_oxygen
New User
Joined: 25 Oct 2006 Posts: 33
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Robert,
thanks for the expansion/correction.
That would account for spaces in the OPs subsequent record area. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
cser_oxygen
New User
Joined: 25 Oct 2006 Posts: 33
|
|
|
|
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
Thank you for all the replies! |
|
Back to top |
|
|
cser_oxygen
New User
Joined: 25 Oct 2006 Posts: 33
|
|
|
|
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! |
|
Back to top |
|
|
|