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
 

 

Whats the solution for this REDEFINE question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mijanurit
Currently Banned

New User


Joined: 26 Aug 2005
Posts: 33
Location: bangalore

PostPosted: Sun Jan 08, 2006 8:42 am    Post subject: Whats the solution for this REDEFINE question
Reply with quote

hi davidatk,

plz tell me in details for the following ...

Quote:

01 filler
05 x pic x(5).
05 y redefines x pic 9(5).

when x=123 3
what is the content of y?

in case of x=123 z OR x='123=3' what will be the content of y if y is declared as pic s9(5)?


thanks and regards
mijanurit
Back to top
View user's profile Send private message

gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Mon Jan 09, 2006 10:21 am    Post subject: Re: Whats the solution for this REDEFINE question
Reply with quote

mijanurit wrote:
hi davidatk,

plz tell me in details for the following ...

Quote:

01 filler
05 x pic x(5).
05 y redefines x pic 9(5).

when x=123 3
what is the content of y?

in case of x=123 z OR x='123=3' what will be the content of y if y is declared as pic s9(5)?


thanks and regards
mijanurit



hai mijanurit,

i suppose the value of Y will also contain the same data as that of X. Rediefines simply share the memory space irrespective of their PIC.

corrections welcomed...

gowtham
Back to top
View user's profile Send private message
vinodmaanju

New User


Joined: 10 May 2005
Posts: 28
Location: Pune

PostPosted: Mon Jan 09, 2006 10:31 pm    Post subject: Re: Whats the solution for this REDEFINE question
Reply with quote

Hi mijanurit,

Output will be same as X. coz redefines share same memory locatiom from starting bytes according your length of Y.


Thanks
Vinod
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Tue Jan 10, 2006 3:50 am    Post subject: Re: Whats the solution for this REDEFINE question
Reply with quote

Hi mijanurit,

Both vinodmaanju and gowtham_1982 are correct. the 9(5) field will contain the same hex value as the X(5) field. the difference come when you try to use the field.

First, you understand the hex representation of the numbers?

Shown below are 0-9 0 = x?F0?, 1 = x?F1? etc.

Code:

0123456789
FFFFFFFFFF
0123456789


Given a PIC 9(5) value 12345

This is an unsigned field where the hex value will be ?F1F2F3F4F5?. When addition is performed on this only the low order 4 bits of each byte are considered for the magnitude of the value. The high order 4 bits do not play any part, the sign is assumed to be + (positive).

Given a PIC S9(5) value +12345

This is a signed field where the hex value will be ?F1F2F3F4C5?. ?F1F2F3F4D5? if the value was -12345. When addition is performed only the low order 4 bits are considered for the magnitude of the number and the high order 4 bits of the last byte is considered for the sign.

Normally in a PIC S9(?) field the sign 4 bits will be ?C? = ?+? and ?D? = ?-?.

Now, when addition is performed on a PIC 9(?) or S9(?) field. The field is converted to COMP-3, the addition performed, and converted back to zoned decimal.

When you convert a zoned decimal number to a PIC 9(?) COMP-3 (unsigned) anything can be in the sign bits (x?0? ? x?F?) When converted, the COMP-3 sign bits will always be x?F? and when converted back to the zoned decimal format the sign bits x'F' will remain.

When you convert a zoned decimal number to a PIC S9(?) COMP-3 (Signed) only x?A? ? x?F? can be in the sign bits.
x?A?,x?C?,x?E?,x?F? will be ?+? and x?B?, x?D? will be ?-?. When converted the sign bits will always be either x?C? or x?D?. Anything other than x?A? ? x?F? will cause an 0C7 abend. The sign bits of s successfull add x'C' or 'D' will remain when converted back to zoned decimal.

In both cases, signed and unsigned, anything in the low order 4 bits of each byte other than x?0? ? x?9? will cause an 0C7 abend.

That?s why, when you redefine a PIC X(5) VALUE = ?123 3? as a PIC 9(5) or as a PIC S9(5) the space is converted to a 0 (zero). The hex value of the space is x?40?. This is not the sign byte, so the high order 4 bits the ?4? is ignored, and the low order 4 bits '0' are x?0? ? x?9?.

The ?123 3? is converted to VALUE 12303. x?F1F2F3F0F3? for PIC 9(5) and x?F1F2F3F0C3? for S9(5)

And that?s why you will get an 0C7 abend if your try ?123=3? because the ?=? = x?7E?. The 'E' is not x'0' - x'9'

Or when you try ?1234.? Where ?.? = x?90? and if you try to add to an S9(5) you get an 0C7. The '9' is the sign bits and not one of the allowed values. And converts to ?12340? if you add to an 9(5) because the sign bits are ignored.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Easytrive Redefine vidyaa CA Products 4 Mon Jun 19, 2017 6:01 pm
No new posts Redefine SYS1.PROCLIB farhad_evan JCL & VSAM 12 Mon May 22, 2017 10:54 pm
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm


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