Reading EBCDIC file and Flattening it.

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
landaghaar
Participant
Posts: 38
Joined: Wed Sep 19, 2007 10:11 am
Location: Canada

Reading EBCDIC file and Flattening it.

Post by landaghaar »

Hi,
I have a complex cobol file in ebcdic format. i have trouble reading the COMP fields.

Here is the copybook ETI generated:
01 DCLFRGN-EXCHNG.
05 RECORD-ID PIC X(4).
05 PRTITION-NO PIC S9(4) COMP.
05 SESS-DT PIC S9(9) COMP.
05 SESS-TR PIC S9(9) COMP.
05 SESS-TM PIC S9(9) COMP.
05 TXN-SESS-ID PIC S9(4) COMP.
05 SEQ-NO PIC S9(4) COMP.
05 TXN-ID PIC S9(4) COMP.
05 SUB-TXN-NO PIC S9(4) COMP.
05 DEAL-NO-NULL PIC X(1).
05 DEAL-NO PIC S9(9) COMP.
05 DEAL-TYP-NULL PIC X(1).
05 DEAL-TYP PIC X(1).
05 HAS-AMT-NULL PIC X(1).
05 HAS-AMT PIC S9(16)V9(2) COMP-3.
05 HAS-CRNCY-CD-NULL PIC X(1).
05 HAS-CRNCY-CD PIC X(3).
05 HAS-INSTRMT-TYP-NULL PIC X(1).
05 HAS-INSTRMT-TYP PIC X(3).
05 WANTS-AMT PIC S9(16)V9(2) COMP-3.
05 WANTS-CURRENCY-COD PIC X(3).
05 WANTS-INSTRMT-TYP-N PIC X(1).
05 WANTS-INSTRMT-TYP PIC X(3).
05 ACTL-RT-NULL PIC X(1).
05 ACTL-RT PIC S9(18) COMP-3.
05 ACTL-RT-NO-OF-DECS-N PIC X(1).
05 ACTL-RT-NO-OF-DECS PIC S9(4) COMP.
05 SUG-RT-NULL PIC X(1).
05 SUG-RT PIC S9(18) COMP-3.
05 SUG-RT-NO-OF-DECS-N PIC X(1).
05 SUG-RT-NO-OF-DECS PIC S9(4) COMP.
05 SETL-RT PIC S9(18) COMP-3.
05 SETL-RT-NO-OF-DECS PIC S9(4) COMP.
05 TXN-STS-NULL PIC X(1).
05 TXN-STS PIC S9(4) COMP.
05 TXN-REAS-FOR-FAIL-N PIC X(1).
05 TXN-REAS-FOR-FAIL-LEN PIC S9(4) COMP.
05 TXN-REAS-FOR-FAIL-TEXT PIC X(256).
05 TXN-TYP PIC S9(4) COMP.
05 DEAL-GL-TYP PIC S9(4) COMP.
05 PROF-AMT PIC S9(16)V9(2) COMP-3.
05 DEAL-HOE-EQUIV-AMT-N PIC X(1).
05 DEAL-HOE-EQUIV-AMT PIC S9(16)V9(2) COMP-3.


This is the generated definition in DS:
RECORD-ID Char(4)
PRTITION-NO SmallInt(4)
SESS-DT Integer(9)
SESS-TR Integer(9)
SESS-TM Integer(9)
...


as you see SESS-DT must be in format YYYYMMDD, but what i get is:
3507224576
and for SESS-TM I get 2545994242 which is absord.
Any suggestions?
landaghaar
Participant
Posts: 38
Joined: Wed Sep 19, 2007 10:11 am
Location: Canada

Post by landaghaar »

Well, I found the problem in NULL values in the ebcdic file. i got rid of those problematic columns and it works for now. although it is not a good idea, but i can view my data. now i have another problem.
I have this basic job to read from mainframe and convert it to ascii sequencial file, now when i view the contents from DS they seem fine, when i open the file in a text editor it is in binary format.

how could i convert this mainframe file to ascii plain sequencial file?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Binary or EBCDIC? If the latter, you have an Import As EBCDIC property that you can set.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
landaghaar
Participant
Posts: 38
Joined: Wed Sep 19, 2007 10:11 am
Location: Canada

Post by landaghaar »

Well, the file is in EBCDIC format, but some columns are in COMP as mentioned above. when I open the definition they are stored as binary.
but I read the file as EBCDIC, go to a transformer one to one then write them to a flat file. the definition of the flat file is not cobol format.

here is the definition of the flat file:
RECORD_ID CHAR(4)
PRTITION_NO SmallInt
SESS_DT PIC Integer (9)
SESS_TR PIC Integer (9)
SESS_TM PIC Integer (9)
...

but when I open the file with a text editor i see all the junk data for Partition_no, sess_dt, sess_tr and sess_tm which should be numbers, but for CHAR fields i see correct ASCII characters.

How could I convert? If i create the same job in a server edition, it writes to flat file properly, but in EE it doesnt.

any help?
rajeevn80
Participant
Posts: 28
Joined: Mon Jan 31, 2005 10:58 pm

Post by rajeevn80 »

05 SESS-DT PIC S9(9) COMP.
S9(9) COMP requires 4 bytes of storage length. Once u have loaded the metadata set this field to a SMALLINT(4). Set additional properties for this field as big-endian, Data format - binary. This can be found by double cliking the field.

The try viewing the data.
Rajeev
Nobody knows Everything,
But U should not be the One who knows Nothing.
landaghaar
Participant
Posts: 38
Joined: Wed Sep 19, 2007 10:11 am
Location: Canada

Post by landaghaar »

rajeevn,
I fixed the problem the hard way :)
I agree about big-endian, i have done it already, when i view it from datastage it shows properly but when i open it in a text editor i get junk.
my workaround was inside the transformer.
I read as smallInt then my target file field is Varchar instead of smallint.
still it doesnt work, you have to show the datastage it is a number, so I divided it by one and then it shows proper numbers. i have no idea why datastage behaves like this.


guys, whenever you read a COMP column and want to write the content to a flat file you better divide it by one or multiply by one, doesnt matter, as long as you do a mathematical operation on it then dont convert, just write to a varchar target field and you are set. i know it sounds stupid but it works, unless people from DataStage tell us otherwise or fix this bug.

as for the Null values, the big-endian setting fixed that problem.
Post Reply