View previous topic :: View next topic
|
Author |
Message |
sripallu
New User
Joined: 11 May 2005 Posts: 12 Location: India
|
|
|
|
Hi,
I need some help from Guru's here !
I am receiving a file which is unloaded from a db2 table and there are particular columns which are DECIMAL(31,2) and has been modified as
characters with the help of COALESCE function
Here are how theydefined
1. In the table
X1 DECIMAL (31,2) WITH DEFAULT NULL
2. Unload job which unloads by
COALESCE(CHAR(X1),CHAR(' ')) AS X1
3. In the flat file i have received as (this is what i have declared in copybook)
X1-FILE PIC X(33) , and i could see the field value as below
' 000000000000000000000000000123.33'
3. I want this field to be moved to a report variable
HEADER-X1 PIC Z.ZZZ.ZZZ.ZZZ.ZZZ.ZZ9,99
I have tried using the NUMVAL function and getting U4038 error, also tried to use NUMVAL-C but no luck
Can someone please guide me in this regard? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
01 a-field-with-a-good-name.
05 some-random-blank PIC X.
05 nice-name-integer-part PIC 9(29).
05 nice-name-decimal-point PIC X.
88 decimal-point-is-ok VALUE ".".
05 nice-name-decimal-part PIC 99.
01 another-field-with-good-name PIC 9(29)V99.
01 FILLER REDEFINES another-field-with-good-name.
05 afwgn-integer-part PIC 9(29).
05 afwgn-decimal-part PIC 99, |
On the first group, check the obvious things for being NUMERIC and use the 88. If all OK, MOVE the obvious to the obvious receivers, and use another-field-with-good-name.
At the moment I don't care why you can't get NUMVAL to work - I don't use it, through choice :-). |
|
Back to top |
|
|
sripallu
New User
Joined: 11 May 2005 Posts: 12 Location: India
|
|
|
|
Bill Woodger wrote: |
Code: |
01 another-field-with-good-name PIC 9(29)V99.
01 FILLER REDEFINES another-field-with-good-name.
05 afwgn-integer-part PIC 9(29).
05 afwgn-decimal-part PIC 99, |
. |
thank Bill,
I am compiling thru Endevor and i dont have control to use Arith for using varibales more than 18digits ,
will my program compiles if i declare PIC 9(29)V99 ??
any how i will give a try, but just curios upfront |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Nope. Not a chance. Probably also why NUMVAL/NUMVAL-C were not working.
Why is the field 31 digits in the db if you can't process it?
Just split the 29-byte fields into two, 15 and 14 (or any combination that you like as long as less than or equal to 18). Increase the number of MOVEs appropriately. Even the editing will work. |
|
Back to top |
|
|
sripallu
New User
Joined: 11 May 2005 Posts: 12 Location: India
|
|
|
|
We have an unload job which extracts the data from the db2 table and provide us in a file , i am using that file to generate a quick report
below is the snapshot of select stmt mentioned in that
select
COALESCE(CHAR(X1),CHAR(' ')) AS X1
from <table>
where <condition>
;
This unload job (DSNTIAUL) runs and generates the file
BTW : the above declarations couldn't pass thru compilation ! Since the db2 stores the DECIMAL as packed decimal we have used the above CHAR to have them in file readable format,
I will try to split the variable as
PIC X(15)
PIC X(14) and check each of them separately |
|
Back to top |
|
|
sripallu
New User
Joined: 11 May 2005 Posts: 12 Location: India
|
|
|
|
I understood sometimes we need to think simple rather than using functions/or any other fancy stuff
Splitting the variables did the trick ! |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Btw what is the purpose of DECIMAL (31,2) big amount? |
|
Back to top |
|
|
sripallu
New User
Joined: 11 May 2005 Posts: 12 Location: India
|
|
|
|
Not sure
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
May be thats where you can start asking this question to Business or responsible parties, as tomorrow what is plan B if you get more than 18 bytes? |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
IMO, you should always question a requirement that makes no sense. It is your duty as a professional programmer. What if it was a typo in the specification document? It happens. |
|
Back to top |
|
|
|