Page 1 of 1

what is the output of the following?

PostPosted: Thu Nov 01, 2007 10:33 am
by dhiviya
hi,
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.

Re: what is the output of the following?

PostPosted: Thu Nov 01, 2007 3:06 pm
by CICS Guy
It depends on the buffering of the file, either the "Company" will still be there or not......What does the SELECT look like?

Re: what is the output of the following?

PostPosted: Thu Nov 01, 2007 7:48 pm
by dick scherrer
Hello,

What will be written to the Output file when the last write statement is executed
To quote an old IBM caution "The result may be unpredictable".

Another answer is - it depends (as mentioned by CG). If it is not "Company", it may be literally anything - from all x'00' to all x'ff' and any value in between.

If you did this in working-storage, the result would be predictable.

Re: what is the output of the following?

PostPosted: Tue Nov 13, 2007 5:14 pm
by cravi_pdy
It is very clear that the output data will be written as
BillCompany
Jim

Re: what is the output of the following?

PostPosted: Tue Nov 13, 2007 5:21 pm
by CICS Guy
cravi_pdy wrote:It is very clear that the output data will be written as
BillCompany
Jim
No, it is not 'very' clear, data not initialized is 'unpredictable'.....
What do you think is in the field following 'Jim'?

Re: what is the output of the following?

PostPosted: Tue Nov 13, 2007 5:26 pm
by cravi_pdy
Move “Bill” to field1.
Move “Company” to field2.
Write Output-record.
move space to out-rec.

Move “Jim” to field1.
Write Output-record.

Re: what is the output of the following?

PostPosted: Tue Nov 13, 2007 8:03 pm
by CICS Guy
cravi_pdy wrote:move space to out-rec.
Better.......