View previous topic :: View next topic
|
Author |
Message |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi all,
I am new to PL/1.
Rec Struct is like,
Code: |
DCL 01 EMPST,
05 ENO FIXED DEC(4,0),
05 EDESC CHAR(76); |
For this Struct, I have entered values in PS as,
Code: |
1200NORMAL
1201GOOD |
The Rec.., Length of this PS is 80.
While reading this file, I got this error.
IBM0121S ONCODE=21 The RECORD condition was raised because the length of the record variable was less than the record length ('ONFILE'= EMPFL).
My doubt is ,
Can we enter the value 1200 for the FIXED DEC(4,0). I assume this will take 4 bytes in file and max value is 9999??
Or
value should be given in HEX ON mode?
If i am wrong,
And for FIXED DEC(4,0), What is the max value? and what is the memory size?
Please resolve this? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
And one thing from manual,
While using FIXED DEC(q,w), q should be odd number. If it's even, it will take next odd number.
So, I have to change my FIXED DEC(4,0)??? |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
Isn't FIXED DEC packed-decimal? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
I am not sure. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
Are you gonna find out? It seems relevant. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Yes, Phrzby Phil.
FIXED DEC is packed decimal. It takes two digits per byte.
We have to enter the values in PS directly, means HEX ON should be used.
Say, FIXED DEC is almost same as COBOL - COMP3 datatype.
Do correct me if I am wrong. |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Hi,
As gnanas already said, FIXED DEC is packed decimal.
It takes 1/2 byte per each digit and extra half byte for sign.
Take odd and even contexts as below
FIXED DEC(5,2) takes
5*(1/2 byte) + 1/2 byte for sign = 3 bytes
FIXED DEC(4,2) or FIXED DEC(4,0) (as is the case here).
4*(1/2 byte) + 1/2 byte for sign = 2 and half bytes. But the remaining 1/2 byte is wasted. So it too occupies 3 bytes.
To avoid the half byte wastage, it is always preferred to use odd values in fixed decimal. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Thanks Srihari. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
Making the length odd doesn't avoid "wasting" a half byte. If your number will never need the left most digit, then it's "wasted" anyhow - always = 0.
What the odd length does do, in COBOL at least, is avoid the extra generated code to remove the leftmost digit when you have even length, as COBOL does not let you have a value that exceeds your PIC definition.
That is:
01 VARA PIC 9(2) COMP-3
then
MOVE 123 TO VARA
will result in a value of 23. COBOL generated code to ensure restruction to 2 digits. That is the "waste" that is avoided by odd length. |
|
Back to top |
|
|
cheryala
New User
Joined: 20 Mar 2006 Posts: 46
|
|
|
|
Hi Gnanas,
Quote: |
IBM0121S ONCODE=21 The RECORD condition was raised because the length of the record variable was less than the record length ('ONFILE'= EMPFL). |
Your PS fine record length is 80 and your record structure is of length 79bytes (Fixed dec(4,0) occupies 3 bytes). So you have to make your record structure to hold 80byte record to avoid RECORD condition that you are getting...
Regards,
Cheryala |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
I got it. Thanks Cheryala |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
if the record are being built using an editor why not use a "PIC" definition???
01 card
02 number pic'zzz9'
02 alphanum char(96) |
|
Back to top |
|
|
Max Payne
New User
Joined: 13 Dec 2007 Posts: 10 Location: Shanghai
|
|
|
|
FIXED DEC in PL1 is equal to COMP-3 in Cobol
eg: FIXED DEC(5,1) = 9(4)v9(1) comp-3 |
|
Back to top |
|
|
|