Page 1 of 1

Reading Fixed width

Posted: Thu Apr 07, 2011 8:06 pm
by sriec12
Hi GUys ,

I have problem in reading FIXED WIDTH file.
The file format is EBCDIC(character set).

Fox example:
input file: ab1234crest89.12

usually get the copy book

name PIC x(2)
ID PIC x(4)
class PIC x(5)
price PIC s9(1)v(2) comp-3


so while defining metadata in sequential file:

name char(2)
id char(2)
classs char(5)
price decimal(2,2):

here x represents char and v reflects it is decimal.

My Question is :in Squential file we have view button tab, i am able to get
char fields but i am not able to retriew decimal field.


plz guide me how to define in sequential metadata?

Posted: Thu Apr 07, 2011 11:17 pm
by antonyraj.deva
As per the copy book specifications, The length of the ID field should be 4 and the decimal is (1,2).
When using a fixed length file, the metadata has to be precise. Try after making the above changes.

Posted: Thu Apr 07, 2011 11:24 pm
by jwiles
No, the decimal will be length 3 scale 2.

A COBOL decimal definition shows the length before and after the decimal point: PIC 9(1)V(2) is #.##

To convert to DataStage decimal, use the sum of the before and after as the length: For the above, Length=3 and Scale=2. So, Dec(3,2) for DataStage's definition. Also, it is a packed decimal (COMP-3), so be sure to set that option as well.

Regards,

Posted: Fri Apr 08, 2011 12:03 am
by antonyraj.deva
jwiles wrote:No, the decimal will be length 3 scale 2.
Slipped out of mind... :oops:

Posted: Fri Apr 08, 2011 7:35 am
by FranklinE
In general, trying to read EBCDIC mainframe files is actually simpler than one might expect. Try the following settings for your read format:

Record level>>Record type=implicit
Field defaults>>Delimter=none
Type defaults>>General>>Character set=EBCDIC, Data format=binary
Type defaults>>Decimal>>allow all zeroes=yes

When you import the copybook, let DataStage handle converting the PIC clauses. The vast majority of the time it works very well. The "implicit" setting means, so far as I have seen, that your table definition determines your record length. If your data doesn't line up properly, make your adjustments in the columns, not in the read format.