View previous topic :: View next topic
|
Author |
Message |
Huzefa
New User
Joined: 05 Dec 2006 Posts: 83 Location: Bangalore
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Huzefa
New User
Joined: 05 Dec 2006 Posts: 83 Location: Bangalore
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Huzefa
New User
Joined: 05 Dec 2006 Posts: 83 Location: Bangalore
|
|
|
|
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 |
|
|
|