Page 1 of 2

Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 4:08 am
by mainframe_novice
I was trying to unload DB2 data through query which involves joins and has functions like sum . There are 2 amount fields which are defined as Decimal 11,2 in DB2 .

I tried BMCUNLOAD and DSNTIUL .
But while data in non numerica fields was accurate , I found junk / garbage data in numeric fields .

I was suggested to use the copybook structure in order to view this data .

Since there is no processing involved and I just load the data back to other table , I don't prefer to add a copybook .

Can somebody help ?

IBM Unload,BMCUNLOAD or whatever is just fine with me .

Appreciate your help !

Please let me know if any additional information is required.

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 4:28 am
by William Thompson
mainframe_novice wrote:But while data in non numerica fields was accurate , I found junk / garbage data in numeric fields .
Please let me know if any additional information is required.
Yes, please provide a 'hex on' cut&paste image of the "junk / garbage" fields.

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 6:07 am
by dick scherrer
Hello,

Do you understand packed-decimal and binary fields. . .?

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 10:11 am
by mainframe_novice
Little bit....

However I found some sample code on this and other forums where SORT was used for converting these values to readable format .
It was a combination of Sort,Edit and outrec .

I tried to write similar code but got the error CD = S000|U0016 when I tried to submit the job .I couldn't get more information on this error.
PREP was successfull on the job .

Can someone help me understand what happens when we unload the numeric fields from DB2 ? What format they are in ? And how they can be converted into readable format ?

For now I just see some symbols like & , @ or some letters in these fields .

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 10:43 am
by William Thompson
mainframe_novice wrote:I tried to write similar code but got the error CD = S000|U0016 when I tried to submit the job .I couldn't get more information on this error.
PREP was successfull on the job .
Please post the cut&paste of the JCL and all sysouts.
Can someone help me understand what happens when we unload the numeric fields from DB2 ?
Yes, if you provide us with more information as mentioned above.
What format they are in ? And how they can be converted into readable format ?
For now I just see some symbols like & , @ or some letters in these fields .
As said, more information from you is needed for these requests.

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 5:58 pm
by mainframe_novice
db2 STRUCTURE for table car_sales
Car_Make Char 40
Car_Model Char 40
Sales_Price Decimal 11,2
Down_Payment Decimal 11,5

In the unloaded flat file I found the data for
Sales_Price was at position 81-89
Down_Payment at position 90,94
(I don't know why the data is not as per the db2 structuure..)

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 6:10 pm
by Tina_campbell
This is similar to what I had found on one of the sites
//S1 EXEC  PGM=SORT
//SORTIN      DD  DSN =DATA.CARSALES.RESULT,DISP=SHR
//SORTOUT   DD  DSN =DATA.CARSALES.RESULT,DISP=SHR
//SYSOUT      DD  SYSOUT=*
//SYSIN      DD  SYSOUT=*
    SORT FIELDS=COPY
    OUTREC FIELDS =(1,80,81,9,PD,EDIT(IIIITTTTT.TT),90,5,PD,EDIT=(ITTTTT.TTTTT))
/*


It failes with S0000|U0016

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 7:20 pm
by mainframe_novice
Yes...I still need to get it working

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 9:01 pm
by mainframe_novice
I figured it out .I can't use the same file as an input and output .
Because the length of input file is truncated since data was unloaded in binary format .
When through sort we convert it back to decimal , the same record length won't help .

Thanks everyone for the help .

If there is a way by which I can avoid SORT and directly unload it into readable decimal format , please reply .
Appreciate everybody's help again !

Re: Unload Numeric Format Data from DB2 to dataset

PostPosted: Wed Apr 28, 2010 10:24 pm
by Frank Yaeger
Tina,

I don't know where you got that SORT job, but it has several problems. Here's a version of it that wouldn't fail (although I can't say if it would do what you want since I don't know what you want to do).

//S1 EXEC  PGM=SORT
//SORTIN   DD  DSN=...  input file
//SORTOUT  DD  DSN=...  output file
//SYSOUT   DD  SYSOUT=*
//SYSIN  DD  *
    SORT FIELDS=COPY
    OUTREC FIELDS=(1,80,81,9,PD,EDIT=(IIIIIIIIT.TT),
       90,5,PD,EDIT=(IIIIIT.TTTTT))
/*


Note that the input and output must be different files.

If you're not familiar with DFSORT and DFSORT's ICETOOL, and you'd like to be, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080