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
 

 

Moving an 9(20) Decimal field to COMP-1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 85
Location: Bangalore

PostPosted: Tue Nov 17, 2009 8:36 pm    Post subject: Moving an 9(20) Decimal field to COMP-1
Reply with quote

Hi
I have been trying to move a 9(20) field to a COMP-1 variable to load into a DB2 FLOAT variable. But since my COBOL compiler can handle only 18 digits only the rightmost 18 digits are being moved truncating the first 2 digits.

If there any way that I can move all the 20 digits to the COMP-1 variable without truncation
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Nov 17, 2009 8:40 pm    Post subject:
Reply with quote

Compiler option ARITH(EXTEND) extends the maximum digits from 18 to 31; it should be noted that this is not the default. This works on the Enterprise COBOL compilers for sure; ( though , I'm not sure how far back it goes.)

Other way round is, click on the manuals link at the top of the page, find the COBOL Programming Guide, and look up the ARITH compile option. This has been discussed many times on this forum - so you have a chance to search the forum as well on ARITH in Mainframe COBOL part of the Forum.
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 85
Location: Bangalore

PostPosted: Tue Nov 17, 2009 8:56 pm    Post subject: Reply to: Moving an 9(20) Decimal field to COMP-1
Reply with quote

I tried to do that but does not work with the compiler installed on our system.
Is there any go around other than this.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Nov 17, 2009 8:58 pm    Post subject: Reply to: Moving an 9(20) Decimal field to COMP-1
Reply with quote

ARITH(EXTEND) was introduced with OS/390 COBOL, version/release 2.2.1.

Otherwise, you'd have to write a small Assembler sub-program, which will perform this for you.

Although you could do this with Assembler H (IEV90), High-Level Assembler (ASMA90) introduced many new instructions to accomplish this easier.

Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Tue Nov 17, 2009 9:07 pm    Post subject:
Reply with quote

Quote:
I tried to do that but does not work with the compiler installed on our system.


what did you try?
what did not work?
if you would bother to read the manuals, as Robert suggested,
you would have found out that you can have compiler options in your source program,
which if you did try WOULD WORK

besides, if your installation required the 20 digits,
someone responsible for assigning you this task would have coordinated
with the sys-ops/compiler support group to allow for this.

Considering you obvious lack of expertise, could it be that
you really don't need this 20 digit number????

and, how did you define the 9(20)?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Tue Nov 17, 2009 9:25 pm    Post subject:
Reply with quote

Quote:
I tried to do that but does not work with the compiler installed on our system.
Is there any go around other than this.
Which implies either (1) the system you are running on is using software more than 9 years old (ARITH(EXTEND) has been available at least since 2000 or 2001), or (2) you didn't use the compiler parameter correctly. Posting the first line of compiler output (which has the name and version) would resolve the first issue real fast.

Depending on what you're doing, and how you're doing it, workarounds you may be able to use include an Assembler routine (as mentioned), or you may cut the field down to 18 digits if you truly are running on an old COBOL compiler, or you may have the specifications changed, or you may have to go back to whoever gave you the assignment and tell them it cannot be accomplished under current conditions.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Tue Nov 17, 2009 9:33 pm    Post subject:
Reply with quote

I just went back and looked at your original post. You are aware, I hope, that COMP-1 fields are internally equivalent to a 9-digit number so trying to keep all 20 digits is futile? From the manual:
Quote:
Internal floating-point data items are converted as if they were moved to a data item as follows:

* For COMP-1: an external floating-point data item with PICTURE -9.9(8)E+99
Even a COMP-2 only holds 18 digits at most, so if you are required to use floating point, give up on the idea of keeping all 20 digits as it cannot be done with floating point.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Nov 17, 2009 10:09 pm    Post subject: Reply to: Moving an 9(20) Decimal field to COMP-1
Reply with quote

I'm assuming that the 9(20) field is External/Display numeric or is it Packed-Decimal/COMP-3?

As Robert has said, you can't squeeze this entire value into a COMP-1 field, unless the value is not greater than the maximum capacity/value for a COMP-1 field and this must be confirmed with your colleagues ahead of time.

I would go back to the individual who assigned this to you and ask him how can you complete your assignment?

Apparently, there's some level of disconnect here and bad assumptions have been made.

Bill
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 85
Location: Bangalore

PostPosted: Wed Nov 18, 2009 3:59 pm    Post subject: Reply to: Moving an 9(20) Decimal field to COMP-1
Reply with quote

In the input Copybook I was not able to define the field as 9(20) due to compiler limitations and hence defined it as X(20).

As mentioned by Robert and other folks in here I tried to use the option ARITH(EXTEND) in COMPILE PARMS in the Change Man option while compiling the COBOL Routine. But since I was moving a X(20) field into a COMP-2 variable which has a capacity to hold only 18 digits, the data was either way truncated. I had to move the data into one of the COMP variables since using this variable I need to laod into DB2 DB which is defined as FLOAT.

As per the above post I understand there is no option to squeeze all the 20 digits into one variable and I got with the system Folks and got the field defined to 9(18).

Thanks for all the help and suggestions.
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am


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