IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

what are the values may come after a write statement..


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prabe

New User


Joined: 09 Mar 2007
Posts: 17
Location: kerala

PostPosted: Wed Mar 28, 2007 10:06 am
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Mar 28, 2007 10:17 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Mar 28, 2007 2:06 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Mar 28, 2007 5:24 pm
Reply with quote

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
View user's profile Send private message
prabe

New User


Joined: 09 Mar 2007
Posts: 17
Location: kerala

PostPosted: Thu Mar 29, 2007 11:57 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Mar 30, 2007 12:09 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top