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

Moving Spaces to a numeric field?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
somnath

New User


Joined: 21 Mar 2005
Posts: 18
Location: India

PostPosted: Fri Jan 12, 2007 8:06 pm
Reply with quote

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.
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Fri Jan 12, 2007 9:46 pm
Reply with quote

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.
Back to top
View user's profile Send private message
somnath

New User


Joined: 21 Mar 2005
Posts: 18
Location: India

PostPosted: Tue Jan 16, 2007 11:29 am
Reply with quote

Thanks a lot Dave.

Somnath.
Back to top
View user's profile Send private message
Sasi Kiran Patha
Warnings : 2

New User


Joined: 19 Nov 2006
Posts: 73
Location: Hyederabad

PostPosted: Sat Jan 20, 2007 12:59 pm
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Jan 21, 2007 6:23 am
Reply with quote

Hello,

Please post the data division (the fields) and procedure division (the moves and displays) code that produced your 000/0 output.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top