View previous topic :: View next topic
|
Author |
Message |
rarvins
New User
Joined: 24 Jan 2007 Posts: 59 Location: Texas
|
|
|
|
Hi,
My requiremnt is that I have to produce a file with a COBOL program which can
be loaded into a DB2 table through the IBM load utility.
Say I have Table A with COL1 of datatype SMALLINT.
I am done with the processing logic and I write the output into a file
containing just one datatype S((04) COMP, so that i can load this file in to the
table.
But the problem is something like this:
I have moved a value 27797 to the S9(04) COMP.
But only 7797 is getting populated in the variable
resulting in data loss.
But when I run an insert query I able to insert 27797 into COL1 of TableA.
I dont understand where I am going wrong.
1) Cant S9(04) COMP hold a value as big as 27797 ?
2) Is there any other dataype or declaration that I have to use?
Can somebody help me out... |
|
Back to top |
|
|
vini_srcna
Active User
Joined: 26 May 2005 Posts: 178 Location: Copenhagen, Denmark
|
|
|
|
What is the equivalent datatype given by DCLGEN..?
Are you not making use of DCLGEN..?
It is meant to get rid of this kind of situations. |
|
Back to top |
|
|
rarvins
New User
Joined: 24 Jan 2007 Posts: 59 Location: Texas
|
|
|
|
This is S9(04) COMP is the declarationg given by the DCLGEN |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
A halfword binary can hold your value, but COBOL strictly honors the field definition, which says 4 digits, so the compiled COBOL code truncates the leftmost digit.
E.g., for PIC 9(1) COMP, although a halfword is used, only unsigned single-digit values are stored.
Since PIC 9(5) COMP thru 9(9) COMP allocate a fullword, I'm not sure how you can do this directly in COBOL.
I think it is unwise to store a 5-digit number in a halfword or SMALLINT, as it will not hold any 5-digit number. That's why PIC 9(1) COMP thru 9(4) COMP use a halfword - all 4-digit values can be accomodated. |
|
Back to top |
|
|
|