input and output file description.



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

input and output file description.

Postby dhoomphatash » Sat May 15, 2010 2:58 am

I am trying to copy one records from an input file, say FILE1, to an output file,say FILE2. the input and output files are sequentially organized and access mode is sequential too. Now my question is do I have to have the same file description of the files.

like say.

.....
PROGRAM DIVISION.
FD FILE1.
01 FILE1-REC.
    05 NAME PIC X(10).
    05 PHONE-NUMBER PIC 9(13).
    05 FILLER PIC X(57).


Now should the output file description be same or can vary if needed?


FD FILE2.
01 FILE2-REC.
    05 NAME1 PIC X(10).
    05 PHONE-NUMBER1 PIC 9(13).
    05 FILLER PIC X(57).


working on z10 record length 80.
dhoomphatash
 
Posts: 10
Joined: Sat May 15, 2010 2:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: input and output file description.

 

Re: input and output file description.

Postby Robert Sample » Sat May 15, 2010 3:35 am

As long as the total record size is the same, you can define either file any way you want. You can even have multiple record layouts.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: input and output file description.

Postby dick scherrer » Sat May 15, 2010 4:11 am

Hello and welcome to the forum,

Just make sure the input data matches the input layout(s). Otherwise strange results or abends may happen.
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: input and output file description.

Postby Anuj Dhawan » Sat May 15, 2010 3:45 pm

Why not just try that?
Anuj
Anuj Dhawan
 
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

Re: input and output file description.

Postby dhoomphatash » Sat May 15, 2010 7:38 pm

I tried it but a SOC4 error comes up to abend the program.
So thought of just to make sure I am not wrong with that concept.
dhoomphatash
 
Posts: 10
Joined: Sat May 15, 2010 2:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: input and output file description.

Postby dhoomphatash » Sat May 15, 2010 7:45 pm

just another question... can 123.45 be put in a variable with picture

pic 999v99.
or
pic X(6).
dhoomphatash
 
Posts: 10
Joined: Sat May 15, 2010 2:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: input and output file description.

Postby Robert Sample » Sat May 15, 2010 7:55 pm

Yes, and yes. Assuming USAGE DISPLAY, the first variable would be stored as X'F1F2F3F4F5' while the second would be stored as X'F1F2F34BF4F5'
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: input and output file description.

Postby dick scherrer » Sat May 15, 2010 10:39 pm

Hello,

The s0c4 is more likely caused by referring to the fields when they are "not available" - such as when the file is not open or after a read that was not successful..
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: input and output file description.

Postby dhoomphatash » Sun May 16, 2010 8:52 am

Thanks for the help. :)
dhoomphatash
 
Posts: 10
Joined: Sat May 15, 2010 2:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: input and output file description.

Postby dick scherrer » Sun May 16, 2010 9:45 am

You're welcome - does this mean the program is now working?

If yes, it will help someone later if you post the solution :)

d
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

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post