Reading Fixed width

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
sriec12
Participant
Posts: 56
Joined: Mon Nov 01, 2010 5:34 pm

Reading Fixed width

Post 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?
antonyraj.deva
Premium Member
Premium Member
Posts: 138
Joined: Wed Jul 16, 2008 9:51 pm
Location: Kolkata

Post 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.
TONY
ETL Manager
Infotrellis India

"Do what you can, with what you have, from where you are and to the best of your abilities."
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post 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,
- james wiles


All generalizations are false, including this one - Mark Twain.
antonyraj.deva
Premium Member
Premium Member
Posts: 138
Joined: Wed Jul 16, 2008 9:51 pm
Location: Kolkata

Post by antonyraj.deva »

jwiles wrote:No, the decimal will be length 3 scale 2.
Slipped out of mind... :oops:
TONY
ETL Manager
Infotrellis India

"Do what you can, with what you have, from where you are and to the best of your abilities."
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post 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.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Post Reply