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

Author Message
Vedam

New User

Joined: 24 Apr 2007
Posts: 23
Location: India

 Posted: Sun Apr 29, 2007 5:24 pm    Post subject: How many bytes does comp-3 take? Hi, can you please let me know how many bytes will the following take? can you please explain in detail? 1. S9(12)V9(5) COMP-3 2. S9(17)V9(8) COMP-3 3. S9(18)V9(18) COMP-3 will any of these give compilation error? Thanks in advance,

dick scherrer

Site Director

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

 Posted: Sun Apr 29, 2007 9:42 pm    Post subject: Hello, For "normal" processing the maximum number of digits is 18 (with the ARITH(EXTEND) compiler option, it may be 31). To calculate the byte-length of a comp-3 field, start with the total number of digits and divide by 2 giving a result (discarding the remainder if any), then add 1 to the result. So, a field with "pic s9(6) comp-3" would take 4 bytes (6/2 +1). A field with "pic s9(9) comp-3" would take 5 bytes (9/2 +1) - the .5 remainder is discarded. It does not matter if there are any decimal places - decimal places do not alter the field length, they are just another digit. Using the above (and the Fine Manual linked to from this site), you can calculate the lengths of your fields and decide which might be valid in which condition(s). After you do the calculations and look in the Fine Manual, let us know if you have any questions. As a rule, always define an odd number of digits for a comp-3 item. Defining comp-3 fields with an even number of digits only leads to confusion.
Vedam

New User

Joined: 24 Apr 2007
Posts: 23
Location: India

 Posted: Sun Apr 29, 2007 11:29 pm    Post subject: Re: how many bytes does comp-3 take? Thanks a lot for this. It was relly helpful
dick scherrer

Site Director

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

 Posted: Mon Apr 30, 2007 12:38 am    Post subject: You're welcome What did you decide were your 3 answers? If you tell me yours, i'll tell you mine
Vedam

New User

Joined: 24 Apr 2007
Posts: 23
Location: India

 Posted: Mon Apr 30, 2007 4:51 pm    Post subject: Re: How many bytes does comp-3 take? I think 2 and 3 would give compilation error and the first one would take 9 bytes. please correct me if I am wrong.
murmohk1

Senior Member

Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

 Posted: Mon Apr 30, 2007 5:12 pm    Post subject: Vedam, Good.
dick scherrer

Site Director

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

 Posted: Mon Apr 30, 2007 7:24 pm    Post subject: Hello, One clarification - depending on the ARITH compiler option setting, this "2. S9(17)V9(8) COMP-3" may or may not compile successfully. Normally, the EXTEND is not used, so your assessment is on target
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Error in SQL-PLIST3 'Above value tru... rikdeb DB2 4 Wed Sep 06, 2017 1:34 pm Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm

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