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

FIXED DEC(4,0) value in file???


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gnanas N

Active Member


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

PostPosted: Mon Dec 24, 2007 4:20 pm
Reply with quote

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
View user's profile Send private message
Gnanas N

Active Member


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

PostPosted: Mon Dec 24, 2007 4:31 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Mon Dec 24, 2007 6:42 pm
Reply with quote

Isn't FIXED DEC packed-decimal?
Back to top
View user's profile Send private message
Gnanas N

Active Member


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

PostPosted: Mon Dec 24, 2007 6:44 pm
Reply with quote

I am not sure.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Wed Dec 26, 2007 5:40 am
Reply with quote

Are you gonna find out? It seems relevant.
Back to top
View user's profile Send private message
Gnanas N

Active Member


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

PostPosted: Wed Dec 26, 2007 10:26 am
Reply with quote

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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Wed Dec 26, 2007 10:47 am
Reply with quote

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
View user's profile Send private message
Gnanas N

Active Member


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

PostPosted: Wed Dec 26, 2007 11:31 am
Reply with quote


Thanks Srihari.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Wed Dec 26, 2007 7:16 pm
Reply with quote

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
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Wed Jan 02, 2008 5:25 pm
Reply with quote

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
View user's profile Send private message
Gnanas N

Active Member


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

PostPosted: Wed Jan 02, 2008 7:01 pm
Reply with quote

I got it. Thanks Cheryala
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Jan 02, 2008 7:59 pm
Reply with quote

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
View user's profile Send private message
Max Payne

New User


Joined: 13 Dec 2007
Posts: 10
Location: Shanghai

PostPosted: Fri Jan 04, 2008 7:49 am
Reply with quote

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
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 -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts how to eliminate null indicator value... DB2 7
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top