how to read the comp-3 data

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
yimwai
Participant
Posts: 46
Joined: Thu Jul 01, 2010 9:34 pm

how to read the comp-3 data

Post by yimwai »

using "complex flat file" STAGE to read an EBCD file
I'm forced to change the usage to 'comp-3' when I set default value for a 'decimal' column.After that I find the data still not right .
the data should be as follow:
DECIMAL CHAR(8) CHAR(10)
0000 20100812 OK
0000 20100707 OK
0000 20100703 0K
but what OUTPUT IS AS FOLLOW
0000 201008 12OK
0000 2010 0707OK
0000 20 100703OK
SO I wander if I need to make additional set for comp-3 decimal data
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First off, it's EBCDIC and secondly, which in all that is the COMP-3 column? Can you post the complete definition from the FD?
-craig

"You can never have too many knives" -- Logan Nine Fingers
yimwai
Participant
Posts: 46
Joined: Thu Jul 01, 2010 9:34 pm

Post by yimwai »

the first column is decimal. I must set the 'usage' property to 'comp-3',or I can't set nullable or default value to the column.why?

set in 3 places for this column:
usage :comp-3
nullable: yes
default value:0

then I found the first column occupied wrong length ,so ....result data as i described before
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Could you please post the COBOL PICture clause for this file, it would make it a lot easier to understand the problem.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As requested. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I was just reinforcing your request, Craig :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And I, yours. :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yep, and with all this deja-vu all over again we still don't have a copybook.
yimwai
Participant
Posts: 46
Joined: Thu Jul 01, 2010 9:34 pm

Post by yimwai »

the copy book is as follow:
01 :RAAKYCUP:-REC.
05 :RAAKYCUP:-KEY.
10 :RAAKYCUP:-ID.
15 :RAAKYCUP:-ID-FORMAT PIC X(02).
15 :RAAKYCUP:-ID-NO PIC X(04).
05 :RAAKYCUP:-CUSTOMER-ACCT PIC S9(16) COMP-3.
05 :RAAKYCUP:-CUSTOMER-NAME PIC X(1).
....................................................

part of data file (EBCDIC hexadecimal )is like as follow:
F0 F1 F0 F0 F0 F9 F0 F0 F0 F0 F0 F0 F0 F1 F0 F0 F0
F0 F4 F0 F6 F2 D4...

So the data in these 4 columns are supposed to be:
01 | 0009 | (a number,according to F0 F0 F0 F0 F0 F0 F0 F1 F0 F0 F0 F0 F4 F0 F6 F2 ) | M
but the result is that the comp-3 only read the 9 of 16 bytes( red color) and the 10th byte( here is F0,green color) is put in the 4th column.
but i cannot change the column usage to be display (the information is "usage of decimal must be comp-3")
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

PIC S9(16) COMP-3 is stored in 9 bytes, not 16. COMP-3 stores one digit in 4 bits, plus it needs 4 bits for the sign, thus 16 digits / 2 = 8 plus sign and rounded up to the next 8-byte boundary.
Last edited by ArndW on Wed Aug 11, 2010 6:23 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly, was wondering if something like this was going on. Hence the need to see the PICture clause.

As noted, count the digits, add one for the sign if present, round up to even if odd and then divide by two to get the packed field size.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply