Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
somnath

New User

Joined: 21 Mar 2005
Posts: 18
Location: India

 Posted: Fri Jan 12, 2007 8:06 pm    Post subject: Moving Spaces to a numeric field? Hi All, I have a field B (Pic 9(9)V99) which redifines field A (Pic X(11)). Now A contains spaces. I am moving field B to another field C (Pic 9(9)V99). C is being populated with 0. How can it be possible? Thanks & Regards, Somnath.

DavidatK

Active Member

Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

 Posted: Fri Jan 12, 2007 9:46 pm    Post subject: Re: Moving Spaces to a numeric field? Somnath, This is due to an idiosyncrasy of COBOL and ZONED DECIMAL numbers. First, a definition of ZONED DECIMAL (External Decimal) from the IBM Manual: External Decimal Items are sometimes referred to as zoned decimal items. Each digit of a number is represented by a single byte. The 4 high-order bits of each byte are zone bits; the 4 high-order bits of the low-order byte represent the sign of the item. The 4 low-order bits of each byte contain the value of the digit. The zone bits on all but the sign zone of zoned decimal numbers is hex ?F? (all bits on). The zone bits of the sign zone are as follows. Unsigned = hex ?F?, positive = hex ?C?, negative = ?D?. So, a zoned decimal unsigned number 00000 = hex x?F0F0F0F0F0?. The hex representation of 5 spaces is x?4040404040?. As you can see, the only difference between these two variables is the zone bits. When you moved A to C, COBOL moved x?4040404040? to C and then because C is defined as unsigned, set the sign zone to hex ?F? so you now have x?40404040F0?. You could use this variable in any way; the zones of all but the sign are ignored.
somnath

New User

Joined: 21 Mar 2005
Posts: 18
Location: India

 Posted: Tue Jan 16, 2007 11:29 am    Post subject: Thanks a lot Dave. Somnath.
Sasi Kiran Patha
Warnings : 2

New User

Joined: 19 Nov 2006
Posts: 73

 Posted: Sat Jan 20, 2007 12:59 pm    Post subject: Re: Moving Spaces to a numeric field? An addition to the above query by somnath, When i move A to C and display C it is displayed as 000 when i move A to B and display C it is displayed as 0. why is the displatity in the number of zero s that are displayed for the same variable C. How does it actually matter any where if at all. Regrds, Sasi Patha.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Sun Jan 21, 2007 6:23 am    Post subject: Hello, Please post the data division (the fields) and procedure division (the moves and displays) code that produced your 000/0 output.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 9 Thu Dec 14, 2017 3:52 pm Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us