MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Handle Comp value in a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Amitc_23
Beginner


Joined: 22 Jan 2003
Posts: 1
Topics: 1
Location: Gurgaon

PostPosted: Mon Aug 03, 2015 7:22 am    Post subject: Handle Comp value in a file Reply with quote

Hi

I am getting some problem while handling a comp value in a file. Actually there are two fields in the format.

20150003
051C0014

First one is date x'2005115C'
Second one is a count x'00000134'

to read them I defined as

15 detail-date pic 9(7) comp-3.
15 detail-vol pic 9(8) comp-3.

Detail-date is read ok, but detail-vol is giving a S0c7 while executing. If i give it as 9(7) comp-3 , it reads 13 only instead of 134, and if i give 9(9) comp-3 it reads 1340 istead of 134. 9(8) comp-3 abends.

Please advise how should i define working storage so as to read them correctly
Date as 2005115 and Volume as 134.

Thanks
_________________
Cheers

Amit
Back to top
View user's profile Send private message
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Mon Aug 03, 2015 8:31 am    Post subject: Reply with quote

It appears like you should be defining the last 4 bytes as S9(8) BINARY or COMP or COMP-5. Not COMP-3 (packed decimal). See Language Reference Manual. And X'134' is decimal 308. Is 00000134 the actual contents in memory? Decimal 134 is X'86'.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon Aug 03, 2015 8:46 am    Post subject: Reply with quote

The second field is not a packed-decimal field, as Terry has pointed out, it is a binary field (until you determine otherwise).

You can use a USAGE of BINARY/COMP/COMP-4, they are all the same, or COMP-5.

Which you choose depends on the maximum value of the field.

If it can be greater than 99,999,999 then use COMP-5. If not, use the other.

For BINARY/COMP/COMP-4 use a PIC of 9(8) (or S9(8) if the value may also be negative).

For COMP-5, use 9(9) or S9(9).

You compiled your program with NUMPROC(NOPFD). If you had used NUMPROC(PFD), you attempt with COMP-3/PACKED-DECIMAL 9(7) would have given an S0C7, and the 9(9) quite possibly so (can't be sure, as we can't see what is after the final byte of your field).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group