Read Binary (BCD) file with variable length records

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
avazeos
Participant
Posts: 3
Joined: Tue Jun 07, 2005 9:20 am

Read Binary (BCD) file with variable length records

Post by avazeos »

Hi to all,

I am a new comer in the forum and I need your help for the following issue(s).

The task that we must do using Datastage is to read a binary file (CDRs) that is in BCD format and translate it in ascii format. For this i want someone to describe me which is the best practise for doing so using Datastage.
Another problem with the binary file is that it is not a delimited file and the fileds have variable length. In order to understand the length of a variable length field there is a standard field before that with the length of the next field. So I would also like a best practise approach for this situation.

Thanks in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

What you describe is a very unusual scenario - a binary file with other than fixed length records. Do you have any description (such as a COBOL file definition) of the structure? It may be that there is more than one record type - you need to know this before you can proceed.

Once you have the file ("Table") definition you can probably use the Complex Flat File stage to read the file and automatically unpack the binary data.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
avazeos
Participant
Posts: 3
Joined: Tue Jun 07, 2005 9:20 am

Post by avazeos »

Hi,
thanks for your answer.
I have the description of the file format. The file structure is like that:
In the beginning of the row there are some fixed length fileds that are standard in every record and after that there is a field with the total length of the record annd then there are some variable length records that first they have a one byte field with the size of the following record.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's fine. If you can represent that as a COBOL format and import from that (put it in a file) then you can readily use the CFF stage. Is every field BCD, or do you have a mix of encodings?

Otherwise you can read the entire record as a VarChar (I've assumed that each line has a line terminator) and parse it in a Transformer stage using substring techniques, having constructed a table definition from the information that you have.

To process these CDRs in DataStage, you will need to convert the BCD numerics into "regular" decimal. I'm in an Internet Cafe at the moment, but am fairly sure there are some SDK routines that can help.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

Are these Call Detail Records?
Depending on the record format, there is often feature encoding at the bit level, as well as BCD encoding of digits.
Not convinced that DataStage is the right tool for this job, but if you insist, then you wil probably have to disassemble each record piece by piece, ie the record header with lengths first, then each subfield, length byte first, the number of nibbles or bytes, then the next, etc.
Sounds like a job for a UnivBasic routine, the array processing and bitwise operators will be your friends.

Have fun

Carter
Post Reply