what is the output of the following?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

what is the output of the following?

Postby dhiviya » Thu Nov 01, 2007 10:33 am

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.
dhiviya
 
Posts: 4
Joined: Mon Oct 29, 2007 4:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is the output of the following?

 

Re: what is the output of the following?

Postby CICS Guy » Thu Nov 01, 2007 3:06 pm

It depends on the buffering of the file, either the "Company" will still be there or not......What does the SELECT look like?
CICS Guy
 
Posts: 255
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: what is the output of the following?

Postby dick scherrer » Thu Nov 01, 2007 7:48 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: what is the output of the following?

Postby cravi_pdy » Tue Nov 13, 2007 5:14 pm

It is very clear that the output data will be written as
BillCompany
Jim
cravi_pdy
 
Posts: 5
Joined: Tue Nov 13, 2007 5:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is the output of the following?

Postby CICS Guy » Tue Nov 13, 2007 5:21 pm

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'?
CICS Guy
 
Posts: 255
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: what is the output of the following?

Postby cravi_pdy » Tue Nov 13, 2007 5:26 pm

Move “Bill” to field1.
Move “Company” to field2.
Write Output-record.
move space to out-rec.

Move “Jim” to field1.
Write Output-record.
cravi_pdy
 
Posts: 5
Joined: Tue Nov 13, 2007 5:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is the output of the following?

Postby CICS Guy » Tue Nov 13, 2007 8:03 pm

cravi_pdy wrote:move space to out-rec.
Better.......
CICS Guy
 
Posts: 255
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post