Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Gnanas N

Active Member


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

PostPosted: Mon Dec 24, 2007 4:20 pm    Post subject: FIXED DEC(4,0) value in file???
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: 788
Location: Chennai, India

PostPosted: Mon Dec 24, 2007 4:31 pm    Post subject:
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

Active Member


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

PostPosted: Mon Dec 24, 2007 6:42 pm    Post subject:
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: 788
Location: Chennai, India

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

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

Active Member


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

PostPosted: Wed Dec 26, 2007 5:40 am    Post subject:
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: 788
Location: Chennai, India

PostPosted: Wed Dec 26, 2007 10:26 am    Post subject:
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    Post subject:
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: 788
Location: Chennai, India

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


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

Active Member


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

PostPosted: Wed Dec 26, 2007 7:16 pm    Post subject:
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    Post subject: Reply to: FIXED DEC(4,0) value in file???
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: 788
Location: Chennai, India

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

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Wed Jan 02, 2008 7:59 pm    Post subject: Reply to: FIXED DEC(4,0) value in file???
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us