Conveting Binary feed to ASCII feed in UNIX

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
r29g18
Participant
Posts: 9
Joined: Mon Apr 23, 2012 11:48 am

Conveting Binary feed to ASCII feed in UNIX

Post by r29g18 »

Hi,
Can we convert a Binary feed to ASCII feed in UNIX? Can you pls provide a sample code, if available?

We have a Datastage job to 'split' the Binary feed containing Header, detail recods and Trailer record. Thought is to replace the Datastage 'split' job to a UNIX script which can parse the feed and separate the Header, Detail and Trailer record.

Thanks.
Ria
The only way of finding the limits of the possible is by going beyond them into the impossible
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Depends on what you mean by "binary feed". I'm guessing you mean a mainframe file either in EBCDIC or with packed fields or both. Can you clarify? And confirm you are using a Server job, please.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jerome_rajan
Premium Member
Premium Member
Posts: 376
Joined: Sat Jan 07, 2012 12:25 pm
Location: Piscataway

Re: Conveting Binary feed to ASCII feed in UNIX

Post by jerome_rajan »

Not too sure what you are looking for but I think "iconv" can do the job for you.

Syntax: iconv -f encoding -t encoding
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn

Life is really simple, but we insist on making it complicated.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The job includes the need to "parse the feed and separate the Header, Detail and Trailer record", not just a straight conversion as noted in the subject...
-craig

"You can never have too many knives" -- Logan Nine Fingers
jerome_rajan
Premium Member
Premium Member
Posts: 376
Joined: Sat Jan 07, 2012 12:25 pm
Location: Piscataway

Post by jerome_rajan »

My bad! Will learn to read the content before jumping to a solution next time
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn

Life is really simple, but we insist on making it complicated.
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

Ria,

My first question would be why is it necessary to accomplish the split in Unix? I don't see any performance gain to be had between (for example) dropping the header and trailer in Unix and dropping it after the input stage.

Nearly every job I have starts with an FTP stage from a mainframe dataset. When the dataset includes more than one record type, I parse the records in a transformer stage using substring derivations and the record type as a constraint. Complex Flat File does it on the input.

If your source is mainframe and EBCDIC, the FAQ on this may be helpful.
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
r29g18
Participant
Posts: 9
Joined: Mon Apr 23, 2012 11:48 am

Post by r29g18 »

Thanks for your quick responses!

Yes, its EBCDIC file with packed data format containing heade, Detail and Trailer record. We've an existing DataStage Server job for splitting the file into different formats.

iconv has been used in UNIX. But But, its showing a message ""Can not open converter". Command:
iconv -f UTF-8 -t ASCII TPS_DDS_20120411.DAT
(UTF-8 was also checked with UTF-16, BIN also, but the error msg was the same). Can you pls share if above command needs to be corrected?

od command was also. But, it was not useful.
od -c TPS_DDS_20120411.DAT
od -x TPS_DDS_20120411.DAT

Thanks in advance for your immediate attention.
Ria
The only way of finding the limits of the possible is by going beyond them into the impossible
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Stick with the DataStage job. Any straight 'conversion' of the entire file will corrupt the packed fields and it's more trouble than it is worth to try to parse out the different record types, converting the individual string fields and unpacking the others using a script. Of course, you could fall back on Perl or something of that ilk but if you've got something that works why bother? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

I can't help with your command line questions. I can offer a successful method I use, which I summarized in the FAQ viewtopic.php?t=143596&sid=96688420e3bd ... f6045c5a9b

Read the beginning section, then look for the question "Q: My mainframe file has two or more record types. If I'm not using Complex Flat File, how do I read the file?"

Post any further questions you may have here, and I'll try to help.
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do keep in mind the fact that (as best as we can tell) they already have a DataStage job that does all this. They are looking for an alternative for some reason.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ahmedwaseem2000
Premium Member
Premium Member
Posts: 145
Joined: Fri Sep 15, 2006 12:23 pm

Post by ahmedwaseem2000 »

the quickest way would be to use datastage to do this task. However, there is option like dd to convert the ebcidic file to ascii, this does not convert compressed or comp fields. so, the best way is to write a c or cobol program that converts byte by byte.

alternatively, if you have perl and know how to use it then you could check this link which has got some code which does this taskhttp://search.cpan.org/~cxl/Convert-EBC ... /EBCDIC.pm

Hope this helps!!
Post Reply