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
 

 

How can I declare a WS var to move a S9(5) comp-3 value

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

New User


Joined: 08 Jun 2005
Posts: 4

PostPosted: Wed Jun 08, 2005 3:45 pm    Post subject: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi all,

Can any one tell me the size that I have to declare for an var in WS to display a COMP-3 var (eg:S9(5) comp-3).

Regards,
Back to top
View user's profile Send private message

senthilkumar selvaraju

New User


Joined: 30 May 2005
Posts: 16

PostPosted: Wed Jun 08, 2005 4:34 pm    Post subject:
Reply with quote

it takes 4 bytes( n/2 + 1)

n- number of bytes (12345 i.e 5 bytes)

1 - for sign so (5/2 + 1) = 3.5. Then it rounduped as 4 bytes.

So s9(5) comp-3 is equal to 4 bytes.
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Wed Jun 08, 2005 4:56 pm    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi,
I think it will take 3 bytes.
for example if we store +12345 in that variable, then it is internally stored as
12 34 5C
So total 3 bytes will be taken.
For even digit formula is (N/2+1)
for even digit (N+1/2)
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Wed Jun 08, 2005 4:57 pm    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi,
For ODD digit it is (N+1/2).
Back to top
View user's profile Send private message
muraly
Currently Banned

New User


Joined: 02 Jun 2005
Posts: 2
Location: chennai

PostPosted: Wed Jun 08, 2005 5:11 pm    Post subject: hi
Reply with quote

hi sentil

check u r answer

s9(5) com-3 will take 3 bites only.

why b'cos
each digit takes half byte
sign takes half byte

5 digits takes 2 1/2 bytes.
sign takes 1/2 byte.

total 3 bytes...

regards
muraly..
Back to top
View user's profile Send private message
srinivasareddy_80

New User


Joined: 07 Mar 2005
Posts: 4
Location: Chennai

PostPosted: Mon Jun 13, 2005 12:29 am    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi Friends,

we can count the size of Comp-3 field in 2 ways
1.S9(5) comp-3 It takes only N/2 1 Bytes,==>>5/2 1==>> 2.5 -.5(Remove the value which is available after Decimal point) 1==>>2 1=3 Bytes.

2.S9(5) comp-3. It is a Packed decimal, So each digit occupy 1/2 Byte 1/2 byte for sign(Right most 1/2 Byte), So 5*1/2 1/2==>>2.5 .5=3 Bytes
Back to top
View user's profile Send private message
srinivasareddy_80

New User


Joined: 07 Mar 2005
Posts: 4
Location: Chennai

PostPosted: Mon Jun 13, 2005 12:30 am    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi Friends,

we can count the size of Comp-3 field in 2 ways.


1. S9(5) comp-3 It takes only N/2 1 Bytes,==>>5/2 1==>> 2.5 -.5(Remove the value which is available after Decimal point) 1==>>2 1=3 Bytes.

2. S9(5) comp-3. It is a Packed decimal, So each digit occupy 1/2 Byte 1/2 byte for sign(Right most 1/2 Byte), So 5*1/2 1/2==>>2.5 .5=3 Bytes.


Srinivasa Reddy Lakki Reddy.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jun 13, 2005 6:59 am    Post subject:
Reply with quote

Hi Folks,

In my opinion the best way to calc the # of bytes in a comp-3 field is to total the # of 9s. If the total is even, divide by 2; if odd add 1 then divide by 2.

It eliminates playing w/the fraction and makes the division straightforward.

Just one man's opinion.
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Need information on COBOL MOVE CORRES... subratarec COBOL Programming 10 Tue Jun 28, 2016 10:38 pm


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