Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
about comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
ksivapradeep

Active User


Joined: 30 Jul 2004
Posts: 98

PostPosted: Mon Sep 13, 2004 11:12 am    Post subject: about comp-3
Reply with quote

how it will(+1234) store in the comp-3 .

01 a pic s9(4) comp-3 value +1234.
display a.
Back to top
View user's profile Send private message
References
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1506

PostPosted: Mon Sep 13, 2004 9:10 pm    Post subject:
Reply with quote

Hi K,

If you looked at the field in a dump you would see X'01234C'. BTW you should always define COMP-3 fields with an odd number of "9"s.

The field will DISPLAY as "01234{". The DISPLAY verb UNPACKs the field. If you turned HEX ON when you viewed the SYSOUT, you'd see
X'F0F1F2F3C4'. C4 displays as "{".

If the field was negative you'd see X'01234D' in the dump and it would DISPLAY as "01234}", X'F0F1F2F3D4'.
Back to top
View user's profile Send private message
ksivapradeep

Active User


Joined: 30 Jul 2004
Posts: 98

PostPosted: Wed Sep 15, 2004 9:36 am    Post subject:
Reply with quote

ok jack,but i am getting 123N for -ve value (-1234) then why it shouldnt do unpack and display as 1234.

regards
siva pradeep
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1506

PostPosted: Wed Sep 15, 2004 11:21 am    Post subject:
Reply with quote

Hi Siva,

My apologies, I really messed up that post. I'm resending it with the corrections below.

If you looked at the field in a dump you would see X'01234C'. BTW you should always define COMP-3 fields with an odd number of "9"s.

The field will DISPLAY as "0123D". The DISPLAY verb UNPACKs the field. If you turned HEX ON when you viewed the SYSOUT, you'd see
X'F0F1F2F3C4'. C4 displays as "D".

If the field was negative you'd see X'01234D' in the dump and it would DISPLAY as "0123M", X'F0F1F2F3D4'.

Sorry for the confusion.

You said in your latest reply that you got "123N" when you displayed a packed -1234. I calculated that you should have gotten a "0123M". Could that have been a typo?

You ask:
Quote:
then why it shouldnt do unpack and display as 1234.

I assume you mean "why 123M and not 1234?". The answer is that UNPACK takes the last digit and the sign in a packed field and reverses them when performing the UNPACK. All other digits in the field are converted to Fn, where n is the original packed 4 bit digit. So, that means that 4C (the last digit and sign of the positive number) becomes C4 and 4D (the last digit and sign of the negative number) becomes D4 and they display as D and M respectively.

BTW, what does "-ve" mean?
Back to top
View user's profile Send private message
ksivapradeep

Active User


Joined: 30 Jul 2004
Posts: 98

PostPosted: Wed Sep 15, 2004 2:15 pm    Post subject:
Reply with quote

ok jack thanks 4 ur clarification i understood well .and -ve means negative
Back to top
View user's profile Send private message
ksivapradeep

Active User


Joined: 30 Jul 2004
Posts: 98

PostPosted: Wed Sep 15, 2004 2:34 pm    Post subject:
Reply with quote

hi jack i got 1 doubt that ,actually the display will reverses and takes the actual length 4m the comp-3 bu why its displaying 123n if we store -1234

regards
siva pradeep
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1506

PostPosted: Wed Sep 15, 2004 10:04 pm    Post subject:
Reply with quote

Hi Siva,

You ask:
Quote:
why its displaying 123n if we store -1234


The ans. is "that's the way IBM does it." If you want to display it as -1234 you have to move it to a field defined as "PIC ----9" or PIC S9999 SIGN IS LEADING SEPARATE and DISPLAY that field.

Check my syntax before trying this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1