Page 1 of 1

Zoned Decimal Fields

Posted: Fri Jul 15, 2005 2:01 am
by JezT
I am processing a file that contains some fields with packed data in. For example, when the file is viewed within DS, the values look like the following:
{
5A
00{
M
L
Whereas the values of these fields should be as follows:
0
51
000
-4
-3
Is there a way within DS of converting these packed fields into ASCII ?

Cheers
Jez T

Posted: Fri Jul 15, 2005 2:15 am
by ArndW
JezT,

since these are binary fields DataStage cannot display them without knowing which conversion to apply. If you look into the routines/functions in the SDK you will find "DataTypePicComp3" which should solve your problem.

Posted: Fri Jul 15, 2005 3:26 am
by JezT
"DataTypePicComp3"

I have tried the above but it doesn't give the correct values.

For example, 'J' returns 7 when it should return -1. All the values provided are incorrect.

Posted: Fri Jul 15, 2005 3:31 am
by ArndW
JezT,

what is the exact datatype you are getting? It would seem that it is not a PIC S9 COMP-3 cobol type.

Posted: Fri Jul 15, 2005 3:38 am
by JezT
Examples of the values I am getting are:

In File
J
{
M
A
B
E
What they should be:
-1
0
-4
1
2
5
What I am getting when I use the Function DataTypePicComp3
4
7
-4
4
4
4
I think the fact that the correct value for M is obtained is purely coincedence.

JezT

Posted: Fri Jul 15, 2005 3:49 am
by ArndW
JezT,

that is not exactly what you need to know --> from what language is this field being written and what is the definition of that field in that language. This is kind of like a Rosetta Stone for data... ;)

Once the data type is known you can either use a built-in DS function to decode it or use those existing functions to write your own if it does not exist.

Posted: Fri Jul 15, 2005 4:07 am
by JezT
It is coming from the Mainframe (EBCDIC) and transferred to UNIX.

Code: Select all

03 TOT-NUM-PUB-INFO          PIC 9(01).
03 TOT-VAL-PUB-INFO           PIC 9(03).
03 MNTHS-SINCE-INFO          PIC 9(02).
03 NUM-NON-MAIL-CAIS        PIC 9(01).
The datatypes for the fields are as above.

Cheers
JezT

Posted: Fri Jul 15, 2005 5:08 am
by ArndW
JezT,

either your data is wrong or your PICture clauses are. The PIC 9 datatype is not packed, it is essentially a CHAR field that contains only digits. Are you doing the EBCDIC to ASCII conversion?

Posted: Fri Jul 15, 2005 9:22 am
by pnchowdary
Like ArndW suggested, you must do an EBCDIC to ASCII conversion using Ascii( ) function, before attempting to even view the data. If you have a packed field, other than EBCDIC to ASCII conversion, you have to make sure that even the storage length is correct, as the storage length changes when you unpack that field.

Posted: Fri Jul 15, 2005 12:42 pm
by logic
a hint..maybe useful maybe not..Every Mainframe file would be neccessarily accompanied with the cobol file defination. So looking into the .cfd file will help you analyse the data defination associated with the Respective column names. It might be that you are associating the defination with other fields. without trying to view the data then you can use the proper length and routines for conversion. otherwise i guess it should work as stated in the previous posts if the defination is as you have mentioned .