Page 1 of 1

data type conversion

PostPosted: Fri Jun 11, 2010 10:44 am
by sunwillow
hello
i have a question.
I unload a dataset from a table. there was a filed which was defined in DEC(15,2), So i must use the HEX parm in the dataset to see it.
....カ.&.
00016350
0001650D


I want to convert the filed to FS, but the conversion result was -116635500,
but if i query it in the table, the result is -1166355.00
how can i convert it that make it the same as the tale?

convertion parm
//SYSIN    DD *                     
 OPTION COPY                       
 INREC  FIELDS=(65,8,PD,TO=FS)

Re: data type conversion

PostPosted: Fri Jun 11, 2010 10:21 pm
by skolusu
sunwillow,

DB2 DECIMAL (15,2) = COBOL PIC S9(13)V9(2) COMP-3. = 8 BYTES of storage

You need to use edit mask to retain the decimal value. Use the following control cards. The positive numbers will have a space for sign and negative numbers will have - as sign.

//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC FIELDS=(65,8,PD,EDIT=(SIIIIIIIIIIIIT.TT),SIGNS=(,-))
//*


If you the + sign for positive numbers then change the signs statement to
SIGNS=(+,-)

Re: data type conversion

PostPosted: Mon Jun 14, 2010 3:23 pm
by sunwillow
skolusu,
I got it, thank you very much.