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

Reading a file using copybook


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

New User


Joined: 30 Mar 2007
Posts: 7
Location: Chennai

PostPosted: Tue Apr 01, 2008 4:11 pm
Reply with quote

Hi,

I am fairly new to the mainframe world. I have the following requirement.

I have to read a file using copybook.

I am not able to read the file while using DEBIT-BALANCE PIC S9(13) in the copybook but I am able to read the file when I use DEBIT-BALANCE PIC X(14). I cannot use PIC X(14) in the copybook since DEBIT-BALANCE is a amount field and I need to process it using a program.

Is there some way by which I can read the copybook using S9(13) for DEBIT-BALANCE.

Regards,
Elan
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Apr 01, 2008 4:34 pm
Reply with quote

Quote:
I am not able to read the file while using DEBIT-BALANCE PIC S9(13) in the copybook

What is the error message and its code?

It seems...
Change the data type for DEBIT-BALANCE in record structure in program from X(14) to S9(13).
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 01, 2008 5:14 pm
Reply with quote

we realize you are new - but, please, what do you mean read a file using a copybook? You can not do that in cobol. file-aid, ya, but you do not read files with copybooks.

you can define a record image with a copybook. as long as the length of the copybook matches the dcb parms of the file, you can read the file without any problem. now, you might get a s0c7 if your copybook does not match your files' record layout.

but the only error you will have is the open because of dcb mismatch.

might help us to help you if you were to tell us the error - and not your interpretation of the error, the exact error that mvs provided you during the execution of your program.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Apr 01, 2008 10:32 pm
Reply with quote

define in your copybook

05 DEBIT-BALANCE s9(13).
05 DEBIT-BALANCE-x redefines DEBIT-BALANCE pic x(13).

after read convert your x(13) to numeric using

compute ws-DEBIT-BALANCE = function numval(DEBIT-BALANCE-x)

try this ....
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Apr 02, 2008 12:04 am
Reply with quote

DEBIT-BALANCE PIC S9(13)
DEBIT-BALANCE PIC X(14)

Are different sizes s9(13) and x(13) would be the same size or s9(14) and x(14). The S does not count in the size of a numeric field.
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: Wed Apr 02, 2008 12:06 am
Reply with quote

Hello,

Quote:
try this ....
Maybe, but it would be better if Elan replied to these requests. . .

Quote:
What is the error message and its code?


Quote:
might help us to help you if you were to tell us the error - and not your interpretation of the error, the exact error that mvs provided you during the execution of your program.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top