View previous topic :: View next topic
|
Author |
Message |
prabe
New User
Joined: 09 Mar 2007 Posts: 17 Location: kerala
|
|
|
|
i have a FD section with record name WS-RECORD ......
then after executing the statement WRITE WS-RECORD what will the values in the WS-RECORD , only spaces or is there any chance to come values other than spaces? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi There,
I think it will contain the value which u have populated in it befor writing the record in output file |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Etka, only if it is an unblocked file and unbuffered or single buffered.
Prabe, the 01 in an FD is (similar to the Linkage Section) only a pointer to one of the output buffers containing the block being built. Old data can remain. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Contents of an FD record after writing are undefined, for the reasons stated above.
Many programmers use WORKING STORAGE variables, e.g., W-PAY-RECORD, populate this, then WRITE FILENAME FROM WS-PAY-RECORD.
This guarantees your values remain, to be either accessed by your code or included in the next write.
BTW - your choice WS-RECORD in an FD is not a good name, as WS- usually means WORKING STORAGE, and the FD is not in WORKING STORAGE. |
|
Back to top |
|
|
prabe
New User
Joined: 09 Mar 2007 Posts: 17 Location: kerala
|
|
|
|
2. Consider the following statements. What will be written to the Output file when the last write statement is executed.
FD Out-rec.
01 Output-record.
05 field1 pic X(4).
05 field2 pic X(7).
Procedure Division.
??
Move ?Bill? to field1.
Move ?Company? to field2.
Write Output-record.
Move ?Jim? to field1.
Write Output-record.
i have given above my full question
i tried with
Move ?Bill? to field1.
Move ?Company? to field2.
Write Output-record.
Write Output-record.
Write Output-record.
Move ?Jim? to field1.
Write Output-record.
then i got output as follows( two blank lines in between two records)
BillCompany
Jim |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You got whatever happened to be in the output buffer area - you will not always get "blanks".
As "Jim" was the last value moved to the output area and written, Jim is the last data written. Notice that in none of the writes after the first one was the value "Company" progagated.
As was suggested above, to retain what was previously written in the data fields, write FROM a working-storage item. You cannot count on what will be in the FD fields after a write. |
|
Back to top |
|
|
|