Page 1 of 1

Reading EBCDIC file and Flattening it.

Posted: Wed Sep 19, 2007 11:45 am
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?

Posted: Wed Sep 19, 2007 1:43 pm
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?

Posted: Thu Sep 20, 2007 12:19 am
by ray.wurlod
Binary or EBCDIC? If the latter, you have an Import As EBCDIC property that you can set.

Posted: Thu Sep 20, 2007 6:01 am
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?

Posted: Thu Sep 20, 2007 6:06 am
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.

Posted: Thu Sep 20, 2007 7:08 am
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.