Page 1 of 1

how to read the comp-3 data

Posted: Sun Aug 08, 2010 7:01 pm
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

Posted: Sun Aug 08, 2010 8:16 pm
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?

Posted: Sun Aug 08, 2010 9:10 pm
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

Posted: Mon Aug 09, 2010 4:11 am
by ArndW
Could you please post the COBOL PICture clause for this file, it would make it a lot easier to understand the problem.

Posted: Mon Aug 09, 2010 5:44 am
by chulett
As requested. :wink:

Posted: Mon Aug 09, 2010 6:49 am
by ArndW
I was just reinforcing your request, Craig :wink:

Posted: Mon Aug 09, 2010 6:53 am
by chulett
And I, yours. :lol:

Posted: Mon Aug 09, 2010 7:46 am
by ArndW
Yep, and with all this deja-vu all over again we still don't have a copybook.

Posted: Tue Aug 10, 2010 7:30 pm
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")

Posted: Wed Aug 11, 2010 1:55 am
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.

Posted: Wed Aug 11, 2010 6:18 am
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.